in internal/client/client.go [57:99]
func getLoadOptions(ctx context.Context, pluginConfig map[string]string) []func(*config.LoadOptions) error {
log := logger.GetLogger(ctx)
var loadOptions []func(*config.LoadOptions) error
if customEndpoint, ok := pluginConfig[configKeySignerEndpoint]; ok {
customResolver := aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) {
if service == signer.ServiceID && customEndpoint != "" {
log.Debug("AWS Signer endpoint override: " + customEndpoint)
return aws.Endpoint{
PartitionID: "aws",
URL: customEndpoint,
SigningRegion: region,
}, nil
}
// returning EndpointNotFoundError will allow the service to fall back to its default resolution
return aws.Endpoint{}, &aws.EndpointNotFoundError{}
})
loadOptions = append(loadOptions, config.WithEndpointResolverWithOptions(customResolver))
}
if region, ok := pluginConfig[configKeyAwsRegion]; ok {
loadOptions = append(loadOptions, config.WithRegion(region))
log.Debugf("AWS Signer region override: %s\n", region)
}
if credentialProfile, ok := pluginConfig[configKeyAwsProfile]; ok {
loadOptions = append(loadOptions, config.WithSharedConfigProfile(credentialProfile))
log.Debugf("AWS Signer credential profile: %s\n", credentialProfile)
}
loadOptions = append(loadOptions, config.WithAPIOptions([]func(*middleware.Stack) error{
awsmiddleware.AddUserAgentKeyValue("aws-signer-caller", "NotationPlugin/"+version.GetVersion()),
}))
if log.IsDebug() {
loadOptions = append(loadOptions, config.WithClientLogMode(aws.LogRequestWithBody|aws.LogResponseWithBody))
loadOptions = append(loadOptions, config.WithLogConfigurationWarnings(true))
loadOptions = append(loadOptions, config.WithLogger(logging.LoggerFunc(func(_ logging.Classification, format string, v ...interface{}) {
log.Debugf("AWS call %s\n", fmt.Sprintf(format, v))
})))
}
return loadOptions
}