Skip to content

Commit

Permalink
Fix how the options slice is created
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
  • Loading branch information
frouioui committed Dec 2, 2024
1 parent 94a89c5 commit bde043b
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions go/vt/mysqlctl/s3backupstorage/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"time"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/aws/retry"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/feature/s3/manager"
"github.com/aws/aws-sdk-go-v2/service/s3"
Expand Down Expand Up @@ -505,17 +506,24 @@ func (bs *S3BackupStorage) client() (*s3.Client, error) {
return nil, err
}

var endpointResolverV2 func(options *s3.Options) = nil
options := []func(options *s3.Options){
func(o *s3.Options) {
o.UsePathStyle = forcePath
if retryCount >= 0 {
o.RetryMaxAttempts = retryCount
o.Retryer = &ClosedConnectionRetryer{
awsRetryer: retry.NewStandard(func(options *retry.StandardOptions) {
options.MaxAttempts = retryCount
}),
}
}
},
}
if endpoint != "" {
endpointResolverV2 = s3.WithEndpointResolverV2(newEndpointResolver())
options = append(options, s3.WithEndpointResolverV2(newEndpointResolver()))
}
bs._client = s3.NewFromConfig(cfg, func(o *s3.Options) {
o.UsePathStyle = forcePath
if retryCount >= 0 {
o.RetryMaxAttempts = retryCount
o.Retryer = &ClosedConnectionRetryer{}
}
}, endpointResolverV2)

bs._client = s3.NewFromConfig(cfg, options...)

if len(bucket) == 0 {
return nil, fmt.Errorf("--s3_backup_storage_bucket required")
Expand Down

0 comments on commit bde043b

Please sign in to comment.