Skip to content

Commit 4d29ab3

Browse files
committed
fixed support for image aliases
Signed-off-by: Aleksandr Petrov <[email protected]>
1 parent 2a2b321 commit 4d29ab3

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

pkg/argocd/argocd.go

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

497+
appImgs := make(image.ContainerImageList, 0, len(app.Status.Summary.Images))
497498
for _, imageStr := range app.Status.Summary.Images {
498-
img := image.NewFromIdentifier(imageStr)
499-
if ImageIsAllowed(img, imagesFromAnnotations) {
499+
appImgs = append(appImgs, image.NewFromIdentifier(imageStr))
500+
}
501+
502+
for _, img := range *imagesFromAnnotations {
503+
if ImageIsAllowed(img, &appImgs) {
500504
images = append(images, img)
501505
}
502506
}

pkg/argocd/update.go

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

421421
for _, c := range images {
422-
423-
if c.ImageAlias == "" {
424-
continue
422+
image := c.ImageAlias
423+
if image == "" {
424+
image = c.ImageName
425425
}
426-
427-
helmAnnotationParamName, helmAnnotationParamVersion := getHelmParamNamesFromAnnotation(app.Annotations, c)
428-
426+
helmAnnotationParamName, helmAnnotationParamVersion := getHelmParamNamesFromAnnotation(app.Annotations, image)
429427
if helmAnnotationParamName == "" {
430-
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)
431429
}
432430
if helmAnnotationParamVersion == "" {
433-
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)
434432
}
435433

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

0 commit comments

Comments
 (0)