Skip to content

Commit a2eaa1c

Browse files
committed
fixed support for image aliases
Signed-off-by: Aleksandr Petrov <burnb83@gmail.com>
1 parent 7259efa commit a2eaa1c

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

pkg/argocd/argocd.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,9 +497,13 @@ func GetImagesFromApplication(app *v1alpha1.Application) image.ContainerImageLis
497497
annotations := app.Annotations
498498
imagesFromAnnotations := parseImageList(annotations)
499499

500+
appImgs := make(image.ContainerImageList, 0, len(app.Status.Summary.Images))
500501
for _, imageStr := range app.Status.Summary.Images {
501-
img := image.NewFromIdentifier(imageStr)
502-
if ImageIsAllowed(img, imagesFromAnnotations) {
502+
appImgs = append(appImgs, image.NewFromIdentifier(imageStr))
503+
}
504+
505+
for _, img := range *imagesFromAnnotations {
506+
if ImageIsAllowed(img, &appImgs) {
503507
images = append(images, img)
504508
}
505509
}

pkg/argocd/update.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,12 +419,16 @@ func marshalParamsOverride(app *v1alpha1.Application, originalData []byte) ([]by
419419
images := GetImagesFromApplication(app)
420420

421421
for _, c := range images {
422-
helmAnnotationParamName, helmAnnotationParamVersion := getHelmParamNamesFromAnnotation(app.Annotations, c.ImageName)
422+
image := c.ImageAlias
423+
if image == "" {
424+
image = c.ImageName
425+
}
426+
helmAnnotationParamName, helmAnnotationParamVersion := getHelmParamNamesFromAnnotation(app.Annotations, image)
423427
if helmAnnotationParamName == "" {
424-
return nil, fmt.Errorf("could not find an image-name annotation for image %s", c.ImageName)
428+
return nil, fmt.Errorf("could not find an image-name annotation for image %s", image)
425429
}
426430
if helmAnnotationParamVersion == "" {
427-
return nil, fmt.Errorf("could not find an image-tag annotation for image %s", c.ImageName)
431+
return nil, fmt.Errorf("could not find an image-tag annotation for image %s", image)
428432
}
429433

430434
helmParamName := getHelmParam(appSource.Helm.Parameters, helmAnnotationParamName)

0 commit comments

Comments
 (0)