From 7c38c138d1b3f79cd9bd07932f73b5191eeb0d3d Mon Sep 17 00:00:00 2001 From: Austin Abro Date: Fri, 18 Oct 2024 19:34:23 +0000 Subject: [PATCH] ssa in zarf Signed-off-by: Austin Abro --- src/internal/packager/helm/post-render.go | 14 +++++++++++++- src/pkg/cluster/namespace.go | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/internal/packager/helm/post-render.go b/src/internal/packager/helm/post-render.go index 16f1b29810..d75b2fac24 100644 --- a/src/internal/packager/helm/post-render.go +++ b/src/internal/packager/helm/post-render.go @@ -7,6 +7,7 @@ package helm import ( "bytes" "context" + "encoding/json" "fmt" "os" "path/filepath" @@ -53,7 +54,18 @@ func (h *Helm) newRenderer(ctx context.Context) (*renderer, error) { if kerrors.IsNotFound(err) { rend.namespaces[h.chart.Namespace] = cluster.NewZarfManagedNamespace(h.chart.Namespace) } else if h.cfg.DeployOpts.AdoptExistingResources { - namespace.Labels[cluster.ZarfManagedByLabel] = "zarf" + // Need to make sure this path is tested + b, err := json.Marshal(namespace) + if err != nil { + return nil, err + } + nsAc := &v1ac.NamespaceApplyConfiguration{} + err = json.Unmarshal(b, nsAc) + if err != nil { + return nil, err + } + nsAc.WithLabels(cluster.AdoptZarfManagedLabels(nsAc.Labels)) + rend.namespaces[h.chart.Namespace] = nsAc } return rend, nil diff --git a/src/pkg/cluster/namespace.go b/src/pkg/cluster/namespace.go index 824cd0ffef..6f125f052b 100644 --- a/src/pkg/cluster/namespace.go +++ b/src/pkg/cluster/namespace.go @@ -12,9 +12,9 @@ import ( "github.com/avast/retry-go/v4" kerrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - v1ac "k8s.io/client-go/applyconfigurations/core/v1" "github.com/zarf-dev/zarf/src/pkg/message" + v1ac "k8s.io/client-go/applyconfigurations/core/v1" ) // DeleteZarfNamespace deletes the Zarf namespace from the connected cluster.