summaryrefslogtreecommitdiff
path: root/pkg/argocd
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/argocd')
-rw-r--r--pkg/argocd/argocd.go35
-rw-r--r--pkg/argocd/argocd_test.go45
-rw-r--r--pkg/argocd/update.go12
-rw-r--r--pkg/argocd/update_test.go20
4 files changed, 57 insertions, 55 deletions
diff --git a/pkg/argocd/argocd.go b/pkg/argocd/argocd.go
index fdcc69c..de540f6 100644
--- a/pkg/argocd/argocd.go
+++ b/pkg/argocd/argocd.go
@@ -11,6 +11,7 @@ import (
"github.com/argoproj-labs/argocd-image-updater/pkg/common"
"github.com/argoproj-labs/argocd-image-updater/pkg/kube"
"github.com/argoproj-labs/argocd-image-updater/pkg/metrics"
+ registryCommon "github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/common"
"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/env"
"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/image"
"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/log"
@@ -232,7 +233,7 @@ func parseImageList(annotations map[string]string) *image.ContainerImageList {
splits := strings.Split(updateImage, ",")
for _, s := range splits {
img := image.NewFromIdentifier(strings.TrimSpace(s))
- if kustomizeImage := img.GetParameterKustomizeImageName(annotations); kustomizeImage != "" {
+ if kustomizeImage := img.GetParameterKustomizeImageName(annotations, common.ImageUpdaterAnnotationPrefix); kustomizeImage != "" {
img.KustomizeImage = image.NewFromIdentifier(kustomizeImage)
}
results = append(results, img)
@@ -314,17 +315,17 @@ func getHelmParamNamesFromAnnotation(annotations map[string]string, img *image.C
var annotationName, helmParamName, helmParamVersion string
// Image spec is a full-qualified specifier, if we have it, we return early
- if param := img.GetParameterHelmImageSpec(annotations); param != "" {
+ if param := img.GetParameterHelmImageSpec(annotations, common.ImageUpdaterAnnotationPrefix); param != "" {
log.Tracef("found annotation %s", annotationName)
return strings.TrimSpace(param), ""
}
- if param := img.GetParameterHelmImageName(annotations); param != "" {
+ if param := img.GetParameterHelmImageName(annotations, common.ImageUpdaterAnnotationPrefix); param != "" {
log.Tracef("found annotation %s", annotationName)
helmParamName = param
}
- if param := img.GetParameterHelmImageTag(annotations); param != "" {
+ if param := img.GetParameterHelmImageTag(annotations, common.ImageUpdaterAnnotationPrefix); param != "" {
log.Tracef("found annotation %s", annotationName)
helmParamVersion = param
}
@@ -384,16 +385,16 @@ func GetHelmImage(app *v1alpha1.Application, newImage *image.ContainerImage) (st
var hpImageName, hpImageTag, hpImageSpec string
- hpImageSpec = newImage.GetParameterHelmImageSpec(app.Annotations)
- hpImageName = newImage.GetParameterHelmImageName(app.Annotations)
- hpImageTag = newImage.GetParameterHelmImageTag(app.Annotations)
+ hpImageSpec = newImage.GetParameterHelmImageSpec(app.Annotations, common.ImageUpdaterAnnotationPrefix)
+ hpImageName = newImage.GetParameterHelmImageName(app.Annotations, common.ImageUpdaterAnnotationPrefix)
+ hpImageTag = newImage.GetParameterHelmImageTag(app.Annotations, common.ImageUpdaterAnnotationPrefix)
if hpImageSpec == "" {
if hpImageName == "" {
- hpImageName = common.DefaultHelmImageName
+ hpImageName = registryCommon.DefaultHelmImageName
}
if hpImageTag == "" {
- hpImageTag = common.DefaultHelmImageTag
+ hpImageTag = registryCommon.DefaultHelmImageTag
}
}
@@ -434,16 +435,16 @@ func SetHelmImage(app *v1alpha1.Application, newImage *image.ContainerImage) err
var hpImageName, hpImageTag, hpImageSpec string
- hpImageSpec = newImage.GetParameterHelmImageSpec(app.Annotations)
- hpImageName = newImage.GetParameterHelmImageName(app.Annotations)
- hpImageTag = newImage.GetParameterHelmImageTag(app.Annotations)
+ hpImageSpec = newImage.GetParameterHelmImageSpec(app.Annotations, common.ImageUpdaterAnnotationPrefix)
+ hpImageName = newImage.GetParameterHelmImageName(app.Annotations, common.ImageUpdaterAnnotationPrefix)
+ hpImageTag = newImage.GetParameterHelmImageTag(app.Annotations, common.ImageUpdaterAnnotationPrefix)
if hpImageSpec == "" {
if hpImageName == "" {
- hpImageName = common.DefaultHelmImageName
+ hpImageName = registryCommon.DefaultHelmImageName
}
if hpImageTag == "" {
- hpImageTag = common.DefaultHelmImageTag
+ hpImageTag = registryCommon.DefaultHelmImageTag
}
}
@@ -494,7 +495,7 @@ func GetKustomizeImage(app *v1alpha1.Application, newImage *image.ContainerImage
return "", fmt.Errorf("cannot set Kustomize image on non-Kustomize application")
}
- ksImageName := newImage.GetParameterKustomizeImageName(app.Annotations)
+ ksImageName := newImage.GetParameterKustomizeImageName(app.Annotations, common.ImageUpdaterAnnotationPrefix)
appSource := getApplicationSource(app)
@@ -524,7 +525,7 @@ func SetKustomizeImage(app *v1alpha1.Application, newImage *image.ContainerImage
}
var ksImageParam string
- ksImageName := newImage.GetParameterKustomizeImageName(app.Annotations)
+ ksImageName := newImage.GetParameterKustomizeImageName(app.Annotations, common.ImageUpdaterAnnotationPrefix)
if ksImageName != "" {
ksImageParam = fmt.Sprintf("%s=%s", ksImageName, newImage.GetFullNameWithTag())
} else {
@@ -568,7 +569,7 @@ func GetImagesFromApplication(app *v1alpha1.Application) image.ContainerImageLis
// Check the image list for images with a force-update annotation, and add them if they are not already present.
annotations := app.Annotations
for _, img := range *parseImageList(annotations) {
- if img.HasForceUpdateOptionAnnotation(annotations) {
+ if img.HasForceUpdateOptionAnnotation(annotations, common.ImageUpdaterAnnotationPrefix) {
img.ImageTag = nil // the tag from the image list will be a version constraint, which isn't a valid tag
images = append(images, img)
}
diff --git a/pkg/argocd/argocd_test.go b/pkg/argocd/argocd_test.go
index 3876da0..1c9b944 100644
--- a/pkg/argocd/argocd_test.go
+++ b/pkg/argocd/argocd_test.go
@@ -9,6 +9,7 @@ import (
"github.com/argoproj-labs/argocd-image-updater/pkg/common"
"github.com/argoproj-labs/argocd-image-updater/pkg/kube"
+ registryCommon "github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/common"
"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/image"
registryKube "github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/kube"
@@ -66,8 +67,8 @@ func Test_GetImagesFromApplication(t *testing.T) {
Name: "test-app",
Namespace: "argocd",
Annotations: map[string]string{
- fmt.Sprintf(common.ForceUpdateOptionAnnotation, "nginx"): "true",
- common.ImageUpdaterAnnotation: "nginx=nginx",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.ForceUpdateOptionAnnotationSuffix), "nginx"): "true",
+ common.ImageUpdaterAnnotation: "nginx=nginx",
},
},
Spec: v1alpha1.ApplicationSpec{},
@@ -558,8 +559,8 @@ func Test_FilterApplicationsForUpdate(t *testing.T) {
func Test_GetHelmParamAnnotations(t *testing.T) {
t.Run("Get parameter names without symbolic names", func(t *testing.T) {
annotations := map[string]string{
- fmt.Sprintf(common.HelmParamImageSpecAnnotation, "myimg"): "image.blub",
- fmt.Sprintf(common.HelmParamImageTagAnnotation, "myimg"): "image.blab",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.HelmParamImageSpecAnnotationSuffix), "myimg"): "image.blub",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.HelmParamImageTagAnnotationSuffix), "myimg"): "image.blab",
}
name, tag := getHelmParamNamesFromAnnotation(annotations, &image.ContainerImage{
ImageAlias: "",
@@ -570,8 +571,8 @@ func Test_GetHelmParamAnnotations(t *testing.T) {
t.Run("Find existing image spec annotation", func(t *testing.T) {
annotations := map[string]string{
- fmt.Sprintf(common.HelmParamImageSpecAnnotation, "myimg"): "image.path",
- fmt.Sprintf(common.HelmParamImageTagAnnotation, "myimg"): "image.tag",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.HelmParamImageSpecAnnotationSuffix), "myimg"): "image.path",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.HelmParamImageTagAnnotationSuffix), "myimg"): "image.tag",
}
name, tag := getHelmParamNamesFromAnnotation(annotations, &image.ContainerImage{
ImageAlias: "myimg",
@@ -582,8 +583,8 @@ func Test_GetHelmParamAnnotations(t *testing.T) {
t.Run("Find existing image name and image tag annotations", func(t *testing.T) {
annotations := map[string]string{
- fmt.Sprintf(common.HelmParamImageNameAnnotation, "myimg"): "image.name",
- fmt.Sprintf(common.HelmParamImageTagAnnotation, "myimg"): "image.tag",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.HelmParamImageNameAnnotationSuffix), "myimg"): "image.name",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.HelmParamImageTagAnnotationSuffix), "myimg"): "image.tag",
}
name, tag := getHelmParamNamesFromAnnotation(annotations, &image.ContainerImage{
ImageAlias: "myimg",
@@ -594,8 +595,8 @@ func Test_GetHelmParamAnnotations(t *testing.T) {
t.Run("Find non-existing image name and image tag annotations", func(t *testing.T) {
annotations := map[string]string{
- fmt.Sprintf(common.HelmParamImageNameAnnotation, "otherimg"): "image.name",
- fmt.Sprintf(common.HelmParamImageTagAnnotation, "otherimg"): "image.tag",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.HelmParamImageNameAnnotationSuffix), "otherimg"): "image.name",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.HelmParamImageTagAnnotationSuffix), "otherimg"): "image.tag",
}
name, tag := getHelmParamNamesFromAnnotation(annotations, &image.ContainerImage{
ImageAlias: "myimg",
@@ -606,7 +607,7 @@ func Test_GetHelmParamAnnotations(t *testing.T) {
t.Run("Find existing image tag annotations", func(t *testing.T) {
annotations := map[string]string{
- fmt.Sprintf(common.HelmParamImageTagAnnotation, "myimg"): "image.tag",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.HelmParamImageTagAnnotationSuffix), "myimg"): "image.tag",
}
name, tag := getHelmParamNamesFromAnnotation(annotations, &image.ContainerImage{
ImageAlias: "myimg",
@@ -795,7 +796,7 @@ func Test_SetKustomizeImage(t *testing.T) {
Name: "test-app",
Namespace: "testns",
Annotations: map[string]string{
- fmt.Sprintf(common.KustomizeApplicationNameAnnotation, "foobar"): "foobar",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.KustomizeApplicationNameAnnotationSuffix), "foobar"): "foobar",
},
},
Spec: v1alpha1.ApplicationSpec{
@@ -833,8 +834,8 @@ func Test_SetHelmImage(t *testing.T) {
Name: "test-app",
Namespace: "testns",
Annotations: map[string]string{
- fmt.Sprintf(common.HelmParamImageNameAnnotation, "foobar"): "image.name",
- fmt.Sprintf(common.HelmParamImageTagAnnotation, "foobar"): "image.tag",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.HelmParamImageNameAnnotationSuffix), "foobar"): "image.name",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.HelmParamImageTagAnnotationSuffix), "foobar"): "image.tag",
},
},
Spec: v1alpha1.ApplicationSpec{
@@ -887,8 +888,8 @@ func Test_SetHelmImage(t *testing.T) {
Name: "test-app",
Namespace: "testns",
Annotations: map[string]string{
- fmt.Sprintf(common.HelmParamImageNameAnnotation, "foobar"): "image.name",
- fmt.Sprintf(common.HelmParamImageTagAnnotation, "foobar"): "image.tag",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.HelmParamImageNameAnnotationSuffix), "foobar"): "image.name",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.HelmParamImageTagAnnotationSuffix), "foobar"): "image.tag",
},
},
Spec: v1alpha1.ApplicationSpec{
@@ -930,8 +931,8 @@ func Test_SetHelmImage(t *testing.T) {
Name: "test-app",
Namespace: "testns",
Annotations: map[string]string{
- fmt.Sprintf(common.HelmParamImageNameAnnotation, "foobar"): "foobar.image.name",
- fmt.Sprintf(common.HelmParamImageTagAnnotation, "foobar"): "foobar.image.tag",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.HelmParamImageNameAnnotationSuffix), "foobar"): "foobar.image.name",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.HelmParamImageTagAnnotationSuffix), "foobar"): "foobar.image.tag",
},
},
Spec: v1alpha1.ApplicationSpec{
@@ -984,8 +985,8 @@ func Test_SetHelmImage(t *testing.T) {
Name: "test-app",
Namespace: "testns",
Annotations: map[string]string{
- fmt.Sprintf(common.HelmParamImageNameAnnotation, "foobar"): "foobar.image.name",
- fmt.Sprintf(common.HelmParamImageTagAnnotation, "foobar"): "foobar.image.tag",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.HelmParamImageNameAnnotationSuffix), "foobar"): "foobar.image.name",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.HelmParamImageTagAnnotationSuffix), "foobar"): "foobar.image.tag",
},
},
Spec: v1alpha1.ApplicationSpec{
@@ -1227,8 +1228,8 @@ func Test_parseImageList(t *testing.T) {
})
t.Run("Test kustomize override", func(t *testing.T) {
imgs := *parseImageList(map[string]string{
- common.ImageUpdaterAnnotation: "foo=bar",
- fmt.Sprintf(common.KustomizeApplicationNameAnnotation, "foo"): "baz",
+ common.ImageUpdaterAnnotation: "foo=bar",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.KustomizeApplicationNameAnnotationSuffix), "foo"): "baz",
})
assert.Equal(t, "bar", imgs[0].ImageName)
assert.Equal(t, "baz", imgs[0].KustomizeImage.ImageName)
diff --git a/pkg/argocd/update.go b/pkg/argocd/update.go
index 872886b..f7055cf 100644
--- a/pkg/argocd/update.go
+++ b/pkg/argocd/update.go
@@ -206,11 +206,11 @@ func UpdateApplication(updateConf *UpdateConfiguration, state *SyncIterationStat
imgCtx.Debugf("Using no version constraint when looking for a new tag")
}
- vc.Strategy = applicationImage.GetParameterUpdateStrategy(updateConf.UpdateApp.Application.Annotations)
- vc.MatchFunc, vc.MatchArgs = applicationImage.GetParameterMatch(updateConf.UpdateApp.Application.Annotations)
- vc.IgnoreList = applicationImage.GetParameterIgnoreTags(updateConf.UpdateApp.Application.Annotations)
+ vc.Strategy = applicationImage.GetParameterUpdateStrategy(updateConf.UpdateApp.Application.Annotations, common.ImageUpdaterAnnotationPrefix)
+ vc.MatchFunc, vc.MatchArgs = applicationImage.GetParameterMatch(updateConf.UpdateApp.Application.Annotations, common.ImageUpdaterAnnotationPrefix)
+ vc.IgnoreList = applicationImage.GetParameterIgnoreTags(updateConf.UpdateApp.Application.Annotations, common.ImageUpdaterAnnotationPrefix)
vc.Options = applicationImage.
- GetPlatformOptions(updateConf.UpdateApp.Application.Annotations, updateConf.IgnorePlatforms).
+ GetPlatformOptions(updateConf.UpdateApp.Application.Annotations, updateConf.IgnorePlatforms, common.ImageUpdaterAnnotationPrefix).
WithMetadata(vc.Strategy.NeedsMetadata()).
WithLogger(imgCtx.AddField("application", app))
@@ -228,7 +228,7 @@ func UpdateApplication(updateConf *UpdateConfiguration, state *SyncIterationStat
continue
}
- imgCredSrc := applicationImage.GetParameterPullSecret(updateConf.UpdateApp.Application.Annotations)
+ imgCredSrc := applicationImage.GetParameterPullSecret(updateConf.UpdateApp.Application.Annotations, common.ImageUpdaterAnnotationPrefix)
var creds *image.Credential = &image.Credential{}
if imgCredSrc != nil {
creds, err = imgCredSrc.FetchCredentials(rep.RegistryAPI, updateConf.KubeClient.KubeClient)
@@ -478,7 +478,7 @@ func marshalParamsOverride(app *v1alpha1.Application, originalData []byte) ([]by
// for image-spec annotation, helmAnnotationParamName holds image-spec annotation value,
// and helmAnnotationParamVersion is empty
if helmAnnotationParamVersion == "" {
- if c.GetParameterHelmImageSpec(app.Annotations) == "" {
+ if c.GetParameterHelmImageSpec(app.Annotations, common.ImageUpdaterAnnotationPrefix) == "" {
// not a full image-spec, so image-tag is required
return nil, fmt.Errorf("could not find an image-tag annotation for image %s", c.ImageName)
}
diff --git a/pkg/argocd/update_test.go b/pkg/argocd/update_test.go
index 1f3de53..21cd62a 100644
--- a/pkg/argocd/update_test.go
+++ b/pkg/argocd/update_test.go
@@ -16,7 +16,7 @@ import (
argomock "github.com/argoproj-labs/argocd-image-updater/pkg/argocd/mocks"
"github.com/argoproj-labs/argocd-image-updater/pkg/common"
"github.com/argoproj-labs/argocd-image-updater/pkg/kube"
-
+ registryCommon "github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/common"
"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/image"
registryKube "github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/kube"
"github.com/argoproj-labs/argocd-image-updater/registry-scanner/pkg/registry"
@@ -512,7 +512,7 @@ func Test_UpdateApplication(t *testing.T) {
Name: "guestbook",
Namespace: "guestbook",
Annotations: map[string]string{
- fmt.Sprintf(common.PullSecretAnnotation, "dummy"): "secret:foo/bar#creds",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.PullSecretAnnotationSuffix), "dummy"): "secret:foo/bar#creds",
},
},
Spec: v1alpha1.ApplicationSpec{
@@ -683,8 +683,8 @@ func Test_UpdateApplication(t *testing.T) {
},
}
annotations := map[string]string{
- common.ImageUpdaterAnnotation: "foobar=gcr.io/jannfis/foobar:>=1.0.1",
- fmt.Sprintf(common.KustomizeApplicationNameAnnotation, "foobar"): "jannfis/foobar",
+ common.ImageUpdaterAnnotation: "foobar=gcr.io/jannfis/foobar:>=1.0.1",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.KustomizeApplicationNameAnnotationSuffix), "foobar"): "jannfis/foobar",
}
appImages := &ApplicationImages{
Application: v1alpha1.Application{
@@ -744,8 +744,8 @@ func Test_UpdateApplication(t *testing.T) {
},
}
annotations := map[string]string{
- common.ImageUpdaterAnnotation: "foobar=gcr.io/jannfis/foobar:>=1.0.1",
- fmt.Sprintf(common.KustomizeApplicationNameAnnotation, "foobar"): "jannfis/foobar",
+ common.ImageUpdaterAnnotation: "foobar=gcr.io/jannfis/foobar:>=1.0.1",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.KustomizeApplicationNameAnnotationSuffix), "foobar"): "jannfis/foobar",
}
appImages := &ApplicationImages{
Application: v1alpha1.Application{
@@ -826,8 +826,8 @@ func Test_UpdateApplication(t *testing.T) {
Name: "guestbook",
Namespace: "guestbook",
Annotations: map[string]string{
- fmt.Sprintf(common.AllowTagsOptionAnnotation, "dummy"): "regexp:^foobar$",
- fmt.Sprintf(common.UpdateStrategyAnnotation, "dummy"): "name",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.AllowTagsOptionAnnotationSuffix), "dummy"): "regexp:^foobar$",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.UpdateStrategyAnnotationSuffix), "dummy"): "name",
},
},
Spec: v1alpha1.ApplicationSpec{
@@ -904,8 +904,8 @@ func Test_UpdateApplication(t *testing.T) {
Name: "guestbook",
Namespace: "guestbook",
Annotations: map[string]string{
- fmt.Sprintf(common.IgnoreTagsOptionAnnotation, "dummy"): "*",
- fmt.Sprintf(common.UpdateStrategyAnnotation, "dummy"): "name",
+ fmt.Sprintf(registryCommon.Prefixed(common.ImageUpdaterAnnotationPrefix, registryCommon.IgnoreTagsOptionAnnotationSuffix), "dummy"): "*",
+ fmt.Sprintf(registryCommon.UpdateStrategyAnnotationSuffix, "dummy"): "name",
},
},
Spec: v1alpha1.ApplicationSpec{