Skip to content

Commit

Permalink
chore: update s3 config
Browse files Browse the repository at this point in the history
  • Loading branch information
boojack committed Jun 11, 2024
1 parent e9d027c commit 387bf48
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions plugin/storage/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,17 @@ type Client struct {
}

func NewClient(ctx context.Context, s3Config *storepb.StorageS3Config) (*Client, error) {
resolver := aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...any) (aws.Endpoint, error) {
return aws.Endpoint{
URL: s3Config.Endpoint,
}, nil
})
cfg, err := config.LoadDefaultConfig(ctx,
config.WithEndpointResolverWithOptions(resolver),
config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(s3Config.AccessKeyId, s3Config.AccessKeySecret, "")),
config.WithRegion(s3Config.Region),
)
if err != nil {
return nil, errors.Wrap(err, "failed to load s3 config")
}

client := s3.NewFromConfig(cfg)
client := s3.NewFromConfig(cfg, func(o *s3.Options) {
o.BaseEndpoint = aws.String(s3Config.Endpoint)
})
return &Client{
Client: client,
Bucket: aws.String(s3Config.Bucket),
Expand Down

0 comments on commit 387bf48

Please sign in to comment.