Skip to content

Commit

Permalink
Pass AppNamespace to UpdateSpec api call, to support applications in …
Browse files Browse the repository at this point in the history
…other namespaces than argocd itself (when using the argocd api).
  • Loading branch information
mwijngaard committed Mar 12, 2024
1 parent 7d93c7a commit 2a08935
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 3 additions & 2 deletions pkg/argocd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,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
Expand Down
12 changes: 9 additions & 3 deletions pkg/argocd/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -103,9 +104,6 @@ func Test_UpdateApplication(t *testing.T) {
return &regMock, nil
}

argoClient := argomock.ArgoCD{}
argoClient.On("UpdateSpec", mock.Anything, mock.Anything).Return(nil, nil)

kubeClient := kube.KubernetesClient{
Clientset: fake.NewFakeKubeClient(),
}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 2a08935

Please sign in to comment.