Skip to content

Commit

Permalink
Support default for pathtype: "regex" and use it
Browse files Browse the repository at this point in the history
Add support for setting a default-value for pathtype: "regex",
and add a default value to the image and init_image fields
for deviceplugin. There are  probably other places that need it,
but that'll have to be added later.

Signed-off-by: David Weinehall <[email protected]>
  • Loading branch information
dweineha committed Oct 25, 2024
1 parent 4adb638 commit 774de10
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
17 changes: 10 additions & 7 deletions cmu
Original file line number Diff line number Diff line change
Expand Up @@ -1606,13 +1606,16 @@ def get_obj(obj: Dict, field_dict: Dict, field_names: List[str],
_regexes = deep_get(_path, DictPath("regex"), [])
if isinstance(_regexes, str):
_regexes = [_regexes]
for _regex in _regexes:
_tmp = re.match(_regex, _raw)
if _tmp is not None:
for group in _tmp.groups():
if group is not None:
value.append(group)
break
if _raw is not None and _raw:
for _regex in _regexes:
_tmp = re.match(_regex, _raw)
if _tmp is not None:
for group in _tmp.groups():
if group is not None:
value.append(group)
break
elif default:
value = default
value = tuple(value)
_values.append((value, "raw"))
elif ptype == "tuple":
Expand Down
2 changes: 2 additions & 0 deletions views/DlbDevicePlugin.deviceplugin.intel.com.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ infoview:
- path: "spec#image"
pathtype: "regex"
regex: "^([^:]+):(.*)"
default: ["<none>"]
formatter: "list"
formatting:
field_colors:
Expand All @@ -76,6 +77,7 @@ infoview:
- path: "spec#initImage"
pathtype: "regex"
regex: "^([^:]+):(.*)"
default: ["<none>"]
formatter: "list"
formatting:
field_colors:
Expand Down
2 changes: 2 additions & 0 deletions views/DsaDevicePlugin.deviceplugin.intel.com.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ infoview:
- path: "spec#image"
pathtype: "regex"
regex: "^([^:]+):(.*)"
default: ["<none>"]
formatter: "list"
formatting:
field_colors:
Expand All @@ -76,6 +77,7 @@ infoview:
- path: "spec#initImage"
pathtype: "regex"
regex: "^([^:]+):(.*)"
default: ["<none>"]
formatter: "list"
formatting:
field_colors:
Expand Down
2 changes: 2 additions & 0 deletions views/GpuDevicePlugin.deviceplugin.intel.com.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ infoview:
- path: "spec#image"
pathtype: "regex"
regex: "^([^:]+):(.*)"
default: ["<none>"]
formatter: "list"
formatting:
field_colors:
Expand All @@ -80,6 +81,7 @@ infoview:
- path: "spec#initImage"
pathtype: "regex"
regex: "^([^:]+):(.*)"
default: ["<none>"]
formatter: "list"
formatting:
field_colors:
Expand Down
2 changes: 2 additions & 0 deletions views/IaaDevicePlugin.deviceplugin.intel.com.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ infoview:
- path: "spec#image"
pathtype: "regex"
regex: "^([^:]+):(.*)"
default: ["<none>"]
formatter: "list"
formatting:
field_colors:
Expand All @@ -76,6 +77,7 @@ infoview:
- path: "spec#initImage"
pathtype: "regex"
regex: "^([^:]+):(.*)"
default: ["<none>"]
formatter: "list"
formatting:
field_colors:
Expand Down
2 changes: 2 additions & 0 deletions views/QatDevicePlugin.deviceplugin.intel.com.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ infoview:
- path: "spec#image"
pathtype: "regex"
regex: "^([^:]+):(.*)"
default: ["<none>"]
formatter: "list"
formatting:
field_colors:
Expand All @@ -80,6 +81,7 @@ infoview:
- path: "spec#initImage"
pathtype: "regex"
regex: "^([^:]+):(.*)"
default: ["<none>"]
formatter: "list"
formatting:
field_colors:
Expand Down

0 comments on commit 774de10

Please sign in to comment.