@@ -1383,6 +1383,56 @@ replicas: 1
1383
1383
assert .Equal (t , strings .TrimSpace (strings .ReplaceAll (expected , "\t " , " " )), strings .TrimSpace (string (yaml )))
1384
1384
})
1385
1385
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
+
1386
1436
t .Run ("Valid Helm source with Helm values file with multiple images" , func (t * testing.T ) {
1387
1437
expected := `
1388
1438
nginx.image.name: nginx
@@ -1834,7 +1884,6 @@ replicas: 1
1834
1884
originalData := []byte (`random: yaml` )
1835
1885
_ , err := marshalParamsOverride (& app , originalData )
1836
1886
assert .Error (t , err )
1837
- assert .Equal (t , "wrongimage.name parameter not found" , err .Error ())
1838
1887
})
1839
1888
1840
1889
t .Run ("Image-tag annotation value not found in Helm source parameters list" , func (t * testing.T ) {
0 commit comments