From 6219f365986d7152f0de78a3590c32d95957503c Mon Sep 17 00:00:00 2001 From: Merijn Wijngaard Date: Fri, 7 Jun 2024 22:09:59 +0200 Subject: [PATCH] fix: Pass AppNamespace to UpdateSpec api call (#687) Signed-off-by: Merijn Wijngaard --- pkg/argocd/update.go | 5 +++-- pkg/argocd/update_test.go | 12 +++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pkg/argocd/update.go b/pkg/argocd/update.go index 0f1cab28..d5afa498 100644 --- a/pkg/argocd/update.go +++ b/pkg/argocd/update.go @@ -619,8 +619,9 @@ func commitChanges(app *v1alpha1.Application, wbc *WriteBackConfig, changeList [ switch wbc.Method { case WriteBackApplication: _, err := wbc.ArgoClient.UpdateSpec(context.TODO(), &application.ApplicationUpdateSpecRequest{ - Name: &app.Name, - Spec: &app.Spec, + Name: &app.Name, + AppNamespace: &app.Namespace, + Spec: &app.Spec, }) if err != nil { return err diff --git a/pkg/argocd/update_test.go b/pkg/argocd/update_test.go index fd427b40..83aded3b 100644 --- a/pkg/argocd/update_test.go +++ b/pkg/argocd/update_test.go @@ -21,6 +21,7 @@ import ( "github.com/argoproj-labs/argocd-image-updater/test/fake" "github.com/argoproj-labs/argocd-image-updater/test/fixture" + "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" argogit "github.com/argoproj/argo-cd/v2/util/git" "github.com/distribution/distribution/v3/manifest/schema1" //nolint:staticcheck @@ -103,9 +104,6 @@ func Test_UpdateApplication(t *testing.T) { return ®Mock, nil } - argoClient := argomock.ArgoCD{} - argoClient.On("UpdateSpec", mock.Anything, mock.Anything).Return(nil, nil) - kubeClient := kube.KubernetesClient{ Clientset: fake.NewFakeKubeClient(), } @@ -137,6 +135,14 @@ func Test_UpdateApplication(t *testing.T) { image.NewFromIdentifier("jannfis/foobar:~1.0.0"), }, } + + argoClient := argomock.ArgoCD{} + argoClient.On("UpdateSpec", mock.Anything, &application.ApplicationUpdateSpecRequest{ + Name: &appImages.Application.Name, + AppNamespace: &appImages.Application.Namespace, + Spec: &appImages.Application.Spec, + }).Return(nil, nil) + res := UpdateApplication(&UpdateConfiguration{ NewRegFN: mockClientFn, ArgoClient: &argoClient,