From 02bc73f5eb2ed392aaffa510fbe1cfd392711d28 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sat, 6 Jan 2024 21:44:53 +0100 Subject: [PATCH] s3: minor code cleanups --- internal/backend/s3/s3.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/internal/backend/s3/s3.go b/internal/backend/s3/s3.go index d48813cf2..f0447224f 100644 --- a/internal/backend/s3/s3.go +++ b/internal/backend/s3/s3.go @@ -138,7 +138,7 @@ func getCredentials(cfg Config) (*credentials.Credentials, error) { // use the region provided by the configuration by default awsRegion := cfg.Region // allow the region to be overridden if for some reason it is required - if len(os.Getenv("RESTIC_AWS_ASSUME_ROLE_REGION")) > 0 { + if os.Getenv("RESTIC_AWS_ASSUME_ROLE_REGION") != "" { awsRegion = os.Getenv("RESTIC_AWS_ASSUME_ROLE_REGION") } @@ -148,7 +148,7 @@ func getCredentials(cfg Config) (*credentials.Credentials, error) { stsEndpoint := os.Getenv("RESTIC_AWS_ASSUME_ROLE_STS_ENDPOINT") if stsEndpoint == "" { - if len(awsRegion) > 0 { + if awsRegion != "" { if strings.HasPrefix(awsRegion, "cn-") { stsEndpoint = "https://sts." + awsRegion + ".amazonaws.com.cn" } else { @@ -167,9 +167,7 @@ func getCredentials(cfg Config) (*credentials.Credentials, error) { RoleSessionName: sessionName, ExternalID: externalID, Policy: policy, - } - if len(awsRegion) > 0 { - opts.Location = awsRegion + Location: awsRegion, } creds, err = credentials.NewSTSAssumeRole(stsEndpoint, opts)