diff --git a/ext/git/writer.go b/ext/git/writer.go index d2d2f75b..f286f51c 100644 --- a/ext/git/writer.go +++ b/ext/git/writer.go @@ -61,7 +61,7 @@ func (m *nativeGitClient) Commit(pathSpec string, opts *CommitOptions) error { out, err := m.runCmd(args...) if err != nil { - log.Errorf(out) + log.Errorf("%s %v", out, err) return err } diff --git a/pkg/argocd/argocd.go b/pkg/argocd/argocd.go index 7ad80686..4596f509 100644 --- a/pkg/argocd/argocd.go +++ b/pkg/argocd/argocd.go @@ -465,10 +465,22 @@ func GetImagesAndAliasesFromApplication(app *v1alpha1.Application) image.Contain // We update the ImageAlias field of the Images found in the app.Status.Summary.Images list. for _, img := range *parseImageList(app.Annotations) { if image := images.ContainsImage(img, false); image != nil { - if img.ImageAlias == "" { - image.ImageAlias = img.ImageName + if image.ImageAlias != "" { + // this image has already been matched to an alias, so create a copy + // and assign this alias to the image copy to avoid overwriting the existing alias association + imageCopy := *image + if img.ImageAlias == "" { + imageCopy.ImageAlias = img.ImageName + } else { + imageCopy.ImageAlias = img.ImageAlias + } + images = append(images, &imageCopy) } else { - image.ImageAlias = img.ImageAlias + if img.ImageAlias == "" { + image.ImageAlias = img.ImageName + } else { + image.ImageAlias = img.ImageAlias + } } } } diff --git a/pkg/argocd/update.go b/pkg/argocd/update.go index 6bff79c5..85204103 100644 --- a/pkg/argocd/update.go +++ b/pkg/argocd/update.go @@ -465,11 +465,11 @@ func marshalParamsOverride(app *v1alpha1.Application, originalData []byte) ([]by return nil, fmt.Errorf("%s parameter not found", helmAnnotationParamVersion) } - err = setHelmValue(helmNewValues, helmAnnotationParamName, helmParamName.Value) + err = setHelmValue(&helmNewValues, helmAnnotationParamName, helmParamName.Value) if err != nil { return nil, fmt.Errorf("failed to set image parameter name value: %v", err) } - err = setHelmValue(helmNewValues, helmAnnotationParamVersion, helmParamVersion.Value) + err = setHelmValue(&helmNewValues, helmAnnotationParamVersion, helmParamVersion.Value) if err != nil { return nil, fmt.Errorf("failed to set image parameter version value: %v", err) } @@ -542,34 +542,53 @@ func findHelmValuesKey(m yaml.MapSlice, key string) (int, bool) { } // set value of the parameter passed from the annotations. -func setHelmValue(m yaml.MapSlice, key string, value interface{}) error { +func setHelmValue(currentValues *yaml.MapSlice, key string, value interface{}) error { // Check if the full key exists - if idx, found := findHelmValuesKey(m, key); found { - m[idx].Value = value + if idx, found := findHelmValuesKey(*currentValues, key); found { + (*currentValues)[idx].Value = value return nil } var err error keys := strings.Split(key, ".") - current := m + current := currentValues + var parent *yaml.MapSlice + var parentIdx int for i, k := range keys { - if idx, found := findHelmValuesKey(current, k); found { + if idx, found := findHelmValuesKey(*current, k); found { if i == len(keys)-1 { // If we're at the final key, set the value and return - current[idx].Value = value + (*current)[idx].Value = value return nil } else { // Navigate deeper into the map - if nestedMap, ok := current[idx].Value.(yaml.MapSlice); ok { - current = nestedMap + if nestedMap, ok := (*current)[idx].Value.(yaml.MapSlice); ok { + parent = current + parentIdx = idx + current = &nestedMap } else { - return fmt.Errorf("unexpected type %T for key %s", current[idx].Value, k) + return fmt.Errorf("unexpected type %T for key %s", (*current)[idx].Value, k) } } } else { - err = fmt.Errorf("key %s not found in the map", k) - break + newCurrent := yaml.MapSlice{} + var newParent yaml.MapSlice + + if i == len(keys)-1 { + newParent = append(*current, yaml.MapItem{Key: k, Value: value}) + } else { + newParent = append(*current, yaml.MapItem{Key: k, Value: newCurrent}) + } + + if parent == nil { + *currentValues = newParent + } else { + (*parent)[parentIdx].Value = newParent + } + + parent = &newParent + current = &newCurrent } } diff --git a/pkg/argocd/update_test.go b/pkg/argocd/update_test.go index 4d989e83..bd67d3b6 100644 --- a/pkg/argocd/update_test.go +++ b/pkg/argocd/update_test.go @@ -1471,7 +1471,117 @@ replicas: 1 assert.Equal(t, strings.TrimSpace(strings.ReplaceAll(expected, "\t", " ")), strings.TrimSpace(string(yaml))) }) + t.Run("Valid Helm source with Helm values file with multiple aliases", func(t *testing.T) { + expected := ` +foo.image.name: nginx +foo.image.tag: v1.0.0 +bar.image.name: nginx +bar.image.tag: v1.0.0 +bbb.image.name: nginx +bbb.image.tag: v1.0.0 +replicas: 1 +` + app := v1alpha1.Application{ + ObjectMeta: v1.ObjectMeta{ + Name: "testapp", + Annotations: map[string]string{ + "argocd-image-updater.argoproj.io/image-list": "foo=nginx, bar=nginx, bbb=nginx", + "argocd-image-updater.argoproj.io/write-back-method": "git", + "argocd-image-updater.argoproj.io/write-back-target": "helmvalues:./test-values.yaml", + "argocd-image-updater.argoproj.io/foo.helm.image-name": "foo.image.name", + "argocd-image-updater.argoproj.io/foo.helm.image-tag": "foo.image.tag", + "argocd-image-updater.argoproj.io/bar.helm.image-name": "bar.image.name", + "argocd-image-updater.argoproj.io/bar.helm.image-tag": "bar.image.tag", + "argocd-image-updater.argoproj.io/bbb.helm.image-name": "bbb.image.name", + "argocd-image-updater.argoproj.io/bbb.helm.image-tag": "bbb.image.tag", + }, + }, + Spec: v1alpha1.ApplicationSpec{ + Sources: []v1alpha1.ApplicationSource{ + { + Chart: "my-app", + Helm: &v1alpha1.ApplicationSourceHelm{ + ReleaseName: "my-app", + ValueFiles: []string{"$values/some/dir/values.yaml"}, + Parameters: []v1alpha1.HelmParameter{ + { + Name: "foo.image.name", + Value: "nginx", + ForceString: true, + }, + { + Name: "foo.image.tag", + Value: "v1.0.0", + ForceString: true, + }, + { + Name: "bar.image.name", + Value: "nginx", + ForceString: true, + }, + { + Name: "bar.image.tag", + Value: "v1.0.0", + ForceString: true, + }, + { + Name: "bbb.image.name", + Value: "nginx", + ForceString: true, + }, + { + Name: "bbb.image.tag", + Value: "v1.0.0", + ForceString: true, + }, + }, + }, + RepoURL: "https://example.com/example", + TargetRevision: "main", + }, + { + Ref: "values", + RepoURL: "https://example.com/example2", + TargetRevision: "main", + }, + }, + }, + Status: v1alpha1.ApplicationStatus{ + SourceTypes: []v1alpha1.ApplicationSourceType{ + v1alpha1.ApplicationSourceTypeHelm, + "", + }, + Summary: v1alpha1.ApplicationSummary{ + Images: []string{ + "nginx:v0.0.0", + }, + }, + }, + } + + originalData := []byte(` +foo.image.name: nginx +foo.image.tag: v0.0.0 +bar.image.name: nginx +bar.image.tag: v0.0.0 +bbb.image.name: nginx +bbb.image.tag: v0.0.0 +replicas: 1 +`) + yaml, err := marshalParamsOverride(&app, originalData) + require.NoError(t, err) + assert.NotEmpty(t, yaml) + assert.Equal(t, strings.TrimSpace(strings.ReplaceAll(expected, "\t", " ")), strings.TrimSpace(string(yaml))) + }) + t.Run("Failed to setValue image parameter name", func(t *testing.T) { + expected := ` +image: + name: nginx + tag: v1.0.0 +replicas: 1 +` + app := v1alpha1.Application{ ObjectMeta: v1.ObjectMeta{ Name: "testapp", @@ -1514,16 +1624,24 @@ replicas: 1 } originalData := []byte(` -image_name: nginx -image.tag: v0.0.0 +image: + name: nginx replicas: 1 `) - _, err := marshalParamsOverride(&app, originalData) - assert.Error(t, err) - assert.Equal(t, "failed to set image parameter name value: key image not found in the map", err.Error()) + + yaml, err := marshalParamsOverride(&app, originalData) + require.NoError(t, err) + assert.NotEmpty(t, yaml) + assert.Equal(t, strings.TrimSpace(strings.ReplaceAll(expected, "\t", " ")), strings.TrimSpace(string(yaml))) }) t.Run("Failed to setValue image parameter version", func(t *testing.T) { + expected := ` +image: + tag: v1.0.0 + name: nginx +replicas: 1 +` app := v1alpha1.Application{ ObjectMeta: v1.ObjectMeta{ Name: "testapp", @@ -1566,13 +1684,15 @@ replicas: 1 } originalData := []byte(` -image.name: nginx -image_tag: v0.0.0 +image: + tag: v0.0.0 replicas: 1 `) - _, err := marshalParamsOverride(&app, originalData) - assert.Error(t, err) - assert.Equal(t, "failed to set image parameter version value: key image not found in the map", err.Error()) + + yaml, err := marshalParamsOverride(&app, originalData) + require.NoError(t, err) + assert.NotEmpty(t, yaml) + assert.Equal(t, strings.TrimSpace(strings.ReplaceAll(expected, "\t", " ")), strings.TrimSpace(string(yaml))) }) t.Run("Missing annotation image-tag for helmvalues write-back-target", func(t *testing.T) { @@ -1865,7 +1985,7 @@ func Test_SetHelmValue(t *testing.T) { key := "image.attributes.tag" value := "v2.0.0" - err := setHelmValue(input, key, value) + err := setHelmValue(&input, key, value) require.NoError(t, err) assert.Equal(t, expected, input) }) @@ -1881,23 +2001,72 @@ func Test_SetHelmValue(t *testing.T) { key := "image.attributes.tag" value := "v2.0.0" - err := setHelmValue(input, key, value) + err := setHelmValue(&input, key, value) require.NoError(t, err) assert.Equal(t, expected, input) }) t.Run("Key not found", func(t *testing.T) { + expected := yaml.MapSlice{ + {Key: "image", Value: yaml.MapSlice{ + {Key: "attributes", Value: yaml.MapSlice{ + {Key: "name", Value: "repo-name"}, + {Key: "tag", Value: "v2.0.0"}, + }}, + }}, + } + input := yaml.MapSlice{ {Key: "image", Value: yaml.MapSlice{ - {Key: "tag", Value: "v1.0.0"}, + {Key: "attributes", Value: yaml.MapSlice{ + {Key: "name", Value: "repo-name"}, + }}, }}, } + key := "image.attributes.tag" value := "v2.0.0" - err := setHelmValue(input, key, value) - assert.Error(t, err) - assert.Equal(t, "key attributes not found in the map", err.Error()) + err := setHelmValue(&input, key, value) + require.NoError(t, err) + assert.Equal(t, expected, input) + }) + + t.Run("Root key not found", func(t *testing.T) { + expected := yaml.MapSlice{ + {Key: "name", Value: "repo-name"}, + {Key: "tag", Value: "v2.0.0"}, + } + + input := yaml.MapSlice{ + {Key: "name", Value: "repo-name"}, + } + + key := "tag" + value := "v2.0.0" + + err := setHelmValue(&input, key, value) + require.NoError(t, err) + assert.Equal(t, expected, input) + }) + + t.Run("Empty values with deep key", func(t *testing.T) { + expected := yaml.MapSlice{ + {Key: "image", Value: yaml.MapSlice{ + {Key: "attributes", Value: yaml.MapSlice{ + {Key: "tag", Value: "v2.0.0"}, + }}, + }}, + } + + input := yaml.MapSlice{} + + key := "image.attributes.tag" + value := "v2.0.0" + + err := setHelmValue(&input, key, value) + require.NoError(t, err) + assert.Equal(t, expected, input) }) t.Run("Unexpected type for key", func(t *testing.T) { @@ -1909,7 +2078,7 @@ func Test_SetHelmValue(t *testing.T) { key := "image.attributes.tag" value := "v2.0.0" - err := setHelmValue(input, key, value) + err := setHelmValue(&input, key, value) assert.Error(t, err) assert.Equal(t, "unexpected type string for key attributes", err.Error()) }) diff --git a/pkg/log/log.go b/pkg/log/log.go index 1f746340..85be5d40 100644 --- a/pkg/log/log.go +++ b/pkg/log/log.go @@ -70,7 +70,7 @@ func (logctx *LogContext) AddField(key string, value interface{}) *LogContext { return logctx } -// Logger retrieves the native logger interface. Use with care. +// Log retrieves the native logger interface. Use with care. func Log() *logrus.Logger { return logger } @@ -78,7 +78,7 @@ func Log() *logrus.Logger { // Tracef logs a debug message for logctx to stdout func (logctx *LogContext) Tracef(format string, args ...interface{}) { logger.SetOutput(logctx.normalOut) - if logctx.fields != nil && len(logctx.fields) > 0 { + if len(logctx.fields) > 0 { logger.WithFields(logctx.fields).Tracef(format, args...) } else { logger.Tracef(format, args...) @@ -88,7 +88,7 @@ func (logctx *LogContext) Tracef(format string, args ...interface{}) { // Debugf logs a debug message for logctx to stdout func (logctx *LogContext) Debugf(format string, args ...interface{}) { logger.SetOutput(logctx.normalOut) - if logctx.fields != nil && len(logctx.fields) > 0 { + if len(logctx.fields) > 0 { logger.WithFields(logctx.fields).Debugf(format, args...) } else { logger.Debugf(format, args...) @@ -98,7 +98,7 @@ func (logctx *LogContext) Debugf(format string, args ...interface{}) { // Infof logs an informational message for logctx to stdout func (logctx *LogContext) Infof(format string, args ...interface{}) { logger.SetOutput(logctx.normalOut) - if logctx.fields != nil && len(logctx.fields) > 0 { + if len(logctx.fields) > 0 { logger.WithFields(logctx.fields).Infof(format, args...) } else { logger.Infof(format, args...) @@ -108,7 +108,7 @@ func (logctx *LogContext) Infof(format string, args ...interface{}) { // Warnf logs a warning message for logctx to stdout func (logctx *LogContext) Warnf(format string, args ...interface{}) { logger.SetOutput(logctx.normalOut) - if logctx.fields != nil && len(logctx.fields) > 0 { + if len(logctx.fields) > 0 { logger.WithFields(logctx.fields).Warnf(format, args...) } else { logger.Warnf(format, args...) @@ -118,7 +118,7 @@ func (logctx *LogContext) Warnf(format string, args ...interface{}) { // Errorf logs a non-fatal error message for logctx to stdout func (logctx *LogContext) Errorf(format string, args ...interface{}) { logger.SetOutput(logctx.errorOut) - if logctx.fields != nil && len(logctx.fields) > 0 { + if len(logctx.fields) > 0 { logger.WithFields(logctx.fields).Errorf(format, args...) } else { logger.Errorf(format, args...) @@ -128,14 +128,14 @@ func (logctx *LogContext) Errorf(format string, args ...interface{}) { // Fatalf logs a fatal error message for logctx to stdout func (logctx *LogContext) Fatalf(format string, args ...interface{}) { logger.SetOutput(logctx.errorOut) - if logctx.fields != nil && len(logctx.fields) > 0 { + if len(logctx.fields) > 0 { logger.WithFields(logctx.fields).Fatalf(format, args...) } else { logger.Fatalf(format, args...) } } -// Debugf logs a warning message without context to stdout +// Tracef logs a warning message without context to stdout func Tracef(format string, args ...interface{}) { logCtx := NewContext() logCtx.Tracef(format, args...) diff --git a/test/e2e/suite/101-kustomize-match-application-label/01-assert.yaml b/test/e2e/suite/101-kustomize-match-application-label/01-assert.yaml new file mode 100644 index 00000000..1e390400 --- /dev/null +++ b/test/e2e/suite/101-kustomize-match-application-label/01-assert.yaml @@ -0,0 +1,29 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: image-updater-101-0 +status: + health: + status: Healthy + sync: + status: Synced +--- +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: image-updater-101-1 +status: + health: + status: Healthy + sync: + status: Synced +--- +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: image-updater-101-2 +status: + health: + status: Healthy + sync: + status: Synced \ No newline at end of file diff --git a/test/e2e/suite/101-kustomize-match-application-label/01-install.yaml b/test/e2e/suite/101-kustomize-match-application-label/01-install.yaml new file mode 100644 index 00000000..a87611c1 --- /dev/null +++ b/test/e2e/suite/101-kustomize-match-application-label/01-install.yaml @@ -0,0 +1,87 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: image-updater-e2e-101-0 +--- +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: image-updater-101-0 + labels: + app.index: "0" + annotations: + argocd-image-updater.argoproj.io/image-list: guestbook=gcr.io/heptio-images/ks-guestbook-demo:~0 + argocd-image-updater.argoproj.io/test.update-strategy: semver + finalizers: + - resources-finalizer.argocd.argoproj.io +spec: + project: default + source: + repoURL: https://github.com/argoproj/argocd-example-apps.git + path: kustomize-guestbook + targetRevision: HEAD + destination: + server: https://kubernetes.default.svc + namespace: image-updater-e2e-101-0 + syncPolicy: + automated: {} + retry: + limit: 2 +--- +apiVersion: v1 +kind: Namespace +metadata: + name: image-updater-e2e-101-1 +--- +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: image-updater-101-1 + labels: + app.index: "1" + annotations: + argocd-image-updater.argoproj.io/image-list: guestbook=gcr.io/heptio-images/ks-guestbook-demo:~0 + argocd-image-updater.argoproj.io/test.update-strategy: semver + finalizers: + - resources-finalizer.argocd.argoproj.io +spec: + project: default + source: + repoURL: https://github.com/argoproj/argocd-example-apps.git + path: kustomize-guestbook + targetRevision: HEAD + destination: + server: https://kubernetes.default.svc + namespace: image-updater-e2e-101-1 + syncPolicy: + automated: {} + retry: + limit: 2 +--- +apiVersion: v1 +kind: Namespace +metadata: + name: image-updater-e2e-101-2 +--- +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: image-updater-101-2 + annotations: + argocd-image-updater.argoproj.io/image-list: guestbook=gcr.io/heptio-images/ks-guestbook-demo:~0 + argocd-image-updater.argoproj.io/test.update-strategy: semver + finalizers: + - resources-finalizer.argocd.argoproj.io +spec: + project: default + source: + repoURL: https://github.com/argoproj/argocd-example-apps.git + path: kustomize-guestbook + targetRevision: HEAD + destination: + server: https://kubernetes.default.svc + namespace: image-updater-e2e-101-2 + syncPolicy: + automated: {} + retry: + limit: 2 \ No newline at end of file diff --git a/test/e2e/suite/101-kustomize-match-application-label/02-assert.yaml b/test/e2e/suite/101-kustomize-match-application-label/02-assert.yaml new file mode 100644 index 00000000..9104f091 --- /dev/null +++ b/test/e2e/suite/101-kustomize-match-application-label/02-assert.yaml @@ -0,0 +1,34 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: image-updater-101-0 +spec: + source: + kustomize: + images: + - gcr.io/heptio-images/ks-guestbook-demo:0.2 +status: + health: + status: Healthy + sync: + status: Synced +--- +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: image-updater-101-1 +status: + health: + status: Healthy + sync: + status: Synced +--- +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: image-updater-101-2 +status: + health: + status: Healthy + sync: + status: Synced diff --git a/test/e2e/suite/101-kustomize-match-application-label/02-run-updater.yaml b/test/e2e/suite/101-kustomize-match-application-label/02-run-updater.yaml new file mode 100644 index 00000000..429943a3 --- /dev/null +++ b/test/e2e/suite/101-kustomize-match-application-label/02-run-updater.yaml @@ -0,0 +1,8 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: +- script: | + ${SRC_DIR}/dist/argocd-image-updater run --once \ + --argocd-namespace argocd-image-updater-e2e \ + --match-application-label app.index=0 \ + --loglevel trace \ No newline at end of file diff --git a/test/e2e/suite/101-kustomize-match-application-label/99-delete.yaml b/test/e2e/suite/101-kustomize-match-application-label/99-delete.yaml new file mode 100644 index 00000000..526b0c0c --- /dev/null +++ b/test/e2e/suite/101-kustomize-match-application-label/99-delete.yaml @@ -0,0 +1,22 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +timeout: 120 +delete: +- apiVersion: argoproj.io/v1alpha1 + kind: Application + name: image-updater-101-0 +- apiVersion: v1 + kind: Namespace + name: image-updater-e2e-101-0 +- apiVersion: argoproj.io/v1alpha1 + kind: Application + name: image-updater-101-1 +- apiVersion: v1 + kind: Namespace + name: image-updater-e2e-101-1 +- apiVersion: argoproj.io/v1alpha1 + kind: Application + name: image-updater-101-2 +- apiVersion: v1 + kind: Namespace + name: image-updater-e2e-101-2 \ No newline at end of file diff --git a/test/e2e/suite/101-kustomize-match-application-label/README.md b/test/e2e/suite/101-kustomize-match-application-label/README.md new file mode 100644 index 00000000..a64223fc --- /dev/null +++ b/test/e2e/suite/101-kustomize-match-application-label/README.md @@ -0,0 +1,117 @@ +This test case verifies [filtering applications by labels](https://argocd-image-updater.readthedocs.io/en/stable/install/reference/#flags) with `--match-application-label` command line options + +This test case uses image from public container registry and application source from public GitHub repo. + +To run this individual test case, + +* make sure both docker daemon and k8s cluster is running +* `cd $HOME/go/src/image-updater/test/e2e` +* `SRC_DIR=$HOME/go/src/image-updater kubectl kuttl test --namespace argocd-image-updater-e2e --timeout 120 --test 101-kustomize-match-application-label` + +Test output: +```bash +=== RUN kuttl + harness.go:464: starting setup + harness.go:255: running tests using configured kubeconfig. + harness.go:278: Successful connection to cluster at: https://0.0.0.0:55975 + harness.go:363: running tests + harness.go:75: going to run test suite with timeout of 120 seconds for each step + harness.go:375: testsuite: ./suite has 5 tests +=== RUN kuttl/harness +=== RUN kuttl/harness/101-kustomize-match-application-label +=== PAUSE kuttl/harness/101-kustomize-match-application-label +=== CONT kuttl/harness/101-kustomize-match-application-label + logger.go:42: 11:56:07 | 101-kustomize-match-application-label | Ignoring README.md as it does not match file name regexp: ^(\d+)-(?:[^\.]+)(?:\.yaml)?$ + logger.go:42: 11:56:07 | 101-kustomize-match-application-label | Skipping creation of user-supplied namespace: argocd-image-updater-e2e + logger.go:42: 11:56:07 | 101-kustomize-match-application-label/1-install | starting test step 1-install + logger.go:42: 11:56:07 | 101-kustomize-match-application-label/1-install | Namespace:/image-updater-e2e-101-0 created + logger.go:42: 11:56:07 | 101-kustomize-match-application-label/1-install | Application:argocd-image-updater-e2e/image-updater-101-0 created + logger.go:42: 11:56:07 | 101-kustomize-match-application-label/1-install | Namespace:/image-updater-e2e-101-1 created + logger.go:42: 11:56:07 | 101-kustomize-match-application-label/1-install | Application:argocd-image-updater-e2e/image-updater-101-1 created + logger.go:42: 11:56:07 | 101-kustomize-match-application-label/1-install | Namespace:/image-updater-e2e-101-2 created + logger.go:42: 11:56:07 | 101-kustomize-match-application-label/1-install | Application:argocd-image-updater-e2e/image-updater-101-2 created + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/1-install | test step completed 1-install + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | starting test step 2-run-updater + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | running command: [sh -c ${SRC_DIR}/dist/argocd-image-updater run --once \ + --argocd-namespace argocd-image-updater-e2e \ + --match-application-label app.index=0 \ + --loglevel trace + ] + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=info msg="argocd-image-updater v99.9.9+2bf4b0a starting [loglevel:TRACE, interval:once, healthport:off]" + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=warning msg="commit message template at /app/config/commit.template does not exist, using default" + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=debug msg="Successfully parsed commit message template" + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=warning msg="Registry configuration at /app/config/registries.conf could not be read: stat /app/config/registries.conf: no such file or directory -- using default configuration" + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=debug msg="Creating in-cluster Kubernetes client" + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=info msg="ArgoCD configuration: [apiKind=kubernetes, server=argocd-server.argocd-image-updater-e2e, auth_token=false, insecure=false, grpc_web=false, plaintext=false]" + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=info msg="Starting metrics server on TCP port=8081" + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=info msg="Warming up image cache" + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=trace msg="Matching application name image-updater-101-0 against label app.index=0" + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=trace msg="processing app 'argocd-image-updater-e2e/image-updater-101-0' of type 'Kustomize'" application=image-updater-101-0 namespace=argocd-image-updater-e2e + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=trace msg="Matching application name image-updater-101-1 against label app.index=0" + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=debug msg="Skipping app 'argocd-image-updater-e2e/image-updater-101-1' because it does not carry requested label" application=image-updater-101-1 namespace=argocd-image-updater-e2e + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=trace msg="Matching application name image-updater-101-2 against label app.index=0" + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=debug msg="Skipping app 'argocd-image-updater-e2e/image-updater-101-2' because it does not carry requested label" application=image-updater-101-2 namespace=argocd-image-updater-e2e + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=debug msg="Processing application argocd-image-updater-e2e/image-updater-101-0" + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=debug msg="Considering this image for update" alias=guestbook application=image-updater-101-0 image_name=heptio-images/ks-guestbook-demo image_tag=0.1 registry=gcr.io + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=debug msg="setting rate limit to 20 requests per second" prefix=gcr.io registry="https://gcr.io" + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=debug msg="Inferred registry from prefix gcr.io to use API https://gcr.io" + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=debug msg="Using version constraint '~0' when looking for a new tag" alias=guestbook application=image-updater-101-0 image_name=heptio-images/ks-guestbook-demo image_tag=0.1 registry=gcr.io + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=trace msg="No sort option found" image_alias=guestbook image_digest= image_name=gcr.io/heptio-images/ks-guestbook-demo image_tag="~0" registry_url=gcr.io + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=trace msg="No match annotation found" image_alias=guestbook image_digest= image_name=gcr.io/heptio-images/ks-guestbook-demo image_tag="~0" registry_url=gcr.io + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=trace msg="No ignore-tags annotation found" image_alias=guestbook image_digest= image_name=gcr.io/heptio-images/ks-guestbook-demo image_tag="~0" registry_url=gcr.io + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=trace msg="Using runtime platform constraint darwin/arm64" image_alias=guestbook image_digest= image_name=gcr.io/heptio-images/ks-guestbook-demo image_tag="~0" registry_url=gcr.io + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=trace msg="No pull-secret annotation found" image_alias=guestbook image_digest= image_name=gcr.io/heptio-images/ks-guestbook-demo image_tag="~0" registry_url=gcr.io + logger.go:42: 11:56:11 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:11-04:00" level=trace msg="Performing HTTP GET https://gcr.io/v2/heptio-images/ks-guestbook-demo/tags/list" + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=trace msg="List of available tags found: [0.1 0.2]" alias=guestbook application=image-updater-101-0 image_name=heptio-images/ks-guestbook-demo image_tag=0.1 registry=gcr.io + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=trace msg="Finding out whether to consider 0.1 for being updateable" image="gcr.io/heptio-images/ks-guestbook-demo:0.1" + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=trace msg="Finding out whether to consider 0.2 for being updateable" image="gcr.io/heptio-images/ks-guestbook-demo:0.1" + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=debug msg="found 2 from 2 tags eligible for consideration" image="gcr.io/heptio-images/ks-guestbook-demo:0.1" + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=info msg="Setting new image to gcr.io/heptio-images/ks-guestbook-demo:0.2" alias=guestbook application=image-updater-101-0 image_name=heptio-images/ks-guestbook-demo image_tag=0.1 registry=gcr.io + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=trace msg="Setting Kustomize parameter gcr.io/heptio-images/ks-guestbook-demo:0.2" application=image-updater-101-0 + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=info msg="Successfully updated image 'gcr.io/heptio-images/ks-guestbook-demo:0.1' to 'gcr.io/heptio-images/ks-guestbook-demo:0.2', but pending spec update (dry run=true)" alias=guestbook application=image-updater-101-0 image_name=heptio-images/ks-guestbook-demo image_tag=0.1 registry=gcr.io + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=debug msg="Using commit message: " + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=info msg="Dry run - not committing 1 changes to application" application=image-updater-101-0 + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=info msg="Finished cache warm-up, pre-loaded 0 meta data entries from 2 registries" + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=debug msg="Starting askpass server" + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=trace msg="Matching application name image-updater-101-0 against label app.index=0" + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=trace msg="processing app 'argocd-image-updater-e2e/image-updater-101-0' of type 'Kustomize'" application=image-updater-101-0 namespace=argocd-image-updater-e2e + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=trace msg="Matching application name image-updater-101-1 against label app.index=0" + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=debug msg="Skipping app 'argocd-image-updater-e2e/image-updater-101-1' because it does not carry requested label" application=image-updater-101-1 namespace=argocd-image-updater-e2e + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=trace msg="Matching application name image-updater-101-2 against label app.index=0" + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=debug msg="Skipping app 'argocd-image-updater-e2e/image-updater-101-2' because it does not carry requested label" application=image-updater-101-2 namespace=argocd-image-updater-e2e + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=info msg="Starting image update cycle, considering 1 annotated application(s) for update" + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=debug msg="Processing application argocd-image-updater-e2e/image-updater-101-0" + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=debug msg="Considering this image for update" alias=guestbook application=image-updater-101-0 image_name=heptio-images/ks-guestbook-demo image_tag=0.1 registry=gcr.io + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=debug msg="Using version constraint '~0' when looking for a new tag" alias=guestbook application=image-updater-101-0 image_name=heptio-images/ks-guestbook-demo image_tag=0.1 registry=gcr.io + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=trace msg="No sort option found" image_alias=guestbook image_digest= image_name=gcr.io/heptio-images/ks-guestbook-demo image_tag="~0" registry_url=gcr.io + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=trace msg="No match annotation found" image_alias=guestbook image_digest= image_name=gcr.io/heptio-images/ks-guestbook-demo image_tag="~0" registry_url=gcr.io + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=trace msg="No ignore-tags annotation found" image_alias=guestbook image_digest= image_name=gcr.io/heptio-images/ks-guestbook-demo image_tag="~0" registry_url=gcr.io + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=trace msg="Using runtime platform constraint darwin/arm64" image_alias=guestbook image_digest= image_name=gcr.io/heptio-images/ks-guestbook-demo image_tag="~0" registry_url=gcr.io + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=trace msg="No pull-secret annotation found" image_alias=guestbook image_digest= image_name=gcr.io/heptio-images/ks-guestbook-demo image_tag="~0" registry_url=gcr.io + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=trace msg="Performing HTTP GET https://gcr.io/v2/heptio-images/ks-guestbook-demo/tags/list" + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=trace msg="List of available tags found: [0.1 0.2]" alias=guestbook application=image-updater-101-0 image_name=heptio-images/ks-guestbook-demo image_tag=0.1 registry=gcr.io + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=trace msg="Finding out whether to consider 0.1 for being updateable" image="gcr.io/heptio-images/ks-guestbook-demo:0.1" + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=trace msg="Finding out whether to consider 0.2 for being updateable" image="gcr.io/heptio-images/ks-guestbook-demo:0.1" + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=debug msg="found 2 from 2 tags eligible for consideration" image="gcr.io/heptio-images/ks-guestbook-demo:0.1" + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=info msg="Setting new image to gcr.io/heptio-images/ks-guestbook-demo:0.2" alias=guestbook application=image-updater-101-0 image_name=heptio-images/ks-guestbook-demo image_tag=0.1 registry=gcr.io + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=trace msg="Setting Kustomize parameter gcr.io/heptio-images/ks-guestbook-demo:0.2" application=image-updater-101-0 + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=info msg="Successfully updated image 'gcr.io/heptio-images/ks-guestbook-demo:0.1' to 'gcr.io/heptio-images/ks-guestbook-demo:0.2', but pending spec update (dry run=false)" alias=guestbook application=image-updater-101-0 image_name=heptio-images/ks-guestbook-demo image_tag=0.1 registry=gcr.io + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=debug msg="Using commit message: " + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=info msg="Committing 1 parameter update(s) for application image-updater-101-0" application=image-updater-101-0 + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | W0820 11:56:12.643735 31180 warnings.go:70] unknown field "status.history[0].initiatedBy" + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=info msg="Successfully updated the live application spec" application=image-updater-101-0 + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=info msg="Processing results: applications=1 images_considered=1 images_skipped=0 images_updated=1 errors=0" + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | time="2024-08-20T11:56:12-04:00" level=info msg=Finished. + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/2-run-updater | test step completed 2-run-updater + logger.go:42: 11:56:12 | 101-kustomize-match-application-label/99-delete | starting test step 99-delete + logger.go:42: 11:56:55 | 101-kustomize-match-application-label/99-delete | test step completed 99-delete + logger.go:42: 11:56:55 | 101-kustomize-match-application-label | skipping kubernetes event logging +=== NAME kuttl + harness.go:407: run tests finished + harness.go:515: cleaning up + harness.go:572: removing temp folder: "" +--- PASS: kuttl (47.84s) + --- PASS: kuttl/harness (0.00s) + --- PASS: kuttl/harness/101-kustomize-match-application-label (47.84s) +PASS +``` \ No newline at end of file diff --git a/test/e2e/suite/102-kustomize-match-application-name/01-install.yaml b/test/e2e/suite/102-kustomize-match-application-name/01-install.yaml new file mode 100644 index 00000000..eaa19a86 --- /dev/null +++ b/test/e2e/suite/102-kustomize-match-application-name/01-install.yaml @@ -0,0 +1,83 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: image-updater-e2e-102-0 +--- +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: image-updater-102-0 + annotations: + argocd-image-updater.argoproj.io/image-list: guestbook=gcr.io/heptio-images/ks-guestbook-demo:~0 + argocd-image-updater.argoproj.io/test.update-strategy: semver + finalizers: + - resources-finalizer.argocd.argoproj.io +spec: + project: default + source: + repoURL: https://github.com/argoproj/argocd-example-apps.git + path: kustomize-guestbook + targetRevision: HEAD + destination: + server: https://kubernetes.default.svc + namespace: image-updater-e2e-102-0 + syncPolicy: + automated: {} + retry: + limit: 2 +--- +apiVersion: v1 +kind: Namespace +metadata: + name: image-updater-e2e-102-1 +--- +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: image-updater-102-1 + annotations: + argocd-image-updater.argoproj.io/image-list: guestbook=gcr.io/heptio-images/ks-guestbook-demo:~0 + argocd-image-updater.argoproj.io/test.update-strategy: semver + finalizers: + - resources-finalizer.argocd.argoproj.io +spec: + project: default + source: + repoURL: https://github.com/argoproj/argocd-example-apps.git + path: kustomize-guestbook + targetRevision: HEAD + destination: + server: https://kubernetes.default.svc + namespace: image-updater-e2e-102-1 + syncPolicy: + automated: {} + retry: + limit: 2 +--- +apiVersion: v1 +kind: Namespace +metadata: + name: image-updater-e2e-102-2 +--- +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: image-updater-102-2 + annotations: + argocd-image-updater.argoproj.io/image-list: guestbook=gcr.io/heptio-images/ks-guestbook-demo:~0 + argocd-image-updater.argoproj.io/test.update-strategy: semver + finalizers: + - resources-finalizer.argocd.argoproj.io +spec: + project: default + source: + repoURL: https://github.com/argoproj/argocd-example-apps.git + path: kustomize-guestbook + targetRevision: HEAD + destination: + server: https://kubernetes.default.svc + namespace: image-updater-e2e-102-2 + syncPolicy: + automated: {} + retry: + limit: 2 \ No newline at end of file diff --git a/test/e2e/suite/102-kustomize-match-application-name/02-assert.yaml b/test/e2e/suite/102-kustomize-match-application-name/02-assert.yaml new file mode 100644 index 00000000..df3125bb --- /dev/null +++ b/test/e2e/suite/102-kustomize-match-application-name/02-assert.yaml @@ -0,0 +1,29 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: image-updater-102-0 +status: + health: + status: Healthy + sync: + status: Synced +--- +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: image-updater-102-1 +status: + health: + status: Healthy + sync: + status: Synced +--- +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: image-updater-102-2 +status: + health: + status: Healthy + sync: + status: Synced \ No newline at end of file diff --git a/test/e2e/suite/102-kustomize-match-application-name/02-run-updater.yaml b/test/e2e/suite/102-kustomize-match-application-name/02-run-updater.yaml new file mode 100644 index 00000000..0f09cfe1 --- /dev/null +++ b/test/e2e/suite/102-kustomize-match-application-name/02-run-updater.yaml @@ -0,0 +1,9 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: +- script: | + ${SRC_DIR}/dist/argocd-image-updater run --once \ + --argocd-namespace argocd-image-updater-e2e \ + --match-application-name no-match* \ + --registries-conf-path="" \ + --loglevel info diff --git a/test/e2e/suite/102-kustomize-match-application-name/03-assert.yaml b/test/e2e/suite/102-kustomize-match-application-name/03-assert.yaml new file mode 100644 index 00000000..70acc11b --- /dev/null +++ b/test/e2e/suite/102-kustomize-match-application-name/03-assert.yaml @@ -0,0 +1,34 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: image-updater-102-0 +spec: + source: + kustomize: + images: + - gcr.io/heptio-images/ks-guestbook-demo:0.2 +status: + health: + status: Healthy + sync: + status: Synced +--- +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: image-updater-102-1 +status: + health: + status: Healthy + sync: + status: Synced +--- +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: image-updater-102-2 +status: + health: + status: Healthy + sync: + status: Synced diff --git a/test/e2e/suite/102-kustomize-match-application-name/03-run-updater.yaml b/test/e2e/suite/102-kustomize-match-application-name/03-run-updater.yaml new file mode 100644 index 00000000..987ca093 --- /dev/null +++ b/test/e2e/suite/102-kustomize-match-application-name/03-run-updater.yaml @@ -0,0 +1,9 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: +- script: | + ${SRC_DIR}/dist/argocd-image-updater run --once \ + --argocd-namespace argocd-image-updater-e2e \ + --match-application-name image-updater-102-0 \ + --registries-conf-path="" \ + --loglevel info diff --git a/test/e2e/suite/102-kustomize-match-application-name/04-assert.yaml b/test/e2e/suite/102-kustomize-match-application-name/04-assert.yaml new file mode 100644 index 00000000..bcbc284c --- /dev/null +++ b/test/e2e/suite/102-kustomize-match-application-name/04-assert.yaml @@ -0,0 +1,39 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: image-updater-102-0 +spec: + source: + kustomize: + images: + - gcr.io/heptio-images/ks-guestbook-demo:0.2 +status: + health: + status: Healthy + sync: + status: Synced +--- +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: image-updater-102-1 +spec: + source: + kustomize: + images: + - gcr.io/heptio-images/ks-guestbook-demo:0.2 +status: + health: + status: Healthy + sync: + status: Synced +--- +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: image-updater-102-2 +status: + health: + status: Healthy + sync: + status: Synced diff --git a/test/e2e/suite/102-kustomize-match-application-name/04-run-updater.yaml b/test/e2e/suite/102-kustomize-match-application-name/04-run-updater.yaml new file mode 100644 index 00000000..9cd3eb9e --- /dev/null +++ b/test/e2e/suite/102-kustomize-match-application-name/04-run-updater.yaml @@ -0,0 +1,10 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: +- script: | + ${SRC_DIR}/dist/argocd-image-updater run --once \ + --argocd-namespace argocd-image-updater-e2e \ + --match-application-name image-updater-102-0 \ + --match-application-name image-updater-102-1 \ + --registries-conf-path="" \ + --loglevel info diff --git a/test/e2e/suite/102-kustomize-match-application-name/05-assert.yaml b/test/e2e/suite/102-kustomize-match-application-name/05-assert.yaml new file mode 100644 index 00000000..a44a5c15 --- /dev/null +++ b/test/e2e/suite/102-kustomize-match-application-name/05-assert.yaml @@ -0,0 +1,44 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: image-updater-102-0 +spec: + source: + kustomize: + images: + - gcr.io/heptio-images/ks-guestbook-demo:0.2 +status: + health: + status: Healthy + sync: + status: Synced +--- +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: image-updater-102-1 +spec: + source: + kustomize: + images: + - gcr.io/heptio-images/ks-guestbook-demo:0.2 +status: + health: + status: Healthy + sync: + status: Synced +--- +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: image-updater-102-2 +spec: + source: + kustomize: + images: + - gcr.io/heptio-images/ks-guestbook-demo:0.2 +status: + health: + status: Healthy + sync: + status: Synced diff --git a/test/e2e/suite/102-kustomize-match-application-name/05-run-updater.yaml b/test/e2e/suite/102-kustomize-match-application-name/05-run-updater.yaml new file mode 100644 index 00000000..a0728355 --- /dev/null +++ b/test/e2e/suite/102-kustomize-match-application-name/05-run-updater.yaml @@ -0,0 +1,9 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: +- script: | + ${SRC_DIR}/dist/argocd-image-updater run --once \ + --argocd-namespace argocd-image-updater-e2e \ + --match-application-name image-updater-102-* \ + --registries-conf-path="" \ + --loglevel info diff --git a/test/e2e/suite/102-kustomize-match-application-name/99-delete.yaml b/test/e2e/suite/102-kustomize-match-application-name/99-delete.yaml new file mode 100644 index 00000000..7c72a234 --- /dev/null +++ b/test/e2e/suite/102-kustomize-match-application-name/99-delete.yaml @@ -0,0 +1,22 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +timeout: 120 +delete: +- apiVersion: argoproj.io/v1alpha1 + kind: Application + name: image-updater-102-0 +- apiVersion: v1 + kind: Namespace + name: image-updater-e2e-102-0 +- apiVersion: argoproj.io/v1alpha1 + kind: Application + name: image-updater-102-1 +- apiVersion: v1 + kind: Namespace + name: image-updater-e2e-102-1 +- apiVersion: argoproj.io/v1alpha1 + kind: Application + name: image-updater-102-2 +- apiVersion: v1 + kind: Namespace + name: image-updater-e2e-102-2 \ No newline at end of file diff --git a/test/e2e/suite/102-kustomize-match-application-name/README.md b/test/e2e/suite/102-kustomize-match-application-name/README.md new file mode 100644 index 00000000..b6c39f4d --- /dev/null +++ b/test/e2e/suite/102-kustomize-match-application-name/README.md @@ -0,0 +1,21 @@ +This test case verifies [filtering applications by name](https://argocd-image-updater.readthedocs.io/en/stable/install/reference/#flags) with `--match-application-name` command line options +* match against a non-existent application name +* match against an exact application name +* specify `--match-application-name` option multiple times to match against multiple application names +* use wild card `*` in application name pattern + +This test case uses image from public container registry and application source from public GitHub repo. + +To run this individual test case, + +* make sure both docker daemon and k8s cluster is running +* `cd $HOME/go/src/image-updater/test/e2e` +* `SRC_DIR=$HOME/go/src/image-updater kubectl kuttl test --namespace argocd-image-updater-e2e --timeout 120 --test 102-kustomize-match-application-name` + +The test output logs that during each test step, 0, 1, 2, or 3 images are updated, as specified by argocd-image-updater `--match-application-name` option: +```bash +102-kustomize-match-application-name/2-run-updater msg="Processing results: applications=0 images_considered=0 images_skipped=0 images_updated=0 errors=0" +102-kustomize-match-application-name/3-run-updater msg="Processing results: applications=1 images_considered=1 images_skipped=0 images_updated=1 errors=0" +102-kustomize-match-application-name/4-run-updater msg="Processing results: applications=2 images_considered=2 images_skipped=0 images_updated=2 errors=0" +102-kustomize-match-application-name/5-run-updater msg="Processing results: applications=3 images_considered=3 images_skipped=0 images_updated=3 errors=0" +``` \ No newline at end of file