src

Go monorepo.
git clone git://code.dwrz.net/src
Log | Files | Refs

load_options.go (50660B)


      1 package config
      2 
      3 import (
      4 	"context"
      5 	"io"
      6 
      7 	"github.com/aws/aws-sdk-go-v2/aws"
      8 	"github.com/aws/aws-sdk-go-v2/credentials/ec2rolecreds"
      9 	"github.com/aws/aws-sdk-go-v2/credentials/endpointcreds"
     10 	"github.com/aws/aws-sdk-go-v2/credentials/processcreds"
     11 	"github.com/aws/aws-sdk-go-v2/credentials/ssocreds"
     12 	"github.com/aws/aws-sdk-go-v2/credentials/stscreds"
     13 	"github.com/aws/aws-sdk-go-v2/feature/ec2/imds"
     14 	smithybearer "github.com/aws/smithy-go/auth/bearer"
     15 	"github.com/aws/smithy-go/logging"
     16 	"github.com/aws/smithy-go/middleware"
     17 	smithyhttp "github.com/aws/smithy-go/transport/http"
     18 )
     19 
     20 // LoadOptionsFunc is a type alias for LoadOptions functional option
     21 type LoadOptionsFunc func(*LoadOptions) error
     22 
     23 // LoadOptions are discrete set of options that are valid for loading the
     24 // configuration
     25 type LoadOptions struct {
     26 
     27 	// Region is the region to send requests to.
     28 	Region string
     29 
     30 	// Credentials object to use when signing requests.
     31 	Credentials aws.CredentialsProvider
     32 
     33 	// Token provider for authentication operations with bearer authentication.
     34 	BearerAuthTokenProvider smithybearer.TokenProvider
     35 
     36 	// HTTPClient the SDK's API clients will use to invoke HTTP requests.
     37 	HTTPClient HTTPClient
     38 
     39 	// EndpointResolver that can be used to provide or override an endpoint for
     40 	// the given service and region.
     41 	//
     42 	// See the `aws.EndpointResolver` documentation on usage.
     43 	//
     44 	// Deprecated: See EndpointResolverWithOptions
     45 	EndpointResolver aws.EndpointResolver
     46 
     47 	// EndpointResolverWithOptions that can be used to provide or override an
     48 	// endpoint for the given service and region.
     49 	//
     50 	// See the `aws.EndpointResolverWithOptions` documentation on usage.
     51 	EndpointResolverWithOptions aws.EndpointResolverWithOptions
     52 
     53 	// RetryMaxAttempts specifies the maximum number attempts an API client
     54 	// will call an operation that fails with a retryable error.
     55 	//
     56 	// This value will only be used if Retryer option is nil.
     57 	RetryMaxAttempts int
     58 
     59 	// RetryMode specifies the retry model the API client will be created with.
     60 	//
     61 	// This value will only be used if Retryer option is nil.
     62 	RetryMode aws.RetryMode
     63 
     64 	// Retryer is a function that provides a Retryer implementation. A Retryer
     65 	// guides how HTTP requests should be retried in case of recoverable
     66 	// failures.
     67 	//
     68 	// If not nil, RetryMaxAttempts, and RetryMode will be ignored.
     69 	Retryer func() aws.Retryer
     70 
     71 	// APIOptions provides the set of middleware mutations modify how the API
     72 	// client requests will be handled. This is useful for adding additional
     73 	// tracing data to a request, or changing behavior of the SDK's client.
     74 	APIOptions []func(*middleware.Stack) error
     75 
     76 	// Logger writer interface to write logging messages to.
     77 	Logger logging.Logger
     78 
     79 	// ClientLogMode is used to configure the events that will be sent to the
     80 	// configured logger. This can be used to configure the logging of signing,
     81 	// retries, request, and responses of the SDK clients.
     82 	//
     83 	// See the ClientLogMode type documentation for the complete set of logging
     84 	// modes and available configuration.
     85 	ClientLogMode *aws.ClientLogMode
     86 
     87 	// SharedConfigProfile is the profile to be used when loading the SharedConfig
     88 	SharedConfigProfile string
     89 
     90 	// SharedConfigFiles is the slice of custom shared config files to use when
     91 	// loading the SharedConfig. A non-default profile used within config file
     92 	// must have name defined with prefix 'profile '. eg [profile xyz]
     93 	// indicates a profile with name 'xyz'. To read more on the format of the
     94 	// config file, please refer the documentation at
     95 	// https://docs.aws.amazon.com/credref/latest/refdocs/file-format.html#file-format-config
     96 	//
     97 	// If duplicate profiles are provided within the same, or across multiple
     98 	// shared config files, the next parsed profile will override only the
     99 	// properties that conflict with the previously defined profile. Note that
    100 	// if duplicate profiles are provided within the SharedCredentialsFiles and
    101 	// SharedConfigFiles, the properties defined in shared credentials file
    102 	// take precedence.
    103 	SharedConfigFiles []string
    104 
    105 	// SharedCredentialsFile is the slice of custom shared credentials files to
    106 	// use when loading the SharedConfig. The profile name used within
    107 	// credentials file must not prefix 'profile '. eg [xyz] indicates a
    108 	// profile with name 'xyz'. Profile declared as [profile xyz] will be
    109 	// ignored. To read more on the format of the credentials file, please
    110 	// refer the documentation at
    111 	// https://docs.aws.amazon.com/credref/latest/refdocs/file-format.html#file-format-creds
    112 	//
    113 	// If duplicate profiles are provided with a same, or across multiple
    114 	// shared credentials files, the next parsed profile will override only
    115 	// properties that conflict with the previously defined profile. Note that
    116 	// if duplicate profiles are provided within the SharedCredentialsFiles and
    117 	// SharedConfigFiles, the properties defined in shared credentials file
    118 	// take precedence.
    119 	SharedCredentialsFiles []string
    120 
    121 	// CustomCABundle is CA bundle PEM bytes reader
    122 	CustomCABundle io.Reader
    123 
    124 	// DefaultRegion is the fall back region, used if a region was not resolved
    125 	// from other sources
    126 	DefaultRegion string
    127 
    128 	// UseEC2IMDSRegion indicates if SDK should retrieve the region
    129 	// from the EC2 Metadata service
    130 	UseEC2IMDSRegion *UseEC2IMDSRegion
    131 
    132 	// CredentialsCacheOptions is a function for setting the
    133 	// aws.CredentialsCacheOptions
    134 	CredentialsCacheOptions func(*aws.CredentialsCacheOptions)
    135 
    136 	// BearerAuthTokenCacheOptions is a function for setting the smithy-go
    137 	// auth/bearer#TokenCacheOptions
    138 	BearerAuthTokenCacheOptions func(*smithybearer.TokenCacheOptions)
    139 
    140 	// SSOTokenProviderOptions is a function for setting the
    141 	// credentials/ssocreds.SSOTokenProviderOptions
    142 	SSOTokenProviderOptions func(*ssocreds.SSOTokenProviderOptions)
    143 
    144 	// ProcessCredentialOptions is a function for setting
    145 	// the processcreds.Options
    146 	ProcessCredentialOptions func(*processcreds.Options)
    147 
    148 	// EC2RoleCredentialOptions is a function for setting
    149 	// the ec2rolecreds.Options
    150 	EC2RoleCredentialOptions func(*ec2rolecreds.Options)
    151 
    152 	// EndpointCredentialOptions is a function for setting
    153 	// the endpointcreds.Options
    154 	EndpointCredentialOptions func(*endpointcreds.Options)
    155 
    156 	// WebIdentityRoleCredentialOptions is a function for setting
    157 	// the stscreds.WebIdentityRoleOptions
    158 	WebIdentityRoleCredentialOptions func(*stscreds.WebIdentityRoleOptions)
    159 
    160 	// AssumeRoleCredentialOptions is a function for setting the
    161 	// stscreds.AssumeRoleOptions
    162 	AssumeRoleCredentialOptions func(*stscreds.AssumeRoleOptions)
    163 
    164 	// SSOProviderOptions is a function for setting
    165 	// the ssocreds.Options
    166 	SSOProviderOptions func(options *ssocreds.Options)
    167 
    168 	// LogConfigurationWarnings when set to true, enables logging
    169 	// configuration warnings
    170 	LogConfigurationWarnings *bool
    171 
    172 	// S3UseARNRegion specifies if the S3 service should allow ARNs to direct
    173 	// the region, the client's requests are sent to.
    174 	S3UseARNRegion *bool
    175 
    176 	// S3DisableMultiRegionAccessPoints specifies if the S3 service should disable
    177 	// the S3 Multi-Region access points feature.
    178 	S3DisableMultiRegionAccessPoints *bool
    179 
    180 	// EnableEndpointDiscovery specifies if endpoint discovery is enable for
    181 	// the client.
    182 	EnableEndpointDiscovery aws.EndpointDiscoveryEnableState
    183 
    184 	// Specifies if the EC2 IMDS service client is enabled.
    185 	//
    186 	// AWS_EC2_METADATA_DISABLED=true
    187 	EC2IMDSClientEnableState imds.ClientEnableState
    188 
    189 	// Specifies the EC2 Instance Metadata Service default endpoint selection
    190 	// mode (IPv4 or IPv6)
    191 	EC2IMDSEndpointMode imds.EndpointModeState
    192 
    193 	// Specifies the EC2 Instance Metadata Service endpoint to use. If
    194 	// specified it overrides EC2IMDSEndpointMode.
    195 	EC2IMDSEndpoint string
    196 
    197 	// Specifies that SDK clients must resolve a dual-stack endpoint for
    198 	// services.
    199 	UseDualStackEndpoint aws.DualStackEndpointState
    200 
    201 	// Specifies that SDK clients must resolve a FIPS endpoint for
    202 	// services.
    203 	UseFIPSEndpoint aws.FIPSEndpointState
    204 
    205 	// Specifies the SDK configuration mode for defaults.
    206 	DefaultsModeOptions DefaultsModeOptions
    207 
    208 	// The sdk app ID retrieved from env var or shared config to be added to request user agent header
    209 	AppID string
    210 
    211 	// Specifies whether an operation request could be compressed
    212 	DisableRequestCompression *bool
    213 
    214 	// The inclusive min bytes of a request body that could be compressed
    215 	RequestMinCompressSizeBytes *int64
    216 
    217 	// Specifies whether SDK clock skew correction is disabled
    218 	DisableClockSkewCorrection *bool
    219 
    220 	// Whether S3 Express auth is disabled.
    221 	S3DisableExpressAuth *bool
    222 
    223 	// Whether account id should be built into endpoint resolution
    224 	AccountIDEndpointMode aws.AccountIDEndpointMode
    225 
    226 	// Specify if request checksum should be calculated
    227 	RequestChecksumCalculation aws.RequestChecksumCalculation
    228 
    229 	// Specifies if response checksum should be validated
    230 	ResponseChecksumValidation aws.ResponseChecksumValidation
    231 
    232 	// Service endpoint override. This value is not necessarily final and is
    233 	// passed to the service's EndpointResolverV2 for further delegation.
    234 	BaseEndpoint string
    235 
    236 	// Registry of operation interceptors.
    237 	Interceptors smithyhttp.InterceptorRegistry
    238 
    239 	// Priority list of preferred auth scheme names (e.g. sigv4a).
    240 	AuthSchemePreference []string
    241 
    242 	// ServiceOptions provides service specific configuration options that will be applied
    243 	// when constructing clients for specific services. Each callback function receives the service ID
    244 	// and the service's Options struct, allowing for dynamic configuration based on the service.
    245 	ServiceOptions []func(string, any)
    246 
    247 	// Controls whether the SDK restricts file permissions on credential
    248 	// cache files it creates.
    249 	RestrictFilePermissions aws.RestrictFilePermissions
    250 }
    251 
    252 func (o LoadOptions) getDefaultsMode(ctx context.Context) (aws.DefaultsMode, bool, error) {
    253 	if len(o.DefaultsModeOptions.Mode) == 0 {
    254 		return "", false, nil
    255 	}
    256 	return o.DefaultsModeOptions.Mode, true, nil
    257 }
    258 
    259 // GetRetryMaxAttempts returns the RetryMaxAttempts if specified in the
    260 // LoadOptions and not 0.
    261 func (o LoadOptions) GetRetryMaxAttempts(ctx context.Context) (int, bool, error) {
    262 	if o.RetryMaxAttempts == 0 {
    263 		return 0, false, nil
    264 	}
    265 	return o.RetryMaxAttempts, true, nil
    266 }
    267 
    268 // GetRetryMode returns the RetryMode specified in the LoadOptions.
    269 func (o LoadOptions) GetRetryMode(ctx context.Context) (aws.RetryMode, bool, error) {
    270 	if len(o.RetryMode) == 0 {
    271 		return "", false, nil
    272 	}
    273 	return o.RetryMode, true, nil
    274 }
    275 
    276 func (o LoadOptions) getDefaultsModeIMDSClient(ctx context.Context) (*imds.Client, bool, error) {
    277 	if o.DefaultsModeOptions.IMDSClient == nil {
    278 		return nil, false, nil
    279 	}
    280 	return o.DefaultsModeOptions.IMDSClient, true, nil
    281 }
    282 
    283 // getRegion returns Region from config's LoadOptions
    284 func (o LoadOptions) getRegion(ctx context.Context) (string, bool, error) {
    285 	if len(o.Region) == 0 {
    286 		return "", false, nil
    287 	}
    288 
    289 	return o.Region, true, nil
    290 }
    291 
    292 // getAppID returns AppID from config's LoadOptions
    293 func (o LoadOptions) getAppID(ctx context.Context) (string, bool, error) {
    294 	return o.AppID, len(o.AppID) > 0, nil
    295 }
    296 
    297 // getDisableRequestCompression returns DisableRequestCompression from config's LoadOptions
    298 func (o LoadOptions) getDisableRequestCompression(ctx context.Context) (bool, bool, error) {
    299 	if o.DisableRequestCompression == nil {
    300 		return false, false, nil
    301 	}
    302 	return *o.DisableRequestCompression, true, nil
    303 }
    304 
    305 // getDisableClockSkewCorrection returns DisableClockSkewCorrection from config's LoadOptions
    306 func (o LoadOptions) getDisableClockSkewCorrection(ctx context.Context) (bool, bool, error) {
    307 	if o.DisableClockSkewCorrection == nil {
    308 		return false, false, nil
    309 	}
    310 	return *o.DisableClockSkewCorrection, true, nil
    311 }
    312 
    313 // getRequestMinCompressSizeBytes returns RequestMinCompressSizeBytes from config's LoadOptions
    314 func (o LoadOptions) getRequestMinCompressSizeBytes(ctx context.Context) (int64, bool, error) {
    315 	if o.RequestMinCompressSizeBytes == nil {
    316 		return 0, false, nil
    317 	}
    318 	return *o.RequestMinCompressSizeBytes, true, nil
    319 }
    320 
    321 func (o LoadOptions) getAccountIDEndpointMode(ctx context.Context) (aws.AccountIDEndpointMode, bool, error) {
    322 	return o.AccountIDEndpointMode, len(o.AccountIDEndpointMode) > 0, nil
    323 }
    324 
    325 func (o LoadOptions) getRequestChecksumCalculation(ctx context.Context) (aws.RequestChecksumCalculation, bool, error) {
    326 	return o.RequestChecksumCalculation, o.RequestChecksumCalculation > 0, nil
    327 }
    328 
    329 func (o LoadOptions) getResponseChecksumValidation(ctx context.Context) (aws.ResponseChecksumValidation, bool, error) {
    330 	return o.ResponseChecksumValidation, o.ResponseChecksumValidation > 0, nil
    331 }
    332 
    333 func (o LoadOptions) getBaseEndpoint(context.Context) (string, bool, error) {
    334 	return o.BaseEndpoint, o.BaseEndpoint != "", nil
    335 }
    336 
    337 func (o LoadOptions) getServiceOptions(context.Context) ([]func(string, any), bool, error) {
    338 	return o.ServiceOptions, len(o.ServiceOptions) > 0, nil
    339 }
    340 
    341 // GetServiceBaseEndpoint satisfies (internal/configsources).ServiceBaseEndpointProvider.
    342 //
    343 // The sdkID value is unused because LoadOptions only supports setting a GLOBAL
    344 // endpoint override. In-code, per-service endpoint overrides are performed via
    345 // functional options in service client space.
    346 func (o LoadOptions) GetServiceBaseEndpoint(context.Context, string) (string, bool, error) {
    347 	return o.BaseEndpoint, o.BaseEndpoint != "", nil
    348 }
    349 
    350 // WithRegion is a helper function to construct functional options
    351 // that sets Region on config's LoadOptions. Setting the region to
    352 // an empty string, will result in the region value being ignored.
    353 // If multiple WithRegion calls are made, the last call overrides
    354 // the previous call values.
    355 func WithRegion(v string) LoadOptionsFunc {
    356 	return func(o *LoadOptions) error {
    357 		o.Region = v
    358 		return nil
    359 	}
    360 }
    361 
    362 // WithAppID is a helper function to construct functional options
    363 // that sets AppID on config's LoadOptions.
    364 func WithAppID(ID string) LoadOptionsFunc {
    365 	return func(o *LoadOptions) error {
    366 		o.AppID = ID
    367 		return nil
    368 	}
    369 }
    370 
    371 // WithDisableRequestCompression is a helper function to construct functional options
    372 // that sets DisableRequestCompression on config's LoadOptions.
    373 func WithDisableRequestCompression(DisableRequestCompression *bool) LoadOptionsFunc {
    374 	return func(o *LoadOptions) error {
    375 		if DisableRequestCompression == nil {
    376 			return nil
    377 		}
    378 		o.DisableRequestCompression = DisableRequestCompression
    379 		return nil
    380 	}
    381 }
    382 
    383 // WithDisableClockSkewCorrection is a helper function to construct functional
    384 // options that sets DisableClockSkewCorrection on config's LoadOptions.
    385 func WithDisableClockSkewCorrection(DisableClockSkewCorrection *bool) LoadOptionsFunc {
    386 	return func(o *LoadOptions) error {
    387 		if DisableClockSkewCorrection == nil {
    388 			return nil
    389 		}
    390 		o.DisableClockSkewCorrection = DisableClockSkewCorrection
    391 		return nil
    392 	}
    393 }
    394 
    395 // WithRequestMinCompressSizeBytes is a helper function to construct functional options
    396 // that sets RequestMinCompressSizeBytes on config's LoadOptions.
    397 func WithRequestMinCompressSizeBytes(RequestMinCompressSizeBytes *int64) LoadOptionsFunc {
    398 	return func(o *LoadOptions) error {
    399 		if RequestMinCompressSizeBytes == nil {
    400 			return nil
    401 		}
    402 		o.RequestMinCompressSizeBytes = RequestMinCompressSizeBytes
    403 		return nil
    404 	}
    405 }
    406 
    407 // WithAccountIDEndpointMode is a helper function to construct functional options
    408 // that sets AccountIDEndpointMode on config's LoadOptions
    409 func WithAccountIDEndpointMode(m aws.AccountIDEndpointMode) LoadOptionsFunc {
    410 	return func(o *LoadOptions) error {
    411 		if m != "" {
    412 			o.AccountIDEndpointMode = m
    413 		}
    414 		return nil
    415 	}
    416 }
    417 
    418 // WithRequestChecksumCalculation is a helper function to construct functional options
    419 // that sets RequestChecksumCalculation on config's LoadOptions
    420 func WithRequestChecksumCalculation(c aws.RequestChecksumCalculation) LoadOptionsFunc {
    421 	return func(o *LoadOptions) error {
    422 		if c > 0 {
    423 			o.RequestChecksumCalculation = c
    424 		}
    425 		return nil
    426 	}
    427 }
    428 
    429 // WithResponseChecksumValidation is a helper function to construct functional options
    430 // that sets ResponseChecksumValidation on config's LoadOptions
    431 func WithResponseChecksumValidation(v aws.ResponseChecksumValidation) LoadOptionsFunc {
    432 	return func(o *LoadOptions) error {
    433 		o.ResponseChecksumValidation = v
    434 		return nil
    435 	}
    436 }
    437 
    438 // getDefaultRegion returns DefaultRegion from config's LoadOptions
    439 func (o LoadOptions) getDefaultRegion(ctx context.Context) (string, bool, error) {
    440 	if len(o.DefaultRegion) == 0 {
    441 		return "", false, nil
    442 	}
    443 
    444 	return o.DefaultRegion, true, nil
    445 }
    446 
    447 // WithDefaultRegion is a helper function to construct functional options
    448 // that sets a DefaultRegion on config's LoadOptions. Setting the default
    449 // region to an empty string, will result in the default region value
    450 // being ignored. If multiple WithDefaultRegion calls are made, the last
    451 // call overrides the previous call values. Note that both WithRegion and
    452 // WithEC2IMDSRegion call takes precedence over WithDefaultRegion call
    453 // when resolving region.
    454 func WithDefaultRegion(v string) LoadOptionsFunc {
    455 	return func(o *LoadOptions) error {
    456 		o.DefaultRegion = v
    457 		return nil
    458 	}
    459 }
    460 
    461 // getSharedConfigProfile returns SharedConfigProfile from config's LoadOptions
    462 func (o LoadOptions) getSharedConfigProfile(ctx context.Context) (string, bool, error) {
    463 	if len(o.SharedConfigProfile) == 0 {
    464 		return "", false, nil
    465 	}
    466 
    467 	return o.SharedConfigProfile, true, nil
    468 }
    469 
    470 // WithSharedConfigProfile is a helper function to construct functional options
    471 // that sets SharedConfigProfile on config's LoadOptions. Setting the shared
    472 // config profile to an empty string, will result in the shared config profile
    473 // value being ignored.
    474 // If multiple WithSharedConfigProfile calls are made, the last call overrides
    475 // the previous call values.
    476 func WithSharedConfigProfile(v string) LoadOptionsFunc {
    477 	return func(o *LoadOptions) error {
    478 		o.SharedConfigProfile = v
    479 		return nil
    480 	}
    481 }
    482 
    483 // getSharedConfigFiles returns SharedConfigFiles set on config's LoadOptions
    484 func (o LoadOptions) getSharedConfigFiles(ctx context.Context) ([]string, bool, error) {
    485 	if o.SharedConfigFiles == nil {
    486 		return nil, false, nil
    487 	}
    488 
    489 	return o.SharedConfigFiles, true, nil
    490 }
    491 
    492 // WithSharedConfigFiles is a helper function to construct functional options
    493 // that sets slice of SharedConfigFiles on config's LoadOptions.
    494 // Setting the shared config files to an nil string slice, will result in the
    495 // shared config files value being ignored.
    496 // If multiple WithSharedConfigFiles calls are made, the last call overrides
    497 // the previous call values.
    498 func WithSharedConfigFiles(v []string) LoadOptionsFunc {
    499 	return func(o *LoadOptions) error {
    500 		o.SharedConfigFiles = v
    501 		return nil
    502 	}
    503 }
    504 
    505 // getSharedCredentialsFiles returns SharedCredentialsFiles set on config's LoadOptions
    506 func (o LoadOptions) getSharedCredentialsFiles(ctx context.Context) ([]string, bool, error) {
    507 	if o.SharedCredentialsFiles == nil {
    508 		return nil, false, nil
    509 	}
    510 
    511 	return o.SharedCredentialsFiles, true, nil
    512 }
    513 
    514 // WithSharedCredentialsFiles is a helper function to construct functional options
    515 // that sets slice of SharedCredentialsFiles on config's LoadOptions.
    516 // Setting the shared credentials files to an nil string slice, will result in the
    517 // shared credentials files value being ignored.
    518 // If multiple WithSharedCredentialsFiles calls are made, the last call overrides
    519 // the previous call values.
    520 func WithSharedCredentialsFiles(v []string) LoadOptionsFunc {
    521 	return func(o *LoadOptions) error {
    522 		o.SharedCredentialsFiles = v
    523 		return nil
    524 	}
    525 }
    526 
    527 // getCustomCABundle returns CustomCABundle from LoadOptions
    528 func (o LoadOptions) getCustomCABundle(ctx context.Context) (io.Reader, bool, error) {
    529 	if o.CustomCABundle == nil {
    530 		return nil, false, nil
    531 	}
    532 
    533 	return o.CustomCABundle, true, nil
    534 }
    535 
    536 // WithCustomCABundle is a helper function to construct functional options
    537 // that sets CustomCABundle on config's LoadOptions. Setting the custom CA Bundle
    538 // to nil will result in custom CA Bundle value being ignored.
    539 // If multiple WithCustomCABundle calls are made, the last call overrides the
    540 // previous call values.
    541 func WithCustomCABundle(v io.Reader) LoadOptionsFunc {
    542 	return func(o *LoadOptions) error {
    543 		o.CustomCABundle = v
    544 		return nil
    545 	}
    546 }
    547 
    548 // UseEC2IMDSRegion provides a regionProvider that retrieves the region
    549 // from the EC2 Metadata service.
    550 type UseEC2IMDSRegion struct {
    551 	// If unset will default to generic EC2 IMDS client.
    552 	Client *imds.Client
    553 }
    554 
    555 // getRegion attempts to retrieve the region from EC2 Metadata service.
    556 func (p *UseEC2IMDSRegion) getRegion(ctx context.Context) (string, bool, error) {
    557 	if ctx == nil {
    558 		ctx = context.Background()
    559 	}
    560 
    561 	client := p.Client
    562 	if client == nil {
    563 		client = imds.New(imds.Options{})
    564 	}
    565 
    566 	result, err := client.GetRegion(ctx, nil)
    567 	if err != nil {
    568 		return "", false, err
    569 	}
    570 	if len(result.Region) != 0 {
    571 		return result.Region, true, nil
    572 	}
    573 	return "", false, nil
    574 }
    575 
    576 // getEC2IMDSRegion returns the value of EC2 IMDS region.
    577 func (o LoadOptions) getEC2IMDSRegion(ctx context.Context) (string, bool, error) {
    578 	if o.UseEC2IMDSRegion == nil {
    579 		return "", false, nil
    580 	}
    581 
    582 	return o.UseEC2IMDSRegion.getRegion(ctx)
    583 }
    584 
    585 // WithEC2IMDSRegion is a helper function to construct functional options
    586 // that enables resolving EC2IMDS region. The function takes
    587 // in a UseEC2IMDSRegion functional option, and can be used to set the
    588 // EC2IMDS client which will be used to resolve EC2IMDSRegion.
    589 // If no functional option is provided, an EC2IMDS client is built and used
    590 // by the resolver. If multiple WithEC2IMDSRegion calls are made, the last
    591 // call overrides the previous call values. Note that the WithRegion calls takes
    592 // precedence over WithEC2IMDSRegion when resolving region.
    593 func WithEC2IMDSRegion(fnOpts ...func(o *UseEC2IMDSRegion)) LoadOptionsFunc {
    594 	return func(o *LoadOptions) error {
    595 		o.UseEC2IMDSRegion = &UseEC2IMDSRegion{}
    596 
    597 		for _, fn := range fnOpts {
    598 			fn(o.UseEC2IMDSRegion)
    599 		}
    600 		return nil
    601 	}
    602 }
    603 
    604 // getCredentialsProvider returns the credentials value
    605 func (o LoadOptions) getCredentialsProvider(ctx context.Context) (aws.CredentialsProvider, bool, error) {
    606 	if o.Credentials == nil {
    607 		return nil, false, nil
    608 	}
    609 
    610 	return o.Credentials, true, nil
    611 }
    612 
    613 // WithCredentialsProvider is a helper function to construct functional options
    614 // that sets Credential provider value on config's LoadOptions. If credentials
    615 // provider is set to nil, the credentials provider value will be ignored.
    616 // If multiple WithCredentialsProvider calls are made, the last call overrides
    617 // the previous call values.
    618 func WithCredentialsProvider(v aws.CredentialsProvider) LoadOptionsFunc {
    619 	return func(o *LoadOptions) error {
    620 		o.Credentials = v
    621 		return nil
    622 	}
    623 }
    624 
    625 // getCredentialsCacheOptionsProvider returns the wrapped function to set aws.CredentialsCacheOptions
    626 func (o LoadOptions) getCredentialsCacheOptions(ctx context.Context) (func(*aws.CredentialsCacheOptions), bool, error) {
    627 	if o.CredentialsCacheOptions == nil {
    628 		return nil, false, nil
    629 	}
    630 
    631 	return o.CredentialsCacheOptions, true, nil
    632 }
    633 
    634 // WithCredentialsCacheOptions is a helper function to construct functional
    635 // options that sets a function to modify the aws.CredentialsCacheOptions the
    636 // aws.CredentialsCache will be configured with, if the CredentialsCache is used
    637 // by the configuration loader.
    638 //
    639 // If multiple WithCredentialsCacheOptions calls are made, the last call
    640 // overrides the previous call values.
    641 func WithCredentialsCacheOptions(v func(*aws.CredentialsCacheOptions)) LoadOptionsFunc {
    642 	return func(o *LoadOptions) error {
    643 		o.CredentialsCacheOptions = v
    644 		return nil
    645 	}
    646 }
    647 
    648 // getBearerAuthTokenProvider returns the credentials value
    649 func (o LoadOptions) getBearerAuthTokenProvider(ctx context.Context) (smithybearer.TokenProvider, bool, error) {
    650 	if o.BearerAuthTokenProvider == nil {
    651 		return nil, false, nil
    652 	}
    653 
    654 	return o.BearerAuthTokenProvider, true, nil
    655 }
    656 
    657 // WithBearerAuthTokenProvider is a helper function to construct functional options
    658 // that sets Credential provider value on config's LoadOptions. If credentials
    659 // provider is set to nil, the credentials provider value will be ignored.
    660 // If multiple WithBearerAuthTokenProvider calls are made, the last call overrides
    661 // the previous call values.
    662 func WithBearerAuthTokenProvider(v smithybearer.TokenProvider) LoadOptionsFunc {
    663 	return func(o *LoadOptions) error {
    664 		o.BearerAuthTokenProvider = v
    665 		return nil
    666 	}
    667 }
    668 
    669 // getBearerAuthTokenCacheOptionsProvider returns the wrapped function to set smithybearer.TokenCacheOptions
    670 func (o LoadOptions) getBearerAuthTokenCacheOptions(ctx context.Context) (func(*smithybearer.TokenCacheOptions), bool, error) {
    671 	if o.BearerAuthTokenCacheOptions == nil {
    672 		return nil, false, nil
    673 	}
    674 
    675 	return o.BearerAuthTokenCacheOptions, true, nil
    676 }
    677 
    678 // WithBearerAuthTokenCacheOptions is a helper function to construct functional options
    679 // that sets a function to modify the TokenCacheOptions the smithy-go
    680 // auth/bearer#TokenCache will be configured with, if the TokenCache is used by
    681 // the configuration loader.
    682 //
    683 // If multiple WithBearerAuthTokenCacheOptions calls are made, the last call overrides
    684 // the previous call values.
    685 func WithBearerAuthTokenCacheOptions(v func(*smithybearer.TokenCacheOptions)) LoadOptionsFunc {
    686 	return func(o *LoadOptions) error {
    687 		o.BearerAuthTokenCacheOptions = v
    688 		return nil
    689 	}
    690 }
    691 
    692 // getSSOTokenProviderOptionsProvider returns the wrapped function to set smithybearer.TokenCacheOptions
    693 func (o LoadOptions) getSSOTokenProviderOptions(ctx context.Context) (func(*ssocreds.SSOTokenProviderOptions), bool, error) {
    694 	if o.SSOTokenProviderOptions == nil {
    695 		return nil, false, nil
    696 	}
    697 
    698 	return o.SSOTokenProviderOptions, true, nil
    699 }
    700 
    701 // WithSSOTokenProviderOptions is a helper function to construct functional
    702 // options that sets a function to modify the SSOtokenProviderOptions the SDK's
    703 // credentials/ssocreds#SSOProvider will be configured with, if the
    704 // SSOTokenProvider is used by the configuration loader.
    705 //
    706 // If multiple WithSSOTokenProviderOptions calls are made, the last call overrides
    707 // the previous call values.
    708 func WithSSOTokenProviderOptions(v func(*ssocreds.SSOTokenProviderOptions)) LoadOptionsFunc {
    709 	return func(o *LoadOptions) error {
    710 		o.SSOTokenProviderOptions = v
    711 		return nil
    712 	}
    713 }
    714 
    715 // getProcessCredentialOptions returns the wrapped function to set processcreds.Options
    716 func (o LoadOptions) getProcessCredentialOptions(ctx context.Context) (func(*processcreds.Options), bool, error) {
    717 	if o.ProcessCredentialOptions == nil {
    718 		return nil, false, nil
    719 	}
    720 
    721 	return o.ProcessCredentialOptions, true, nil
    722 }
    723 
    724 // WithProcessCredentialOptions is a helper function to construct functional options
    725 // that sets a function to use processcreds.Options on config's LoadOptions.
    726 // If process credential options is set to nil, the process credential value will
    727 // be ignored. If multiple WithProcessCredentialOptions calls are made, the last call
    728 // overrides the previous call values.
    729 func WithProcessCredentialOptions(v func(*processcreds.Options)) LoadOptionsFunc {
    730 	return func(o *LoadOptions) error {
    731 		o.ProcessCredentialOptions = v
    732 		return nil
    733 	}
    734 }
    735 
    736 // getEC2RoleCredentialOptions returns the wrapped function to set the ec2rolecreds.Options
    737 func (o LoadOptions) getEC2RoleCredentialOptions(ctx context.Context) (func(*ec2rolecreds.Options), bool, error) {
    738 	if o.EC2RoleCredentialOptions == nil {
    739 		return nil, false, nil
    740 	}
    741 
    742 	return o.EC2RoleCredentialOptions, true, nil
    743 }
    744 
    745 // WithEC2RoleCredentialOptions is a helper function to construct functional options
    746 // that sets a function to use ec2rolecreds.Options on config's LoadOptions. If
    747 // EC2 role credential options is set to nil, the EC2 role credential options value
    748 // will be ignored. If multiple WithEC2RoleCredentialOptions calls are made,
    749 // the last call overrides the previous call values.
    750 func WithEC2RoleCredentialOptions(v func(*ec2rolecreds.Options)) LoadOptionsFunc {
    751 	return func(o *LoadOptions) error {
    752 		o.EC2RoleCredentialOptions = v
    753 		return nil
    754 	}
    755 }
    756 
    757 // getEndpointCredentialOptions returns the wrapped function to set endpointcreds.Options
    758 func (o LoadOptions) getEndpointCredentialOptions(context.Context) (func(*endpointcreds.Options), bool, error) {
    759 	if o.EndpointCredentialOptions == nil {
    760 		return nil, false, nil
    761 	}
    762 
    763 	return o.EndpointCredentialOptions, true, nil
    764 }
    765 
    766 // WithEndpointCredentialOptions is a helper function to construct functional options
    767 // that sets a function to use endpointcreds.Options on config's LoadOptions. If
    768 // endpoint credential options is set to nil, the endpoint credential options
    769 // value will be ignored. If multiple WithEndpointCredentialOptions calls are made,
    770 // the last call overrides the previous call values.
    771 func WithEndpointCredentialOptions(v func(*endpointcreds.Options)) LoadOptionsFunc {
    772 	return func(o *LoadOptions) error {
    773 		o.EndpointCredentialOptions = v
    774 		return nil
    775 	}
    776 }
    777 
    778 // getWebIdentityRoleCredentialOptions returns the wrapped function
    779 func (o LoadOptions) getWebIdentityRoleCredentialOptions(context.Context) (func(*stscreds.WebIdentityRoleOptions), bool, error) {
    780 	if o.WebIdentityRoleCredentialOptions == nil {
    781 		return nil, false, nil
    782 	}
    783 
    784 	return o.WebIdentityRoleCredentialOptions, true, nil
    785 }
    786 
    787 // WithWebIdentityRoleCredentialOptions is a helper function to construct
    788 // functional options that sets a function to use stscreds.WebIdentityRoleOptions
    789 // on config's LoadOptions. If web identity role credentials options is set to nil,
    790 // the web identity role credentials value will be ignored. If multiple
    791 // WithWebIdentityRoleCredentialOptions calls are made, the last call
    792 // overrides the previous call values.
    793 func WithWebIdentityRoleCredentialOptions(v func(*stscreds.WebIdentityRoleOptions)) LoadOptionsFunc {
    794 	return func(o *LoadOptions) error {
    795 		o.WebIdentityRoleCredentialOptions = v
    796 		return nil
    797 	}
    798 }
    799 
    800 // getAssumeRoleCredentialOptions returns AssumeRoleCredentialOptions from LoadOptions
    801 func (o LoadOptions) getAssumeRoleCredentialOptions(context.Context) (func(options *stscreds.AssumeRoleOptions), bool, error) {
    802 	if o.AssumeRoleCredentialOptions == nil {
    803 		return nil, false, nil
    804 	}
    805 
    806 	return o.AssumeRoleCredentialOptions, true, nil
    807 }
    808 
    809 // WithAssumeRoleCredentialOptions  is a helper function to construct
    810 // functional options that sets a function to use stscreds.AssumeRoleOptions
    811 // on config's LoadOptions. If assume role credentials options is set to nil,
    812 // the assume role credentials value will be ignored. If multiple
    813 // WithAssumeRoleCredentialOptions calls are made, the last call overrides
    814 // the previous call values.
    815 func WithAssumeRoleCredentialOptions(v func(*stscreds.AssumeRoleOptions)) LoadOptionsFunc {
    816 	return func(o *LoadOptions) error {
    817 		o.AssumeRoleCredentialOptions = v
    818 		return nil
    819 	}
    820 }
    821 
    822 func (o LoadOptions) getHTTPClient(ctx context.Context) (HTTPClient, bool, error) {
    823 	if o.HTTPClient == nil {
    824 		return nil, false, nil
    825 	}
    826 
    827 	return o.HTTPClient, true, nil
    828 }
    829 
    830 // WithHTTPClient is a helper function to construct functional options
    831 // that sets HTTPClient on LoadOptions. If HTTPClient is set to nil,
    832 // the HTTPClient value will be ignored.
    833 // If multiple WithHTTPClient calls are made, the last call overrides
    834 // the previous call values.
    835 func WithHTTPClient(v HTTPClient) LoadOptionsFunc {
    836 	return func(o *LoadOptions) error {
    837 		o.HTTPClient = v
    838 		return nil
    839 	}
    840 }
    841 
    842 func (o LoadOptions) getAPIOptions(ctx context.Context) ([]func(*middleware.Stack) error, bool, error) {
    843 	if o.APIOptions == nil {
    844 		return nil, false, nil
    845 	}
    846 
    847 	return o.APIOptions, true, nil
    848 }
    849 
    850 // WithAPIOptions is a helper function to construct functional options
    851 // that sets APIOptions on LoadOptions. If APIOptions is set to nil, the
    852 // APIOptions value is ignored. If multiple WithAPIOptions calls are
    853 // made, the last call overrides the previous call values.
    854 func WithAPIOptions(v []func(*middleware.Stack) error) LoadOptionsFunc {
    855 	return func(o *LoadOptions) error {
    856 		if v == nil {
    857 			return nil
    858 		}
    859 
    860 		o.APIOptions = append(o.APIOptions, v...)
    861 		return nil
    862 	}
    863 }
    864 
    865 func (o LoadOptions) getRetryMaxAttempts(ctx context.Context) (int, bool, error) {
    866 	if o.RetryMaxAttempts == 0 {
    867 		return 0, false, nil
    868 	}
    869 
    870 	return o.RetryMaxAttempts, true, nil
    871 }
    872 
    873 // WithRetryMaxAttempts is a helper function to construct functional options that sets
    874 // RetryMaxAttempts on LoadOptions. If RetryMaxAttempts is unset, the RetryMaxAttempts value is
    875 // ignored. If multiple WithRetryMaxAttempts calls are made, the last call overrides
    876 // the previous call values.
    877 //
    878 // Will be ignored of LoadOptions.Retryer or WithRetryer are used.
    879 func WithRetryMaxAttempts(v int) LoadOptionsFunc {
    880 	return func(o *LoadOptions) error {
    881 		o.RetryMaxAttempts = v
    882 		return nil
    883 	}
    884 }
    885 
    886 func (o LoadOptions) getRetryMode(ctx context.Context) (aws.RetryMode, bool, error) {
    887 	if o.RetryMode == "" {
    888 		return "", false, nil
    889 	}
    890 
    891 	return o.RetryMode, true, nil
    892 }
    893 
    894 // WithRetryMode is a helper function to construct functional options that sets
    895 // RetryMode on LoadOptions. If RetryMode is unset, the RetryMode value is
    896 // ignored. If multiple WithRetryMode calls are made, the last call overrides
    897 // the previous call values.
    898 //
    899 // Will be ignored of LoadOptions.Retryer or WithRetryer are used.
    900 func WithRetryMode(v aws.RetryMode) LoadOptionsFunc {
    901 	return func(o *LoadOptions) error {
    902 		o.RetryMode = v
    903 		return nil
    904 	}
    905 }
    906 
    907 func (o LoadOptions) getRetryer(ctx context.Context) (func() aws.Retryer, bool, error) {
    908 	if o.Retryer == nil {
    909 		return nil, false, nil
    910 	}
    911 
    912 	return o.Retryer, true, nil
    913 }
    914 
    915 // WithRetryer is a helper function to construct functional options
    916 // that sets Retryer on LoadOptions. If Retryer is set to nil, the
    917 // Retryer value is ignored. If multiple WithRetryer calls are
    918 // made, the last call overrides the previous call values.
    919 func WithRetryer(v func() aws.Retryer) LoadOptionsFunc {
    920 	return func(o *LoadOptions) error {
    921 		o.Retryer = v
    922 		return nil
    923 	}
    924 }
    925 
    926 func (o LoadOptions) getEndpointResolver(ctx context.Context) (aws.EndpointResolver, bool, error) {
    927 	if o.EndpointResolver == nil {
    928 		return nil, false, nil
    929 	}
    930 
    931 	return o.EndpointResolver, true, nil
    932 }
    933 
    934 // WithEndpointResolver is a helper function to construct functional options
    935 // that sets the EndpointResolver on LoadOptions. If the EndpointResolver is set to nil,
    936 // the EndpointResolver value is ignored. If multiple WithEndpointResolver calls
    937 // are made, the last call overrides the previous call values.
    938 //
    939 // Deprecated: The global endpoint resolution interface is deprecated. The API
    940 // for endpoint resolution is now unique to each service and is set via the
    941 // EndpointResolverV2 field on service client options. Use of
    942 // WithEndpointResolver or WithEndpointResolverWithOptions will prevent you
    943 // from using any endpoint-related service features released after the
    944 // introduction of EndpointResolverV2. You may also encounter broken or
    945 // unexpected behavior when using the old global interface with services that
    946 // use many endpoint-related customizations such as S3.
    947 func WithEndpointResolver(v aws.EndpointResolver) LoadOptionsFunc {
    948 	return func(o *LoadOptions) error {
    949 		o.EndpointResolver = v
    950 		return nil
    951 	}
    952 }
    953 
    954 func (o LoadOptions) getEndpointResolverWithOptions(ctx context.Context) (aws.EndpointResolverWithOptions, bool, error) {
    955 	if o.EndpointResolverWithOptions == nil {
    956 		return nil, false, nil
    957 	}
    958 
    959 	return o.EndpointResolverWithOptions, true, nil
    960 }
    961 
    962 // WithEndpointResolverWithOptions is a helper function to construct functional options
    963 // that sets the EndpointResolverWithOptions on LoadOptions. If the EndpointResolverWithOptions is set to nil,
    964 // the EndpointResolver value is ignored. If multiple WithEndpointResolver calls
    965 // are made, the last call overrides the previous call values.
    966 //
    967 // Deprecated: The global endpoint resolution interface is deprecated. See
    968 // deprecation docs on [WithEndpointResolver].
    969 func WithEndpointResolverWithOptions(v aws.EndpointResolverWithOptions) LoadOptionsFunc {
    970 	return func(o *LoadOptions) error {
    971 		o.EndpointResolverWithOptions = v
    972 		return nil
    973 	}
    974 }
    975 
    976 func (o LoadOptions) getLogger(ctx context.Context) (logging.Logger, bool, error) {
    977 	if o.Logger == nil {
    978 		return nil, false, nil
    979 	}
    980 
    981 	return o.Logger, true, nil
    982 }
    983 
    984 // WithLogger is a helper function to construct functional options
    985 // that sets Logger on LoadOptions. If Logger is set to nil, the
    986 // Logger value will be ignored. If multiple WithLogger calls are made,
    987 // the last call overrides the previous call values.
    988 func WithLogger(v logging.Logger) LoadOptionsFunc {
    989 	return func(o *LoadOptions) error {
    990 		o.Logger = v
    991 		return nil
    992 	}
    993 }
    994 
    995 func (o LoadOptions) getClientLogMode(ctx context.Context) (aws.ClientLogMode, bool, error) {
    996 	if o.ClientLogMode == nil {
    997 		return 0, false, nil
    998 	}
    999 
   1000 	return *o.ClientLogMode, true, nil
   1001 }
   1002 
   1003 // WithClientLogMode is a helper function to construct functional options
   1004 // that sets client log mode on LoadOptions. If client log mode is set to nil,
   1005 // the client log mode value will be ignored. If multiple WithClientLogMode calls are made,
   1006 // the last call overrides the previous call values.
   1007 func WithClientLogMode(v aws.ClientLogMode) LoadOptionsFunc {
   1008 	return func(o *LoadOptions) error {
   1009 		o.ClientLogMode = &v
   1010 		return nil
   1011 	}
   1012 }
   1013 
   1014 func (o LoadOptions) getLogConfigurationWarnings(ctx context.Context) (v bool, found bool, err error) {
   1015 	if o.LogConfigurationWarnings == nil {
   1016 		return false, false, nil
   1017 	}
   1018 	return *o.LogConfigurationWarnings, true, nil
   1019 }
   1020 
   1021 // WithLogConfigurationWarnings is a helper function to construct
   1022 // functional options that can be used to set LogConfigurationWarnings
   1023 // on LoadOptions.
   1024 //
   1025 // If multiple WithLogConfigurationWarnings calls are made, the last call
   1026 // overrides the previous call values.
   1027 func WithLogConfigurationWarnings(v bool) LoadOptionsFunc {
   1028 	return func(o *LoadOptions) error {
   1029 		o.LogConfigurationWarnings = &v
   1030 		return nil
   1031 	}
   1032 }
   1033 
   1034 // GetS3UseARNRegion returns whether to allow ARNs to direct the region
   1035 // the S3 client's requests are sent to.
   1036 func (o LoadOptions) GetS3UseARNRegion(ctx context.Context) (v bool, found bool, err error) {
   1037 	if o.S3UseARNRegion == nil {
   1038 		return false, false, nil
   1039 	}
   1040 	return *o.S3UseARNRegion, true, nil
   1041 }
   1042 
   1043 // WithS3UseARNRegion is a helper function to construct functional options
   1044 // that can be used to set S3UseARNRegion on LoadOptions.
   1045 // If multiple WithS3UseARNRegion calls are made, the last call overrides
   1046 // the previous call values.
   1047 func WithS3UseARNRegion(v bool) LoadOptionsFunc {
   1048 	return func(o *LoadOptions) error {
   1049 		o.S3UseARNRegion = &v
   1050 		return nil
   1051 	}
   1052 }
   1053 
   1054 // GetS3DisableMultiRegionAccessPoints returns whether to disable
   1055 // the S3 multi-region access points feature.
   1056 func (o LoadOptions) GetS3DisableMultiRegionAccessPoints(ctx context.Context) (v bool, found bool, err error) {
   1057 	if o.S3DisableMultiRegionAccessPoints == nil {
   1058 		return false, false, nil
   1059 	}
   1060 	return *o.S3DisableMultiRegionAccessPoints, true, nil
   1061 }
   1062 
   1063 // WithS3DisableMultiRegionAccessPoints is a helper function to construct functional options
   1064 // that can be used to set S3DisableMultiRegionAccessPoints on LoadOptions.
   1065 // If multiple WithS3DisableMultiRegionAccessPoints calls are made, the last call overrides
   1066 // the previous call values.
   1067 func WithS3DisableMultiRegionAccessPoints(v bool) LoadOptionsFunc {
   1068 	return func(o *LoadOptions) error {
   1069 		o.S3DisableMultiRegionAccessPoints = &v
   1070 		return nil
   1071 	}
   1072 }
   1073 
   1074 // GetEnableEndpointDiscovery returns if the EnableEndpointDiscovery flag is set.
   1075 func (o LoadOptions) GetEnableEndpointDiscovery(ctx context.Context) (value aws.EndpointDiscoveryEnableState, ok bool, err error) {
   1076 	if o.EnableEndpointDiscovery == aws.EndpointDiscoveryUnset {
   1077 		return aws.EndpointDiscoveryUnset, false, nil
   1078 	}
   1079 	return o.EnableEndpointDiscovery, true, nil
   1080 }
   1081 
   1082 // WithEndpointDiscovery is a helper function to construct functional options
   1083 // that can be used to enable endpoint discovery on LoadOptions for supported clients.
   1084 // If multiple WithEndpointDiscovery calls are made, the last call overrides
   1085 // the previous call values.
   1086 func WithEndpointDiscovery(v aws.EndpointDiscoveryEnableState) LoadOptionsFunc {
   1087 	return func(o *LoadOptions) error {
   1088 		o.EnableEndpointDiscovery = v
   1089 		return nil
   1090 	}
   1091 }
   1092 
   1093 // getSSOProviderOptions returns AssumeRoleCredentialOptions from LoadOptions
   1094 func (o LoadOptions) getSSOProviderOptions(context.Context) (func(options *ssocreds.Options), bool, error) {
   1095 	if o.SSOProviderOptions == nil {
   1096 		return nil, false, nil
   1097 	}
   1098 
   1099 	return o.SSOProviderOptions, true, nil
   1100 }
   1101 
   1102 // WithSSOProviderOptions is a helper function to construct
   1103 // functional options that sets a function to use ssocreds.Options
   1104 // on config's LoadOptions. If the SSO credential provider options is set to nil,
   1105 // the sso provider options value will be ignored. If multiple
   1106 // WithSSOProviderOptions calls are made, the last call overrides
   1107 // the previous call values.
   1108 func WithSSOProviderOptions(v func(*ssocreds.Options)) LoadOptionsFunc {
   1109 	return func(o *LoadOptions) error {
   1110 		o.SSOProviderOptions = v
   1111 		return nil
   1112 	}
   1113 }
   1114 
   1115 // GetEC2IMDSClientEnableState implements a EC2IMDSClientEnableState options resolver interface.
   1116 func (o LoadOptions) GetEC2IMDSClientEnableState() (imds.ClientEnableState, bool, error) {
   1117 	if o.EC2IMDSClientEnableState == imds.ClientDefaultEnableState {
   1118 		return imds.ClientDefaultEnableState, false, nil
   1119 	}
   1120 
   1121 	return o.EC2IMDSClientEnableState, true, nil
   1122 }
   1123 
   1124 // GetEC2IMDSEndpointMode implements a EC2IMDSEndpointMode option resolver interface.
   1125 func (o LoadOptions) GetEC2IMDSEndpointMode() (imds.EndpointModeState, bool, error) {
   1126 	if o.EC2IMDSEndpointMode == imds.EndpointModeStateUnset {
   1127 		return imds.EndpointModeStateUnset, false, nil
   1128 	}
   1129 
   1130 	return o.EC2IMDSEndpointMode, true, nil
   1131 }
   1132 
   1133 // GetEC2IMDSEndpoint implements a EC2IMDSEndpoint option resolver interface.
   1134 func (o LoadOptions) GetEC2IMDSEndpoint() (string, bool, error) {
   1135 	if len(o.EC2IMDSEndpoint) == 0 {
   1136 		return "", false, nil
   1137 	}
   1138 
   1139 	return o.EC2IMDSEndpoint, true, nil
   1140 }
   1141 
   1142 // WithEC2IMDSClientEnableState is a helper function to construct functional options that sets the EC2IMDSClientEnableState.
   1143 func WithEC2IMDSClientEnableState(v imds.ClientEnableState) LoadOptionsFunc {
   1144 	return func(o *LoadOptions) error {
   1145 		o.EC2IMDSClientEnableState = v
   1146 		return nil
   1147 	}
   1148 }
   1149 
   1150 // WithEC2IMDSEndpointMode is a helper function to construct functional options that sets the EC2IMDSEndpointMode.
   1151 func WithEC2IMDSEndpointMode(v imds.EndpointModeState) LoadOptionsFunc {
   1152 	return func(o *LoadOptions) error {
   1153 		o.EC2IMDSEndpointMode = v
   1154 		return nil
   1155 	}
   1156 }
   1157 
   1158 // WithEC2IMDSEndpoint is a helper function to construct functional options that sets the EC2IMDSEndpoint.
   1159 func WithEC2IMDSEndpoint(v string) LoadOptionsFunc {
   1160 	return func(o *LoadOptions) error {
   1161 		o.EC2IMDSEndpoint = v
   1162 		return nil
   1163 	}
   1164 }
   1165 
   1166 // WithUseDualStackEndpoint is a helper function to construct
   1167 // functional options that can be used to set UseDualStackEndpoint on LoadOptions.
   1168 func WithUseDualStackEndpoint(v aws.DualStackEndpointState) LoadOptionsFunc {
   1169 	return func(o *LoadOptions) error {
   1170 		o.UseDualStackEndpoint = v
   1171 		return nil
   1172 	}
   1173 }
   1174 
   1175 // GetUseDualStackEndpoint returns whether the service's dual-stack endpoint should be
   1176 // used for requests.
   1177 func (o LoadOptions) GetUseDualStackEndpoint(ctx context.Context) (value aws.DualStackEndpointState, found bool, err error) {
   1178 	if o.UseDualStackEndpoint == aws.DualStackEndpointStateUnset {
   1179 		return aws.DualStackEndpointStateUnset, false, nil
   1180 	}
   1181 	return o.UseDualStackEndpoint, true, nil
   1182 }
   1183 
   1184 // WithUseFIPSEndpoint is a helper function to construct
   1185 // functional options that can be used to set UseFIPSEndpoint on LoadOptions.
   1186 func WithUseFIPSEndpoint(v aws.FIPSEndpointState) LoadOptionsFunc {
   1187 	return func(o *LoadOptions) error {
   1188 		o.UseFIPSEndpoint = v
   1189 		return nil
   1190 	}
   1191 }
   1192 
   1193 // GetUseFIPSEndpoint returns whether the service's FIPS endpoint should be
   1194 // used for requests.
   1195 func (o LoadOptions) GetUseFIPSEndpoint(ctx context.Context) (value aws.FIPSEndpointState, found bool, err error) {
   1196 	if o.UseFIPSEndpoint == aws.FIPSEndpointStateUnset {
   1197 		return aws.FIPSEndpointStateUnset, false, nil
   1198 	}
   1199 	return o.UseFIPSEndpoint, true, nil
   1200 }
   1201 
   1202 // WithDefaultsMode sets the SDK defaults configuration mode to the value provided.
   1203 //
   1204 // Zero or more functional options can be provided to provide configuration options for performing
   1205 // environment discovery when using aws.DefaultsModeAuto.
   1206 func WithDefaultsMode(mode aws.DefaultsMode, optFns ...func(options *DefaultsModeOptions)) LoadOptionsFunc {
   1207 	do := DefaultsModeOptions{
   1208 		Mode: mode,
   1209 	}
   1210 	for _, fn := range optFns {
   1211 		fn(&do)
   1212 	}
   1213 	return func(options *LoadOptions) error {
   1214 		options.DefaultsModeOptions = do
   1215 		return nil
   1216 	}
   1217 }
   1218 
   1219 // GetS3DisableExpressAuth returns the configured value for
   1220 // [EnvConfig.S3DisableExpressAuth].
   1221 func (o LoadOptions) GetS3DisableExpressAuth() (value, ok bool) {
   1222 	if o.S3DisableExpressAuth == nil {
   1223 		return false, false
   1224 	}
   1225 
   1226 	return *o.S3DisableExpressAuth, true
   1227 }
   1228 
   1229 // WithS3DisableExpressAuth sets [LoadOptions.S3DisableExpressAuth]
   1230 // to the value provided.
   1231 func WithS3DisableExpressAuth(v bool) LoadOptionsFunc {
   1232 	return func(o *LoadOptions) error {
   1233 		o.S3DisableExpressAuth = &v
   1234 		return nil
   1235 	}
   1236 }
   1237 
   1238 // WithBaseEndpoint is a helper function to construct functional options that
   1239 // sets BaseEndpoint on config's LoadOptions. Empty values have no effect, and
   1240 // subsequent calls to this API override previous ones.
   1241 //
   1242 // This is an in-code setting, therefore, any value set using this hook takes
   1243 // precedence over and will override ALL environment and shared config
   1244 // directives that set endpoint URLs. Functional options on service clients
   1245 // have higher specificity, and functional options that modify the value of
   1246 // BaseEndpoint on a client will take precedence over this setting.
   1247 func WithBaseEndpoint(v string) LoadOptionsFunc {
   1248 	return func(o *LoadOptions) error {
   1249 		o.BaseEndpoint = v
   1250 		return nil
   1251 	}
   1252 }
   1253 
   1254 // WithServiceOptions is a helper function to construct functional options
   1255 // that sets ServiceOptions on config's LoadOptions.
   1256 func WithServiceOptions(callbacks ...func(string, any)) LoadOptionsFunc {
   1257 	return func(o *LoadOptions) error {
   1258 		o.ServiceOptions = append(o.ServiceOptions, callbacks...)
   1259 		return nil
   1260 	}
   1261 }
   1262 
   1263 // WithBeforeExecution adds the BeforeExecutionInterceptor to config.
   1264 func WithBeforeExecution(i smithyhttp.BeforeExecutionInterceptor) LoadOptionsFunc {
   1265 	return func(o *LoadOptions) error {
   1266 		o.Interceptors.BeforeExecution = append(o.Interceptors.BeforeExecution, i)
   1267 		return nil
   1268 	}
   1269 }
   1270 
   1271 // WithBeforeSerialization adds the BeforeSerializationInterceptor to config.
   1272 func WithBeforeSerialization(i smithyhttp.BeforeSerializationInterceptor) LoadOptionsFunc {
   1273 	return func(o *LoadOptions) error {
   1274 		o.Interceptors.BeforeSerialization = append(o.Interceptors.BeforeSerialization, i)
   1275 		return nil
   1276 	}
   1277 }
   1278 
   1279 // WithAfterSerialization adds the AfterSerializationInterceptor to config.
   1280 func WithAfterSerialization(i smithyhttp.AfterSerializationInterceptor) LoadOptionsFunc {
   1281 	return func(o *LoadOptions) error {
   1282 		o.Interceptors.AfterSerialization = append(o.Interceptors.AfterSerialization, i)
   1283 		return nil
   1284 	}
   1285 }
   1286 
   1287 // WithBeforeRetryLoop adds the BeforeRetryLoopInterceptor to config.
   1288 func WithBeforeRetryLoop(i smithyhttp.BeforeRetryLoopInterceptor) LoadOptionsFunc {
   1289 	return func(o *LoadOptions) error {
   1290 		o.Interceptors.BeforeRetryLoop = append(o.Interceptors.BeforeRetryLoop, i)
   1291 		return nil
   1292 	}
   1293 }
   1294 
   1295 // WithBeforeAttempt adds the BeforeAttemptInterceptor to config.
   1296 func WithBeforeAttempt(i smithyhttp.BeforeAttemptInterceptor) LoadOptionsFunc {
   1297 	return func(o *LoadOptions) error {
   1298 		o.Interceptors.BeforeAttempt = append(o.Interceptors.BeforeAttempt, i)
   1299 		return nil
   1300 	}
   1301 }
   1302 
   1303 // WithBeforeSigning adds the BeforeSigningInterceptor to config.
   1304 func WithBeforeSigning(i smithyhttp.BeforeSigningInterceptor) LoadOptionsFunc {
   1305 	return func(o *LoadOptions) error {
   1306 		o.Interceptors.BeforeSigning = append(o.Interceptors.BeforeSigning, i)
   1307 		return nil
   1308 	}
   1309 }
   1310 
   1311 // WithAfterSigning adds the AfterSigningInterceptor to config.
   1312 func WithAfterSigning(i smithyhttp.AfterSigningInterceptor) LoadOptionsFunc {
   1313 	return func(o *LoadOptions) error {
   1314 		o.Interceptors.AfterSigning = append(o.Interceptors.AfterSigning, i)
   1315 		return nil
   1316 	}
   1317 }
   1318 
   1319 // WithBeforeTransmit adds the BeforeTransmitInterceptor to config.
   1320 func WithBeforeTransmit(i smithyhttp.BeforeTransmitInterceptor) LoadOptionsFunc {
   1321 	return func(o *LoadOptions) error {
   1322 		o.Interceptors.BeforeTransmit = append(o.Interceptors.BeforeTransmit, i)
   1323 		return nil
   1324 	}
   1325 }
   1326 
   1327 // WithAfterTransmit adds the AfterTransmitInterceptor to config.
   1328 func WithAfterTransmit(i smithyhttp.AfterTransmitInterceptor) LoadOptionsFunc {
   1329 	return func(o *LoadOptions) error {
   1330 		o.Interceptors.AfterTransmit = append(o.Interceptors.AfterTransmit, i)
   1331 		return nil
   1332 	}
   1333 }
   1334 
   1335 // WithBeforeDeserialization adds the BeforeDeserializationInterceptor to config.
   1336 func WithBeforeDeserialization(i smithyhttp.BeforeDeserializationInterceptor) LoadOptionsFunc {
   1337 	return func(o *LoadOptions) error {
   1338 		o.Interceptors.BeforeDeserialization = append(o.Interceptors.BeforeDeserialization, i)
   1339 		return nil
   1340 	}
   1341 }
   1342 
   1343 // WithAfterDeserialization adds the AfterDeserializationInterceptor to config.
   1344 func WithAfterDeserialization(i smithyhttp.AfterDeserializationInterceptor) LoadOptionsFunc {
   1345 	return func(o *LoadOptions) error {
   1346 		o.Interceptors.AfterDeserialization = append(o.Interceptors.AfterDeserialization, i)
   1347 		return nil
   1348 	}
   1349 }
   1350 
   1351 // WithAfterAttempt adds the AfterAttemptInterceptor to config.
   1352 func WithAfterAttempt(i smithyhttp.AfterAttemptInterceptor) LoadOptionsFunc {
   1353 	return func(o *LoadOptions) error {
   1354 		o.Interceptors.AfterAttempt = append(o.Interceptors.AfterAttempt, i)
   1355 		return nil
   1356 	}
   1357 }
   1358 
   1359 // WithAfterExecution adds the AfterExecutionInterceptor to config.
   1360 func WithAfterExecution(i smithyhttp.AfterExecutionInterceptor) LoadOptionsFunc {
   1361 	return func(o *LoadOptions) error {
   1362 		o.Interceptors.AfterExecution = append(o.Interceptors.AfterExecution, i)
   1363 		return nil
   1364 	}
   1365 }
   1366 
   1367 // WithAuthSchemePreference sets the priority order of auth schemes on config.
   1368 //
   1369 // Schemes are expressed as names e.g. sigv4a or sigv4.
   1370 func WithAuthSchemePreference(schemeIDs ...string) LoadOptionsFunc {
   1371 	return func(o *LoadOptions) error {
   1372 		o.AuthSchemePreference = schemeIDs
   1373 		return nil
   1374 	}
   1375 }
   1376 
   1377 func (o LoadOptions) getAuthSchemePreference() ([]string, bool) {
   1378 	if len(o.AuthSchemePreference) > 0 {
   1379 		return o.AuthSchemePreference, true
   1380 	}
   1381 	return nil, false
   1382 }
   1383 
   1384 func (o LoadOptions) getRestrictFilePermissions(context.Context) (aws.RestrictFilePermissions, bool, error) {
   1385 	return o.RestrictFilePermissions, len(o.RestrictFilePermissions) > 0, nil
   1386 }
   1387 
   1388 // WithRestrictFilePermissions sets the RestrictFilePermissions mode on config.
   1389 func WithRestrictFilePermissions(m aws.RestrictFilePermissions) LoadOptionsFunc {
   1390 	return func(o *LoadOptions) error {
   1391 		o.RestrictFilePermissions = m
   1392 		return nil
   1393 	}
   1394 }