@@ -2241,6 +2241,72 @@ replicas: 1
2241
2241
_ , err := marshalParamsOverride (& app , nil )
2242
2242
assert .Error (t , err )
2243
2243
})
2244
+
2245
+ t .Run ("Whitespace only values file from helm source does not cause error" , func (t * testing.T ) {
2246
+ expected := `
2247
+ # auto generated by argocd image updater
2248
+
2249
+ nginx:
2250
+ image:
2251
+ tag: v1.0.0
2252
+ name: nginx
2253
+ `
2254
+ app := v1alpha1.Application {
2255
+ ObjectMeta : v1.ObjectMeta {
2256
+ Name : "testapp" ,
2257
+ Annotations : map [string ]string {
2258
+ "argocd-image-updater.argoproj.io/image-list" : "nginx=nginx, redis=redis" ,
2259
+ "argocd-image-updater.argoproj.io/write-back-method" : "git" ,
2260
+ "argocd-image-updater.argoproj.io/write-back-target" : "helmvalues:./test-values.yaml" ,
2261
+ "argocd-image-updater.argoproj.io/nginx.helm.image-name" : "nginx.image.name" ,
2262
+ "argocd-image-updater.argoproj.io/nginx.helm.image-tag" : "nginx.image.tag" ,
2263
+ },
2264
+ },
2265
+ Spec : v1alpha1.ApplicationSpec {
2266
+ Sources : []v1alpha1.ApplicationSource {
2267
+ {
2268
+ Chart : "my-app" ,
2269
+ Helm : & v1alpha1.ApplicationSourceHelm {
2270
+ ReleaseName : "my-app" ,
2271
+ ValueFiles : []string {"$values/some/dir/values.yaml" },
2272
+ Parameters : []v1alpha1.HelmParameter {
2273
+ {
2274
+ Name : "nginx.image.name" ,
2275
+ Value : "nginx" ,
2276
+ ForceString : true ,
2277
+ },
2278
+ {
2279
+ Name : "nginx.image.tag" ,
2280
+ Value : "v1.0.0" ,
2281
+ ForceString : true ,
2282
+ },
2283
+ },
2284
+ },
2285
+ RepoURL : "https://example.com/example" ,
2286
+ TargetRevision : "main" ,
2287
+ },
2288
+ },
2289
+ },
2290
+ Status : v1alpha1.ApplicationStatus {
2291
+ SourceTypes : []v1alpha1.ApplicationSourceType {
2292
+ v1alpha1 .ApplicationSourceTypeHelm ,
2293
+ "" ,
2294
+ },
2295
+ Summary : v1alpha1.ApplicationSummary {
2296
+ Images : []string {
2297
+ "nginx:v0.0.0" ,
2298
+ },
2299
+ },
2300
+ },
2301
+ }
2302
+
2303
+ originalData := []byte (`
2304
+ ` )
2305
+ yaml , err := marshalParamsOverride (& app , originalData )
2306
+ require .NoError (t , err )
2307
+ assert .NotEmpty (t , yaml )
2308
+ assert .Equal (t , strings .TrimSpace (strings .ReplaceAll (expected , "\t " , " " )), strings .TrimSpace (string (yaml )))
2309
+ })
2244
2310
}
2245
2311
2246
2312
func Test_SetHelmValue (t * testing.T ) {
0 commit comments