Skip to content

Commit

Permalink
chore: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra committed Aug 1, 2023
1 parent acd8f25 commit 6b70d3e
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions pkg/clients/aws/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,20 @@ func NewSession(ctx *context.Context, conn v1.AWSConnection) (*aws.Config, error
}
tr = logger.RoundTripper(tr)
}
cfg, err := config.LoadDefaultConfig(ctx, config.WithHTTPClient(&http.Client{Transport: tr}))

loadOptions := []func(*config.LoadOptions) error{
config.WithHTTPClient(&http.Client{Transport: tr}),
}
if conn.Endpoint != "" {
loadOptions = append(loadOptions,
config.WithEndpointResolverWithOptions(aws.EndpointResolverWithOptionsFunc(
func(service, region string, options ...interface{}) (aws.Endpoint, error) {
return aws.Endpoint{URL: conn.Endpoint}, nil
}),
),
)
}
cfg, err := config.LoadDefaultConfig(ctx, loadOptions...)

if !conn.AccessKey.IsEmpty() {
accessKey, err := ctx.GetEnvValueFromCache(conn.AccessKey)
Expand All @@ -52,12 +65,6 @@ func NewSession(ctx *context.Context, conn v1.AWSConnection) (*aws.Config, error
if conn.Region != "" {
cfg.Region = conn.Region
}
if conn.Endpoint != "" {
cfg.EndpointResolverWithOptions = aws.EndpointResolverWithOptionsFunc(
func(service, region string, options ...interface{}) (aws.Endpoint, error) {
return aws.Endpoint{URL: conn.Endpoint}, nil
})
}

return &cfg, err
}

0 comments on commit 6b70d3e

Please sign in to comment.