From 8b6fd6ad99bb07dd1a1c718a0044ecb5b6ffe25b Mon Sep 17 00:00:00 2001 From: Alex Misstear Date: Tue, 23 Apr 2024 14:55:06 -0400 Subject: [PATCH] Initialize destination namespace labels This fixes the `Label destionation namespace - same as CTI` test and a possible bug scenario. Signed-off-by: Alex Misstear --- api/v1alpha1/clustertemplateinstance_utils.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/v1alpha1/clustertemplateinstance_utils.go b/api/v1alpha1/clustertemplateinstance_utils.go index 7f3d6dc..31a01bc 100644 --- a/api/v1alpha1/clustertemplateinstance_utils.go +++ b/api/v1alpha1/clustertemplateinstance_utils.go @@ -237,6 +237,9 @@ func (i *ClusterTemplateInstance) labelDestionationNamespace(ctx context.Context } if l, lOk := ns.Labels["argocd.argoproj.io/managed-by"]; !lOk || l != argoCDNamespace { + if ns.Labels == nil { + ns.Labels = map[string]string{} + } ns.Labels["argocd.argoproj.io/managed-by"] = argoCDNamespace if err := k8sClient.Update(ctx, ns); err != nil { return err