Fix label resolution for maps
The `map[string]interface{}` resolution searched for values within various nested fields, but not the relative path itself.
Ref.: ca1da6b22e/pkg/customresourcestate/registry_factory.go (L603)
Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
This commit is contained in:
parent
91c09d0a96
commit
3f0532bc50
|
|
@ -264,6 +264,8 @@ func (c *compiledGauge) Values(v interface{}) (result []eachValue, errs []error)
|
|||
ev.Labels[c.labelFromKey] = key
|
||||
}
|
||||
addPathLabels(it, c.LabelFromPath(), ev.Labels)
|
||||
// Evaluate path from parent's context as well (search w.r.t. the root element, not just specific fields).
|
||||
addPathLabels(v, c.LabelFromPath(), ev.Labels)
|
||||
result = append(result, *ev)
|
||||
}
|
||||
case []interface{}:
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ func Test_values(t *testing.T) {
|
|||
},
|
||||
ValueFrom: mustCompilePath(t, "creationTimestamp"),
|
||||
}, wantResult: []eachValue{
|
||||
newEachValue(t, 1.6563744e+09),
|
||||
newEachValue(t, 1.6563744e+09, "name", "foo"),
|
||||
}},
|
||||
{name: "non-existent path", each: &compiledGauge{
|
||||
compiledCommon: compiledCommon{
|
||||
|
|
|
|||
Loading…
Reference in New Issue