Skip to content

Commit 3a7e617

Browse files
authored
Merge pull request #2007 from rexagod/fix-label-resolution-maps
Fix label resolution for maps
2 parents da0bceb + 3f0532b commit 3a7e617

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

pkg/customresourcestate/registry_factory.go

+2
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ func (c *compiledGauge) Values(v interface{}) (result []eachValue, errs []error)
264264
ev.Labels[c.labelFromKey] = key
265265
}
266266
addPathLabels(it, c.LabelFromPath(), ev.Labels)
267+
// Evaluate path from parent's context as well (search w.r.t. the root element, not just specific fields).
268+
addPathLabels(v, c.LabelFromPath(), ev.Labels)
267269
result = append(result, *ev)
268270
}
269271
case []interface{}:

pkg/customresourcestate/registry_factory_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func Test_values(t *testing.T) {
193193
},
194194
ValueFrom: mustCompilePath(t, "creationTimestamp"),
195195
}, wantResult: []eachValue{
196-
newEachValue(t, 1.6563744e+09),
196+
newEachValue(t, 1.6563744e+09, "name", "foo"),
197197
}},
198198
{name: "non-existent path", each: &compiledGauge{
199199
compiledCommon: compiledCommon{

0 commit comments

Comments
 (0)