@@ -239,7 +239,8 @@ func GetContainerOverrides(xc *app.ExecutionContext, ctx *cli.Context) (*config.
239
239
if envErr != nil {
240
240
return nil , envErr
241
241
}
242
- env := validateAndCleanEnvVariables (ctx .StringSlice (FlagEnv ), xc )
242
+ envList = validateAndCleanEnvVariables (xc , envList , "param.env-file.value" )
243
+ env := validateAndCleanEnvVariables (xc , ctx .StringSlice (FlagEnv ), "param.env" )
243
244
envList = append (envList , env ... )
244
245
overrides := & config.ContainerOverrides {
245
246
User : ctx .String (FlagUser ),
@@ -408,9 +409,7 @@ func GetDockerClientConfig(ctx *cli.Context) *config.DockerClient {
408
409
return config
409
410
}
410
411
411
- func validateAndCleanEnvVariables (envList []string , xc * app.ExecutionContext ) []string {
412
- xc .Out .Info ("Validating and cleaning environment variables" )
413
-
412
+ func validateAndCleanEnvVariables (xc * app.ExecutionContext , envList []string , errType string ) []string {
414
413
var envStaging []string
415
414
416
415
if len (envList ) == 0 {
@@ -425,19 +424,24 @@ func validateAndCleanEnvVariables(envList []string, xc *app.ExecutionContext) []
425
424
}
426
425
427
426
if ! strings .ContainsAny (kv , "=" ) {
428
- xc .Out .Prompt ( fmt .Sprintf ("Malformed env key/value (idx: %v kv: %s). Excluding from list " , i , kv ))
427
+ xc .Out .Error ( errType , fmt .Sprintf ("skipping malformed env var - (index=%d data='%s') " , i , kv ))
429
428
continue
430
429
}
431
430
432
431
envKeyValue := strings .SplitN (kv , "=" , 2 )
432
+ if len (envKeyValue ) != 2 {
433
+ xc .Out .Error (errType , fmt .Sprintf ("skipping malformed env var - (index=%d data='%s')" , i , kv ))
434
+ continue
435
+ }
436
+
433
437
keyIsEmpty := len (strings .TrimSpace (envKeyValue [0 ])) == 0
434
- valIsEmpty := len (strings .TrimSpace (envKeyValue [1 ])) == 0
438
+ //no need to trim value (it may have spaces intentionally)
439
+ valIsEmpty := len (envKeyValue [1 ]) == 0
435
440
436
- if len (envKeyValue ) == 2 && ! keyIsEmpty && ! valIsEmpty {
437
- xc .Out .Prompt (fmt .Sprintf ("Adding key value %s to list of env values" , kv ))
441
+ if ! keyIsEmpty && ! valIsEmpty {
438
442
envStaging = append (envStaging , kv )
439
443
} else {
440
- xc .Out .Prompt ( fmt .Sprintf ("Malformed env key/value (idx: %v kv: %s). Excluding from list " , i , kv ))
444
+ xc .Out .Error ( errType , fmt .Sprintf ("skipping malformed env var - (index=%d data='%s') " , i , kv ))
441
445
}
442
446
}
443
447
0 commit comments