From 7288cf2b6c40570d84128fd4ec6673a3277aedee Mon Sep 17 00:00:00 2001 From: Philip Laine Date: Mon, 8 Jul 2024 18:05:47 +0200 Subject: [PATCH] fix: remove ignore label when adopting resource (#2699) --- src/pkg/cluster/namespace.go | 1 + src/pkg/cluster/namespace_test.go | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/pkg/cluster/namespace_test.go 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) +}