@@ -1383,6 +1383,94 @@ 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 with multiple images" , func (t * testing.T ) {
1387
+ expected := `
1388
+ nginx.image.name: nginx
1389
+ nginx.image.tag: v1.0.0
1390
+ redis.image.name: redis
1391
+ redis.image.tag: v1.0.0
1392
+ replicas: 1
1393
+ `
1394
+ app := v1alpha1.Application {
1395
+ ObjectMeta : v1.ObjectMeta {
1396
+ Name : "testapp" ,
1397
+ Annotations : map [string ]string {
1398
+ "argocd-image-updater.argoproj.io/image-list" : "nginx=nginx, redis=redis" ,
1399
+ "argocd-image-updater.argoproj.io/write-back-method" : "git" ,
1400
+ "argocd-image-updater.argoproj.io/write-back-target" : "helmvalues:./test-values.yaml" ,
1401
+ "argocd-image-updater.argoproj.io/nginx.helm.image-name" : "nginx.image.name" ,
1402
+ "argocd-image-updater.argoproj.io/nginx.helm.image-tag" : "nginx.image.tag" ,
1403
+ "argocd-image-updater.argoproj.io/redis.helm.image-name" : "redis.image.name" ,
1404
+ "argocd-image-updater.argoproj.io/redis.helm.image-tag" : "redis.image.tag" ,
1405
+ },
1406
+ },
1407
+ Spec : v1alpha1.ApplicationSpec {
1408
+ Sources : []v1alpha1.ApplicationSource {
1409
+ {
1410
+ Chart : "my-app" ,
1411
+ Helm : & v1alpha1.ApplicationSourceHelm {
1412
+ ReleaseName : "my-app" ,
1413
+ ValueFiles : []string {"$values/some/dir/values.yaml" },
1414
+ Parameters : []v1alpha1.HelmParameter {
1415
+ {
1416
+ Name : "nginx.image.name" ,
1417
+ Value : "nginx" ,
1418
+ ForceString : true ,
1419
+ },
1420
+ {
1421
+ Name : "nginx.image.tag" ,
1422
+ Value : "v1.0.0" ,
1423
+ ForceString : true ,
1424
+ },
1425
+ {
1426
+ Name : "redis.image.name" ,
1427
+ Value : "redis" ,
1428
+ ForceString : true ,
1429
+ },
1430
+ {
1431
+ Name : "redis.image.tag" ,
1432
+ Value : "v1.0.0" ,
1433
+ ForceString : true ,
1434
+ },
1435
+ },
1436
+ },
1437
+ RepoURL : "https://example.com/example" ,
1438
+ TargetRevision : "main" ,
1439
+ },
1440
+ {
1441
+ Ref : "values" ,
1442
+ RepoURL : "https://example.com/example2" ,
1443
+ TargetRevision : "main" ,
1444
+ },
1445
+ },
1446
+ },
1447
+ Status : v1alpha1.ApplicationStatus {
1448
+ SourceTypes : []v1alpha1.ApplicationSourceType {
1449
+ v1alpha1 .ApplicationSourceTypeHelm ,
1450
+ "" ,
1451
+ },
1452
+ Summary : v1alpha1.ApplicationSummary {
1453
+ Images : []string {
1454
+ "nginx:v0.0.0" ,
1455
+ "redis:v0.0.0" ,
1456
+ },
1457
+ },
1458
+ },
1459
+ }
1460
+
1461
+ originalData := []byte (`
1462
+ nginx.image.name: nginx
1463
+ nginx.image.tag: v0.0.0
1464
+ redis.image.name: redis
1465
+ redis.image.tag: v0.0.0
1466
+ replicas: 1
1467
+ ` )
1468
+ yaml , err := marshalParamsOverride (& app , originalData )
1469
+ require .NoError (t , err )
1470
+ assert .NotEmpty (t , yaml )
1471
+ assert .Equal (t , strings .TrimSpace (strings .ReplaceAll (expected , "\t " , " " )), strings .TrimSpace (string (yaml )))
1472
+ })
1473
+
1386
1474
t .Run ("Failed to setValue image parameter name" , func (t * testing.T ) {
1387
1475
app := v1alpha1.Application {
1388
1476
ObjectMeta : v1.ObjectMeta {
@@ -1528,7 +1616,7 @@ replicas: 1
1528
1616
},
1529
1617
}
1530
1618
1531
- originalData := []byte (`random content ` )
1619
+ originalData := []byte (`random: yaml ` )
1532
1620
_ , err := marshalParamsOverride (& app , originalData )
1533
1621
assert .Error (t , err )
1534
1622
assert .Equal (t , "could not find an image-tag annotation for image nginx" , err .Error ())
@@ -1575,7 +1663,7 @@ replicas: 1
1575
1663
},
1576
1664
}
1577
1665
1578
- originalData := []byte (`random content ` )
1666
+ originalData := []byte (`random: yaml ` )
1579
1667
_ , err := marshalParamsOverride (& app , originalData )
1580
1668
assert .Error (t , err )
1581
1669
assert .Equal (t , "could not find an image-name annotation for image nginx" , err .Error ())
@@ -1623,7 +1711,7 @@ replicas: 1
1623
1711
},
1624
1712
}
1625
1713
1626
- originalData := []byte (`random content ` )
1714
+ originalData := []byte (`random: yaml ` )
1627
1715
_ , err := marshalParamsOverride (& app , originalData )
1628
1716
assert .Error (t , err )
1629
1717
assert .Equal (t , "wrongimage.name parameter not found" , err .Error ())
@@ -1671,7 +1759,7 @@ replicas: 1
1671
1759
},
1672
1760
}
1673
1761
1674
- originalData := []byte (`random content ` )
1762
+ originalData := []byte (`random: yaml ` )
1675
1763
_ , err := marshalParamsOverride (& app , originalData )
1676
1764
assert .Error (t , err )
1677
1765
assert .Equal (t , "wrongimage.tag parameter not found" , err .Error ())
0 commit comments