@@ -1005,14 +1005,14 @@ func Test_SetHelmImage(t *testing.T) {
1005
1005
require .Error (t , err )
1006
1006
})
1007
1007
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 ) {
1009
1009
app := & v1alpha1.Application {
1010
1010
ObjectMeta : v1.ObjectMeta {
1011
1011
Name : "test-app" ,
1012
1012
Namespace : "testns" ,
1013
1013
Annotations : map [string ]string {
1014
1014
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" ,
1016
1016
},
1017
1017
},
1018
1018
Spec : v1alpha1.ApplicationSpec {
@@ -1088,6 +1088,66 @@ func Test_SetHelmImage(t *testing.T) {
1088
1088
}
1089
1089
assert .Equal (t , "jannfis/foobar" , nameParamTwo .Value )
1090
1090
})
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
+ })
1091
1151
}
1092
1152
1093
1153
func TestKubernetesClient (t * testing.T ) {
0 commit comments