Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(aws*fs): Use BaseEndpoint for overriding endpoints #686

Merged
merged 1 commit into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion awssmfs/awssm.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,16 @@ func (f *awssmFS) getClient(ctx context.Context) (SecretsManagerClient, error) {
return nil, err
}

f.smclient = secretsmanager.NewFromConfig(cfg)
optFns := []func(*secretsmanager.Options){}

// setting a host in the URL is only intended for test purposes
if f.base.Host != "" {
optFns = append(optFns, func(o *secretsmanager.Options) {
o.BaseEndpoint = aws.String("http://" + f.base.Host)
})
}

f.smclient = secretsmanager.NewFromConfig(cfg, optFns...)

return f.smclient, nil
}
Expand Down
24 changes: 10 additions & 14 deletions awssmpfs/awssmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,25 +140,21 @@ func (f *awssmpFS) getClient(ctx context.Context) (SSMClient, error) {
opts = append(opts, config.WithHTTPClient(f.httpclient))
}

// setting a host in the URL is only intended for test purposes
if f.base.Host != "" {
customResolver := aws.EndpointResolverWithOptionsFunc(func(_, _ string, _ ...interface{}) (aws.Endpoint, error) {
return aws.Endpoint{
PartitionID: "aws",
URL: "http://" + f.base.Host,
SigningRegion: "us-east-1",
}, nil
})

opts = append(opts, config.WithEndpointResolverWithOptions(customResolver))
}

cfg, err := config.LoadDefaultConfig(ctx, opts...)
if err != nil {
return nil, err
}

f.ssmclient = ssm.NewFromConfig(cfg)
optFns := []func(*ssm.Options){}

// setting a host in the URL is only intended for test purposes
if f.base.Host != "" {
optFns = append(optFns, func(o *ssm.Options) {
o.BaseEndpoint = aws.String("http://" + f.base.Host)
})
}

f.ssmclient = ssm.NewFromConfig(cfg, optFns...)

return f.ssmclient, nil
}
Expand Down
Loading