Skip to content

Commit

Permalink
fixup! Allow field KV general matching
Browse files Browse the repository at this point in the history
  • Loading branch information
rexagod committed Aug 24, 2023
1 parent c805566 commit e7d0e44
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/customresourcestate-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,5 +482,5 @@ Examples:
[status, conditions, "[value=66]", name] # status.conditions[1].name = "b"
# For generally matching against a field in an object schema, use the following syntax:
[metadata, annotations, "bar:baz"] # metadata.annotations["bar:baz"] = "baz" (if present, ignored otherwise)
[metadata, annotations, "bar=baz"] # metadata.annotations["bar=baz"] = "baz" (if present, ignored otherwise)
```
4 changes: 2 additions & 2 deletions pkg/customresourcestate/registry_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,8 @@ func compilePath(path []string) (out valuePath, _ error) {
part: part,
op: func(m interface{}) interface{} {
if mp, ok := m.(map[string]interface{}); ok {
kv := strings.Split(part, ":")
if len(kv) == 2 /* k:v */ {
kv := strings.Split(part, "=")
if len(kv) == 2 /* k=v */ {
key := kv[0]
val := kv[1]
if v, ok := mp[key]; ok {
Expand Down
4 changes: 2 additions & 2 deletions pkg/customresourcestate/registry_factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,10 @@ func Test_values(t *testing.T) {
newEachValue(t, 0, "type", "Provisioned"),
newEachValue(t, 1, "type", "Ready"),
}},
{name: ": expression matching", each: &compiledInfo{
{name: "= expression matching", each: &compiledInfo{
compiledCommon: compiledCommon{
labelFromPath: map[string]valuePath{
"bar": mustCompilePath(t, "metadata", "annotations", "bar:baz"),
"bar": mustCompilePath(t, "metadata", "annotations", "bar=baz"),
},
},
}, wantResult: []eachValue{
Expand Down

0 comments on commit e7d0e44

Please sign in to comment.