diff options
| author | noah <noah@hackedu.io> | 2021-05-11 20:17:38 +1200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-11 10:17:38 +0200 |
| commit | add387ecfa5c59b34119eabd8b81c1daddcdc06e (patch) | |
| tree | baa5d5c63641505ac16aa849316b85e1bf741190 /pkg/argocd/git_test.go | |
| parent | b47f7e961649acf4c9e7c98d575284a143707ce8 (diff) | |
feat: allow write-back to actual kustomization files (#200)
* feat: allow write-back to actual kustomization files #199
* fix: was not handling default path correctly
default is the source path
* fix: sort imports
Diffstat (limited to 'pkg/argocd/git_test.go')
| -rw-r--r-- | pkg/argocd/git_test.go | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/pkg/argocd/git_test.go b/pkg/argocd/git_test.go index 94cabe0..503c8e5 100644 --- a/pkg/argocd/git_test.go +++ b/pkg/argocd/git_test.go @@ -9,7 +9,9 @@ import ( "github.com/argoproj-labs/argocd-image-updater/pkg/image" "github.com/argoproj-labs/argocd-image-updater/pkg/tag" + "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1" "github.com/stretchr/testify/assert" + image2 "sigs.k8s.io/kustomize/pkg/image" ) func Test_TemplateCommitMessage(t *testing.T) { @@ -37,3 +39,50 @@ updates image bar/baz tag '2.0' to '2.1' assert.Equal(t, exp, r) }) } + +func Test_parseImageOverride(t *testing.T) { + cases := []struct { + name string + override v1alpha1.KustomizeImage + expected image2.Image + }{ + {"tag update", "ghcr.io:1234/foo/foo:123", image2.Image{ + Name: "ghcr.io:1234/foo/foo", + NewTag: "123", + }}, + {"image update", "ghcr.io:1234/foo/foo=ghcr.io:1234/bar", image2.Image{ + Name: "ghcr.io:1234/foo/foo", + NewName: "ghcr.io:1234/bar", + }}, + {"update everything", "ghcr.io:1234/foo/foo=1234.foo.com:9876/bar:123", image2.Image{ + Name: "ghcr.io:1234/foo/foo", + NewName: "1234.foo.com:9876/bar", + NewTag: "123", + }}, + {"change registry and tag", "ghcr.io:1234/foo/foo=1234.dkr.ecr.us-east-1.amazonaws.com/bar:123", image2.Image{ + Name: "ghcr.io:1234/foo/foo", + NewName: "1234.dkr.ecr.us-east-1.amazonaws.com/bar", + NewTag: "123", + }}, + {"change only registry", "0001.dkr.ecr.us-east-1.amazonaws.com/bar=1234.dkr.ecr.us-east-1.amazonaws.com/bar", image2.Image{ + Name: "0001.dkr.ecr.us-east-1.amazonaws.com/bar", + NewName: "1234.dkr.ecr.us-east-1.amazonaws.com/bar", + }}, + {"change image and set digest", "foo=acme/app@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", image2.Image{ + Name: "foo", + NewName: "acme/app", + Digest: "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + }}, + {"set digest", "acme/app@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", image2.Image{ + Name: "acme/app", + Digest: "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + }}, + } + + for _, tt := range cases { + t.Run(tt.name, func(t *testing.T) { + assert.Equal(t, tt.expected, parseImageOverride(tt.override)) + }) + } + +} |
