From 328013667bd75e3056f1e24cbec39fadfd6fa656 Mon Sep 17 00:00:00 2001 From: "alban.stourbe stourbe" Date: Tue, 25 Mar 2025 14:40:25 +0100 Subject: [PATCH] feat(validateMissingS3Options): condition optimisation --- internal/runner/options.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/internal/runner/options.go b/internal/runner/options.go index a8eca738e..56612d153 100644 --- a/internal/runner/options.go +++ b/internal/runner/options.go @@ -236,18 +236,22 @@ func validateMissingS3Options(options *types.Options) []string { missing = append(missing, "AWS_TEMPLATE_BUCKET") } if options.AwsProfile == "" { + var missingCreds []string if options.AwsAccessKey == "" { - missing = append(missing, "AWS_ACCESS_KEY") + missingCreds = append(missingCreds, "AWS_ACCESS_KEY") } if options.AwsSecretKey == "" { - missing = append(missing, "AWS_SECRET_KEY") + missingCreds = append(missingCreds, "AWS_SECRET_KEY") } if options.AwsRegion == "" { - missing = append(missing, "AWS_REGION") + missingCreds = append(missingCreds, "AWS_REGION") + } + + missing = append(missing, missingCreds...) + + if len(missingCreds) > 0 { + missing = append(missing, "AWS_PROFILE") } - } - if (options.AwsAccessKey == "" || options.AwsSecretKey == "" || options.AwsRegion == "") && options.AwsProfile == "" { - missing = append(missing, "AWS_PROFILE") } return missing