@@ -1383,6 +1383,56 @@ replicas: 1
13831383 assert .Equal (t , strings .TrimSpace (strings .ReplaceAll (expected , "\t " , " " )), strings .TrimSpace (string (yaml )))
13841384 })
13851385
1386+ t .Run ("Valid Helm source with Helm values file and image-spec" , func (t * testing.T ) {
1387+ expected := `
1388+ image.spec.foo: nginx:v1.0.0
1389+ replicas: 1
1390+ `
1391+ app := v1alpha1.Application {
1392+ ObjectMeta : v1.ObjectMeta {
1393+ Name : "testapp" ,
1394+ Annotations : map [string ]string {
1395+ "argocd-image-updater.argoproj.io/image-list" : "nginx" ,
1396+ "argocd-image-updater.argoproj.io/write-back-method" : "git" ,
1397+ "argocd-image-updater.argoproj.io/write-back-target" : "helmvalues:./test-values.yaml" ,
1398+ "argocd-image-updater.argoproj.io/nginx.helm.image-spec" : "image.spec.foo" ,
1399+ },
1400+ },
1401+ Spec : v1alpha1.ApplicationSpec {
1402+ Source : & v1alpha1.ApplicationSource {
1403+ RepoURL : "https://example.com/example" ,
1404+ TargetRevision : "main" ,
1405+ Helm : & v1alpha1.ApplicationSourceHelm {
1406+ Parameters : []v1alpha1.HelmParameter {
1407+ {
1408+ Name : "image.spec.foo" ,
1409+ Value : "nginx:v1.0.0" ,
1410+ ForceString : true ,
1411+ },
1412+ },
1413+ },
1414+ },
1415+ },
1416+ Status : v1alpha1.ApplicationStatus {
1417+ SourceType : v1alpha1 .ApplicationSourceTypeHelm ,
1418+ Summary : v1alpha1.ApplicationSummary {
1419+ Images : []string {
1420+ "nginx:v0.0.0" ,
1421+ },
1422+ },
1423+ },
1424+ }
1425+
1426+ originalData := []byte (`
1427+ image.spec.foo: nginx:v0.0.0
1428+ replicas: 1
1429+ ` )
1430+ yaml , err := marshalParamsOverride (& app , originalData )
1431+ require .NoError (t , err )
1432+ assert .NotEmpty (t , yaml )
1433+ assert .Equal (t , strings .TrimSpace (strings .ReplaceAll (expected , "\t " , " " )), strings .TrimSpace (string (yaml )))
1434+ })
1435+
13861436 t .Run ("Valid Helm source with Helm values file with multiple images" , func (t * testing.T ) {
13871437 expected := `
13881438nginx.image.name: nginx
@@ -1834,7 +1884,6 @@ replicas: 1
18341884 originalData := []byte (`random: yaml` )
18351885 _ , err := marshalParamsOverride (& app , originalData )
18361886 assert .Error (t , err )
1837- assert .Equal (t , "wrongimage.name parameter not found" , err .Error ())
18381887 })
18391888
18401889 t .Run ("Image-tag annotation value not found in Helm source parameters list" , func (t * testing.T ) {
0 commit comments