diff --git a/src/pkg/cluster/namespace.go b/src/pkg/cluster/namespace.go index c65c968d0e..997247bfa9 100644 --- a/src/pkg/cluster/namespace.go +++ b/src/pkg/cluster/namespace.go @@ -67,5 +67,6 @@ func AdoptZarfManagedLabels(labels map[string]string) map[string]string { labels = make(map[string]string) } labels[ZarfManagedByLabel] = "zarf" + delete(labels, AgentLabel) return labels } diff --git a/src/pkg/cluster/namespace_test.go b/src/pkg/cluster/namespace_test.go new file mode 100644 index 0000000000..1fcc9fe8e9 --- /dev/null +++ b/src/pkg/cluster/namespace_test.go @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2021-Present The Zarf Authors + +package cluster + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestAdoptZarfManagedLabels(t *testing.T) { + t.Parallel() + + labels := map[string]string{ + "foo": "bar", + AgentLabel: "ignore", + } + adoptedLabels := AdoptZarfManagedLabels(labels) + expectedLabels := map[string]string{ + "foo": "bar", + ZarfManagedByLabel: "zarf", + } + require.Equal(t, expectedLabels, adoptedLabels) +}