Skip to content

Commit 483eeb7

Browse files
committed
Fix tests
1 parent c23b342 commit 483eeb7

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

pkg/argocd/update.go

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

421421
for _, c := range images {
422-
helmAnnotationParamName, helmAnnotationParamVersion := getHelmParamNamesFromAnnotation(app.Annotations, c.ImageAlias)
422+
imageName := c.ImageAlias
423+
if c.ImageAlias == "" {
424+
imageName = c.ImageName
425+
}
426+
427+
helmAnnotationParamName, helmAnnotationParamVersion := getHelmParamNamesFromAnnotation(app.Annotations, imageName)
423428
if helmAnnotationParamName == "" {
424-
return nil, fmt.Errorf("could not find an image-name annotation for image %s", c.ImageAlias)
429+
return nil, fmt.Errorf("could not find an image-name annotation for image %s", imageName)
425430
}
426431
if helmAnnotationParamVersion == "" {
427-
return nil, fmt.Errorf("could not find an image-tag annotation for image %s", c.ImageAlias)
432+
return nil, fmt.Errorf("could not find an image-tag annotation for image %s", imageName)
428433
}
429434

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

pkg/argocd/update_test.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,8 +1320,9 @@ helm:
13201320

13211321
t.Run("Valid Helm source with Helm values file", func(t *testing.T) {
13221322
expected := `
1323-
image.name: nginx
1324-
image.tag: v1.0.0
1323+
image:
1324+
name: nginx
1325+
tag: v1.0.0
13251326
replicas: 1
13261327
`
13271328
app := v1alpha1.Application{
@@ -1366,8 +1367,9 @@ replicas: 1
13661367
}
13671368

13681369
originalData := []byte(`
1369-
image.name: nginx
1370-
image.tag: v0.0.0
1370+
image:
1371+
name: nginx
1372+
tag: v0.0.0
13711373
replicas: 1
13721374
`)
13731375
yaml, err := marshalParamsOverride(&app, originalData)
@@ -1512,7 +1514,10 @@ replicas: 1
15121514
},
15131515
}
15141516

1515-
originalData := []byte(`random content`)
1517+
originalData := []byte(`
1518+
random:
1519+
content: hello
1520+
`)
15161521
_, err := marshalParamsOverride(&app, originalData)
15171522
assert.Error(t, err)
15181523
assert.Equal(t, "wrongimage.name parameter not found", err.Error())
@@ -1560,7 +1565,10 @@ replicas: 1
15601565
},
15611566
}
15621567

1563-
originalData := []byte(`random content`)
1568+
originalData := []byte(`
1569+
random:
1570+
content: hello
1571+
`)
15641572
_, err := marshalParamsOverride(&app, originalData)
15651573
assert.Error(t, err)
15661574
assert.Equal(t, "wrongimage.tag parameter not found", err.Error())

0 commit comments

Comments
 (0)