-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add possibility to specify write-back GIT repository as annotation.
- Loading branch information
Showing
6 changed files
with
78 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,6 +144,22 @@ kubectl -n argocd-image-updater create secret generic git-creds \ | |
--from-file=sshPrivateKey=~/.ssh/id_rsa | ||
``` | ||
|
||
### <a name="method-git-repository"></a>Specifying a repository when using a Helm repository in repoURL | ||
|
||
By default, Argo CD Image Updater will use the value found in the Application | ||
spec at `.spec.source.repoURL` as Git repository to checkout. But when using | ||
a Helm repository as `.spec.source.repoURL` GIT will simply fail. To manually | ||
specify the repository to push the changes, specify the | ||
annotation `argocd-image-updater.argoproj.io/git-repository` on the Application | ||
manifest. | ||
|
||
The value of this annotation will define the Git repository to use, for example the | ||
following would use a GitHub's repository: | ||
|
||
```yaml | ||
argocd-image-updater.argoproj.io/git-repository: [email protected]:example/example.git | ||
``` | ||
|
||
### <a name="method-git-branch"></a>Specifying a branch to commit to | ||
|
||
By default, Argo CD Image Updater will use the value found in the Application | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1691,6 +1691,48 @@ func Test_GetGitCreds(t *testing.T) { | |
require.Error(t, err) | ||
require.Nil(t, creds) | ||
}) | ||
|
||
t.Run("SSH creds from Argo CD settings with Helm Chart repoURL", func(t *testing.T) { | ||
argoClient := argomock.ArgoCD{} | ||
argoClient.On("UpdateSpec", mock.Anything, mock.Anything).Return(nil, nil) | ||
secret := fixture.NewSecret("argocd-image-updater", "git-creds", map[string][]byte{ | ||
"sshPrivateKey": []byte("foo"), | ||
}) | ||
kubeClient := kube.KubernetesClient{ | ||
Clientset: fake.NewFakeClientsetWithResources(secret), | ||
} | ||
|
||
app := v1alpha1.Application{ | ||
ObjectMeta: v1.ObjectMeta{ | ||
Name: "testapp", | ||
Annotations: map[string]string{ | ||
"argocd-image-updater.argoproj.io/image-list": "nginx", | ||
"argocd-image-updater.argoproj.io/write-back-method": "git:secret:argocd-image-updater/git-creds", | ||
"argocd-image-updater.argoproj.io/git-repository": "[email protected]:example/example.git", | ||
}, | ||
}, | ||
Spec: v1alpha1.ApplicationSpec{ | ||
Source: v1alpha1.ApplicationSource{ | ||
RepoURL: "https://example-helm-repo.com/example", | ||
TargetRevision: "main", | ||
}, | ||
}, | ||
Status: v1alpha1.ApplicationStatus{ | ||
SourceType: v1alpha1.ApplicationSourceTypeKustomize, | ||
}, | ||
} | ||
|
||
wbc, err := getWriteBackConfig(&app, &kubeClient, &argoClient) | ||
require.NoError(t, err) | ||
require.Equal(t, wbc.GitRepo, "[email protected]:example/example.git") | ||
|
||
creds, err := wbc.GetCreds(&app) | ||
require.NoError(t, err) | ||
require.NotNil(t, creds) | ||
// Must have SSH creds | ||
_, ok := creds.(git.SSHCreds) | ||
require.True(t, ok) | ||
}) | ||
} | ||
|
||
func Test_CommitUpdates(t *testing.T) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters