@@ -1500,6 +1500,20 @@ replicas: 1
1500
1500
require .NoError (t , err )
1501
1501
assert .NotEmpty (t , yaml )
1502
1502
assert .Equal (t , strings .TrimSpace (strings .ReplaceAll (expected , "\t " , " " )), strings .TrimSpace (string (yaml )))
1503
+
1504
+ // when image.spec.foo fields are missing in the target helm value file,
1505
+ // they should be auto created without corrupting any other pre-existing elements.
1506
+ originalData = []byte ("test-value1: one" )
1507
+ expected = `
1508
+ test-value1: one
1509
+ image:
1510
+ spec:
1511
+ foo: nginx:v1.0.0
1512
+ `
1513
+ yaml , err = marshalParamsOverride (& app , originalData )
1514
+ require .NoError (t , err )
1515
+ assert .NotEmpty (t , yaml )
1516
+ assert .Equal (t , strings .TrimSpace (strings .ReplaceAll (expected , "\t " , " " )), strings .TrimSpace (string (yaml )))
1503
1517
})
1504
1518
1505
1519
t .Run ("Valid Helm source with Helm values file with multiple images" , func (t * testing.T ) {
@@ -1588,6 +1602,25 @@ replicas: 1
1588
1602
require .NoError (t , err )
1589
1603
assert .NotEmpty (t , yaml )
1590
1604
assert .Equal (t , strings .TrimSpace (strings .ReplaceAll (expected , "\t " , " " )), strings .TrimSpace (string (yaml )))
1605
+
1606
+ // when nginx.* and redis.* fields are missing in the target helm value file,
1607
+ // they should be auto created without corrupting any other pre-existing elements.
1608
+ originalData = []byte ("test-value1: one" )
1609
+ expected = `
1610
+ test-value1: one
1611
+ nginx:
1612
+ image:
1613
+ tag: v1.0.0
1614
+ name: nginx
1615
+ redis:
1616
+ image:
1617
+ tag: v1.0.0
1618
+ name: redis
1619
+ `
1620
+ yaml , err = marshalParamsOverride (& app , originalData )
1621
+ require .NoError (t , err )
1622
+ assert .NotEmpty (t , yaml )
1623
+ assert .Equal (t , strings .TrimSpace (strings .ReplaceAll (expected , "\t " , " " )), strings .TrimSpace (string (yaml )))
1591
1624
})
1592
1625
1593
1626
t .Run ("Valid Helm source with Helm values file with multiple aliases" , func (t * testing.T ) {
@@ -1695,6 +1728,7 @@ replicas: 1
1695
1728
1696
1729
t .Run ("Failed to setValue image parameter name" , func (t * testing.T ) {
1697
1730
expected := `
1731
+ test-value1: one
1698
1732
image:
1699
1733
name: nginx
1700
1734
tag: v1.0.0
@@ -1743,6 +1777,7 @@ replicas: 1
1743
1777
}
1744
1778
1745
1779
originalData := []byte (`
1780
+ test-value1: one
1746
1781
image:
1747
1782
name: nginx
1748
1783
replicas: 1
0 commit comments