diff --git a/internal/kubernetes/nodefilters.go b/internal/kubernetes/nodefilters.go index f1569b44..5aada7a0 100644 --- a/internal/kubernetes/nodefilters.go +++ b/internal/kubernetes/nodefilters.go @@ -122,7 +122,7 @@ func ConvertLabelsToFilterExpr(labels map[string]string) *string { if k != "" && labels[k] == "" { res = append(res, fmt.Sprintf(`'%s' in metadata.labels`, k)) } else { - res = append(res, fmt.Sprintf(`metadata.labels.%s == '%s'`, k, labels[k])) + res = append(res, fmt.Sprintf(`metadata.labels['%s'] == '%s'`, k, labels[k])) } } temp := strings.Join(res, " && ") diff --git a/internal/kubernetes/nodefilters_test.go b/internal/kubernetes/nodefilters_test.go index e2b21f4b..c0c7f491 100644 --- a/internal/kubernetes/nodefilters_test.go +++ b/internal/kubernetes/nodefilters_test.go @@ -234,6 +234,17 @@ func TestOldNodeLabelFilter(t *testing.T) { labels: map[string]string{"cool": "very"}, passesFilter: true, }, + { + name: "SingleMatchingLabel.WithDomain", + obj: &core.Node{ + ObjectMeta: meta.ObjectMeta{ + Name: nodeName, + Labels: map[string]string{"planetlabs.com/cool": "very"}, + }, + }, + labels: map[string]string{"planetlabs.com/cool": "very"}, + passesFilter: true, + }, { name: "ManyMatchingLabels", obj: &core.Node{ @@ -431,7 +442,7 @@ func TestConvertLabelsToFilterExpr(t *testing.T) { "sup": "cool", } - desired := "metadata.labels.foo == 'bar' && metadata.labels.sup == 'cool'" + desired := "metadata.labels['foo'] == 'bar' && metadata.labels['sup'] == 'cool'" actual := ConvertLabelsToFilterExpr(input) assert.Equal(t, desired, *actual)