@@ -1005,14 +1005,14 @@ func Test_SetHelmImage(t *testing.T) {
10051005 require .Error (t , err )
10061006 })
10071007
1008- t .Run ("Test set Helm image parameters when two paths are provided" , func (t * testing.T ) {
1008+ t .Run ("Test set Helm image parameters when two paths are provided with name and tag " , func (t * testing.T ) {
10091009 app := & v1alpha1.Application {
10101010 ObjectMeta : v1.ObjectMeta {
10111011 Name : "test-app" ,
10121012 Namespace : "testns" ,
10131013 Annotations : map [string ]string {
10141014 fmt .Sprintf (common .HelmParamImageNameAnnotation , "foobar" ): "foobar.image.name,,, foobar2.image.name" ,
1015- fmt .Sprintf (common .HelmParamImageTagAnnotation , "foobar" ): "foobar.image.tag,,, foobar2.image.tag" , // Space and comma are expected
1015+ fmt .Sprintf (common .HelmParamImageTagAnnotation , "foobar" ): "foobar.image.tag,,, foobar2.image.tag" ,
10161016 },
10171017 },
10181018 Spec : v1alpha1.ApplicationSpec {
@@ -1088,6 +1088,66 @@ func Test_SetHelmImage(t *testing.T) {
10881088 }
10891089 assert .Equal (t , "jannfis/foobar" , nameParamTwo .Value )
10901090 })
1091+
1092+ t .Run ("Test set Helm image parameters when two paths are provided with image spec" , func (t * testing.T ) {
1093+ app := & v1alpha1.Application {
1094+ ObjectMeta : v1.ObjectMeta {
1095+ Name : "test-app" ,
1096+ Namespace : "testns" ,
1097+ Annotations : map [string ]string {
1098+ fmt .Sprintf (common .HelmParamImageSpecAnnotation , "foobar" ): "foobar.image.spec,,, foobar2.image.spec" ,
1099+ },
1100+ },
1101+ Spec : v1alpha1.ApplicationSpec {
1102+ Source : & v1alpha1.ApplicationSource {
1103+ Helm : & v1alpha1.ApplicationSourceHelm {
1104+ Parameters : []v1alpha1.HelmParameter {
1105+ {
1106+ Name : "image.spec" ,
1107+ Value : "jannfis/dummy:1.0.0" ,
1108+ },
1109+ },
1110+ },
1111+ },
1112+ },
1113+ Status : v1alpha1.ApplicationStatus {
1114+ SourceType : v1alpha1 .ApplicationSourceTypeHelm ,
1115+ Summary : v1alpha1.ApplicationSummary {
1116+ Images : []string {
1117+ "jannfis/foobar:1.0.0" ,
1118+ },
1119+ },
1120+ },
1121+ }
1122+
1123+ img := image .NewFromIdentifier ("foobar=jannfis/foobar:1.0.1" )
1124+
1125+ err := SetHelmImage (app , img )
1126+ require .NoError (t , err )
1127+ require .NotNil (t , app .Spec .Source .Helm )
1128+ assert .Len (t , app .Spec .Source .Helm .Parameters , 3 )
1129+
1130+ // Find first correct parameter
1131+ var specParam v1alpha1.HelmParameter
1132+ for _ , p := range app .Spec .Source .Helm .Parameters {
1133+ fmt .Println (p .Name )
1134+ if p .Name == "foobar.image.spec" {
1135+ specParam = p
1136+ break
1137+ }
1138+ }
1139+ assert .Equal (t , "jannfis/foobar:1.0.1" , specParam .Value )
1140+
1141+ // Find second correct parameter
1142+ var specParamTwo v1alpha1.HelmParameter
1143+ for _ , p := range app .Spec .Source .Helm .Parameters {
1144+ if p .Name == "foobar2.image.spec" {
1145+ specParamTwo = p
1146+ break
1147+ }
1148+ }
1149+ assert .Equal (t , "jannfis/foobar:1.0.1" , specParamTwo .Value )
1150+ })
10911151}
10921152
10931153func TestKubernetesClient (t * testing.T ) {
0 commit comments