Skip to content

Commit 3280136

Browse files
feat(validateMissingS3Options): condition optimisation
1 parent e35c604 commit 3280136

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

internal/runner/options.go

+10-6
Original file line numberDiff line numberDiff line change
@@ -236,18 +236,22 @@ func validateMissingS3Options(options *types.Options) []string {
236236
missing = append(missing, "AWS_TEMPLATE_BUCKET")
237237
}
238238
if options.AwsProfile == "" {
239+
var missingCreds []string
239240
if options.AwsAccessKey == "" {
240-
missing = append(missing, "AWS_ACCESS_KEY")
241+
missingCreds = append(missingCreds, "AWS_ACCESS_KEY")
241242
}
242243
if options.AwsSecretKey == "" {
243-
missing = append(missing, "AWS_SECRET_KEY")
244+
missingCreds = append(missingCreds, "AWS_SECRET_KEY")
244245
}
245246
if options.AwsRegion == "" {
246-
missing = append(missing, "AWS_REGION")
247+
missingCreds = append(missingCreds, "AWS_REGION")
248+
}
249+
250+
missing = append(missing, missingCreds...)
251+
252+
if len(missingCreds) > 0 {
253+
missing = append(missing, "AWS_PROFILE")
247254
}
248-
}
249-
if (options.AwsAccessKey == "" || options.AwsSecretKey == "" || options.AwsRegion == "") && options.AwsProfile == "" {
250-
missing = append(missing, "AWS_PROFILE")
251255
}
252256

253257
return missing

0 commit comments

Comments
 (0)