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

Adds IgnoreConfiguredEndpoints and BaseEndpoint to config.LoadOptions #2425

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 46 additions & 1 deletion config/load_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ type LoadOptions struct {
// The sdk app ID retrieved from env var or shared config to be added to request user agent header
AppID string

// Flag used to disable configured endpoints.
IgnoreConfiguredEndpoints *bool

// Value to contain configured endpoints to be propagated to
// corresponding endpoint resolution field.
BaseEndpoint string

// Specifies whether an operation request could be compressed
DisableRequestCompression *bool

Expand Down Expand Up @@ -1095,7 +1102,7 @@ func WithDefaultsMode(mode aws.DefaultsMode, optFns ...func(options *DefaultsMod
}

// GetS3DisableExpressAuth returns the configured value for
// [EnvConfig.S3DisableExpressAuth].
// [LoadOptions.S3DisableExpressAuth].
func (o LoadOptions) GetS3DisableExpressAuth() (value, ok bool) {
if o.S3DisableExpressAuth == nil {
return false, false
Expand All @@ -1112,3 +1119,41 @@ func WithS3DisableExpressAuth(v bool) LoadOptionsFunc {
return nil
}
}

// GetIgnoreConfiguredEndpoints is used in knowing when to disable configured
// endpoints feature.
func (o LoadOptions) GetIgnoreConfiguredEndpoints(context.Context) (bool, bool, error) {
if o.IgnoreConfiguredEndpoints == nil {
return false, false, nil
}

return *o.IgnoreConfiguredEndpoints, true, nil
}

// WithIgnoreConfiguredEndpoints is a helper function to construct functional options
// that sets IgnoreConfiguredEndpoints on config's LoadOptions.
// If multiple WithIgnoreConfiguredEndpoints calls are made, the last call overrides
// the previous call values.
func WithIgnoreConfiguredEndpoints(v bool) LoadOptionsFunc {
return func(o *LoadOptions) error {
o.IgnoreConfiguredEndpoints = &v
return nil
}
}

func (o LoadOptions) getBaseEndpoint(context.Context) (string, bool, error) {
return o.BaseEndpoint, len(o.BaseEndpoint) > 0, nil
}

// WithBaseEndpoint is a helper function to construct functional options
// that sets BaseEndpoint on config's LoadOptions. Setting the base
// endpoint to an empty string will result in the endpoint
// value being ignored.
// If multiple WithBaseEndpoint calls are made, the last call overrides
// the previous call values.
func WithBaseEndpoint(v string) LoadOptionsFunc {
return func(o *LoadOptions) error {
o.BaseEndpoint = v
return nil
}
}