From 9db40f0a4c876fe88a6eac9283aba9fdd15c86df Mon Sep 17 00:00:00 2001 From: Oded Ben Ozer Date: Tue, 2 Jul 2024 13:53:56 +0200 Subject: [PATCH] Explicitly set the NS --- internal/pkg/argocd/argocd.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/pkg/argocd/argocd.go b/internal/pkg/argocd/argocd.go index 07a3d3c..41f9566 100644 --- a/internal/pkg/argocd/argocd.go +++ b/internal/pkg/argocd/argocd.go @@ -23,6 +23,7 @@ import ( "github.com/argoproj/gitops-engine/pkg/sync/hook" "github.com/google/go-cmp/cmp" log "github.com/sirupsen/logrus" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" ) @@ -272,6 +273,9 @@ func SetArgoCDAppRevision(ctx context.Context, componentPath string, revision st } patchObject := argoappv1.Application{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: foundApp.Namespace, + }, Spec: argoappv1.ApplicationSpec{ Source: &argoappv1.ApplicationSource{ TargetRevision: revision, @@ -287,14 +291,14 @@ func SetArgoCDAppRevision(ctx context.Context, componentPath string, revision st log.Debugf("Patching app %s/%s with: %s", foundApp.Namespace, foundApp.Name, patch) patchType := "merge" - _, err = appClient.Patch(ctx, &application.ApplicationPatchRequest{ + patchedApp, err := appClient.Patch(ctx, &application.ApplicationPatchRequest{ Name: &foundApp.Name, AppNamespace: &foundApp.Namespace, PatchType: &patchType, Patch: &patch, }) if err != nil { - return fmt.Errorf("Error patching app %s revision to %s failed: %v\n, patch: %v", foundApp.Name, revision, err, patch) + return fmt.Errorf("Error patching app %s revision to %s failed: %v\n, patch: %v\npatched app: %v\n", foundApp.Name, revision, err, patch, patchedApp) } else { log.Infof("ArgoCD App %s revision set to %s", foundApp.Name, revision) }