src

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

provider.go (26440B)


      1 package config
      2 
      3 import (
      4 	"context"
      5 	"io"
      6 	"net/http"
      7 
      8 	"github.com/aws/aws-sdk-go-v2/aws"
      9 	"github.com/aws/aws-sdk-go-v2/credentials/ec2rolecreds"
     10 	"github.com/aws/aws-sdk-go-v2/credentials/endpointcreds"
     11 	"github.com/aws/aws-sdk-go-v2/credentials/processcreds"
     12 	"github.com/aws/aws-sdk-go-v2/credentials/ssocreds"
     13 	"github.com/aws/aws-sdk-go-v2/credentials/stscreds"
     14 	"github.com/aws/aws-sdk-go-v2/feature/ec2/imds"
     15 	smithybearer "github.com/aws/smithy-go/auth/bearer"
     16 	"github.com/aws/smithy-go/logging"
     17 	"github.com/aws/smithy-go/middleware"
     18 )
     19 
     20 // sharedConfigProfileProvider provides access to the shared config profile
     21 // name external configuration value.
     22 type sharedConfigProfileProvider interface {
     23 	getSharedConfigProfile(ctx context.Context) (string, bool, error)
     24 }
     25 
     26 // getSharedConfigProfile searches the configs for a sharedConfigProfileProvider
     27 // and returns the value if found. Returns an error if a provider fails before a
     28 // value is found.
     29 func getSharedConfigProfile(ctx context.Context, configs configs) (value string, found bool, err error) {
     30 	for _, cfg := range configs {
     31 		if p, ok := cfg.(sharedConfigProfileProvider); ok {
     32 			value, found, err = p.getSharedConfigProfile(ctx)
     33 			if err != nil || found {
     34 				break
     35 			}
     36 		}
     37 	}
     38 	return
     39 }
     40 
     41 // sharedConfigFilesProvider provides access to the shared config filesnames
     42 // external configuration value.
     43 type sharedConfigFilesProvider interface {
     44 	getSharedConfigFiles(ctx context.Context) ([]string, bool, error)
     45 }
     46 
     47 // getSharedConfigFiles searches the configs for a sharedConfigFilesProvider
     48 // and returns the value if found. Returns an error if a provider fails before a
     49 // value is found.
     50 func getSharedConfigFiles(ctx context.Context, configs configs) (value []string, found bool, err error) {
     51 	for _, cfg := range configs {
     52 		if p, ok := cfg.(sharedConfigFilesProvider); ok {
     53 			value, found, err = p.getSharedConfigFiles(ctx)
     54 			if err != nil || found {
     55 				break
     56 			}
     57 		}
     58 	}
     59 
     60 	return
     61 }
     62 
     63 // sharedCredentialsFilesProvider provides access to the shared credentials filesnames
     64 // external configuration value.
     65 type sharedCredentialsFilesProvider interface {
     66 	getSharedCredentialsFiles(ctx context.Context) ([]string, bool, error)
     67 }
     68 
     69 // getSharedCredentialsFiles searches the configs for a sharedCredentialsFilesProvider
     70 // and returns the value if found. Returns an error if a provider fails before a
     71 // value is found.
     72 func getSharedCredentialsFiles(ctx context.Context, configs configs) (value []string, found bool, err error) {
     73 	for _, cfg := range configs {
     74 		if p, ok := cfg.(sharedCredentialsFilesProvider); ok {
     75 			value, found, err = p.getSharedCredentialsFiles(ctx)
     76 			if err != nil || found {
     77 				break
     78 			}
     79 		}
     80 	}
     81 
     82 	return
     83 }
     84 
     85 // customCABundleProvider provides access to the custom CA bundle PEM bytes.
     86 type customCABundleProvider interface {
     87 	getCustomCABundle(ctx context.Context) (io.Reader, bool, error)
     88 }
     89 
     90 // getCustomCABundle searches the configs for a customCABundleProvider
     91 // and returns the value if found. Returns an error if a provider fails before a
     92 // value is found.
     93 func getCustomCABundle(ctx context.Context, configs configs) (value io.Reader, found bool, err error) {
     94 	for _, cfg := range configs {
     95 		if p, ok := cfg.(customCABundleProvider); ok {
     96 			value, found, err = p.getCustomCABundle(ctx)
     97 			if err != nil || found {
     98 				break
     99 			}
    100 		}
    101 	}
    102 
    103 	return
    104 }
    105 
    106 // regionProvider provides access to the region external configuration value.
    107 type regionProvider interface {
    108 	getRegion(ctx context.Context) (string, bool, error)
    109 }
    110 
    111 // getRegion searches the configs for a regionProvider and returns the value
    112 // if found. Returns an error if a provider fails before a value is found.
    113 func getRegion(ctx context.Context, configs configs) (value string, found bool, err error) {
    114 	for _, cfg := range configs {
    115 		if p, ok := cfg.(regionProvider); ok {
    116 			value, found, err = p.getRegion(ctx)
    117 			if err != nil || found {
    118 				break
    119 			}
    120 		}
    121 	}
    122 	return
    123 }
    124 
    125 // IgnoreConfiguredEndpointsProvider is needed to search for all providers
    126 // that provide a flag to disable configured endpoints.
    127 type IgnoreConfiguredEndpointsProvider interface {
    128 	GetIgnoreConfiguredEndpoints(ctx context.Context) (bool, bool, error)
    129 }
    130 
    131 // GetIgnoreConfiguredEndpoints is used in knowing when to disable configured
    132 // endpoints feature.
    133 func GetIgnoreConfiguredEndpoints(ctx context.Context, configs []any) (value bool, found bool, err error) {
    134 	for _, cfg := range configs {
    135 		if p, ok := cfg.(IgnoreConfiguredEndpointsProvider); ok {
    136 			value, found, err = p.GetIgnoreConfiguredEndpoints(ctx)
    137 			if err != nil || found {
    138 				break
    139 			}
    140 		}
    141 	}
    142 	return
    143 }
    144 
    145 type baseEndpointProvider interface {
    146 	getBaseEndpoint(ctx context.Context) (string, bool, error)
    147 }
    148 
    149 func getBaseEndpoint(ctx context.Context, configs configs) (value string, found bool, err error) {
    150 	for _, cfg := range configs {
    151 		if p, ok := cfg.(baseEndpointProvider); ok {
    152 			value, found, err = p.getBaseEndpoint(ctx)
    153 			if err != nil || found {
    154 				break
    155 			}
    156 		}
    157 	}
    158 	return
    159 }
    160 
    161 type servicesObjectProvider interface {
    162 	getServicesObject(ctx context.Context) (map[string]map[string]string, bool, error)
    163 }
    164 
    165 func getServicesObject(ctx context.Context, configs configs) (value map[string]map[string]string, found bool, err error) {
    166 	for _, cfg := range configs {
    167 		if p, ok := cfg.(servicesObjectProvider); ok {
    168 			value, found, err = p.getServicesObject(ctx)
    169 			if err != nil || found {
    170 				break
    171 			}
    172 		}
    173 	}
    174 	return
    175 }
    176 
    177 // appIDProvider provides access to the sdk app ID value
    178 type appIDProvider interface {
    179 	getAppID(ctx context.Context) (string, bool, error)
    180 }
    181 
    182 func getAppID(ctx context.Context, configs configs) (value string, found bool, err error) {
    183 	for _, cfg := range configs {
    184 		if p, ok := cfg.(appIDProvider); ok {
    185 			value, found, err = p.getAppID(ctx)
    186 			if err != nil || found {
    187 				break
    188 			}
    189 		}
    190 	}
    191 	return
    192 }
    193 
    194 // disableRequestCompressionProvider provides access to the DisableRequestCompression
    195 type disableRequestCompressionProvider interface {
    196 	getDisableRequestCompression(context.Context) (bool, bool, error)
    197 }
    198 
    199 func getDisableRequestCompression(ctx context.Context, configs configs) (value bool, found bool, err error) {
    200 	for _, cfg := range configs {
    201 		if p, ok := cfg.(disableRequestCompressionProvider); ok {
    202 			value, found, err = p.getDisableRequestCompression(ctx)
    203 			if err != nil || found {
    204 				break
    205 			}
    206 		}
    207 	}
    208 	return
    209 }
    210 
    211 // disableClockSkewCorrectionProvider provides access to the DisableClockSkewCorrection
    212 type disableClockSkewCorrectionProvider interface {
    213 	getDisableClockSkewCorrection(context.Context) (bool, bool, error)
    214 }
    215 
    216 func getDisableClockSkewCorrection(ctx context.Context, configs configs) (value bool, found bool, err error) {
    217 	for _, cfg := range configs {
    218 		if p, ok := cfg.(disableClockSkewCorrectionProvider); ok {
    219 			value, found, err = p.getDisableClockSkewCorrection(ctx)
    220 			if err != nil || found {
    221 				break
    222 			}
    223 		}
    224 	}
    225 	return
    226 }
    227 
    228 // requestMinCompressSizeBytesProvider provides access to the MinCompressSizeBytes
    229 type requestMinCompressSizeBytesProvider interface {
    230 	getRequestMinCompressSizeBytes(context.Context) (int64, bool, error)
    231 }
    232 
    233 func getRequestMinCompressSizeBytes(ctx context.Context, configs configs) (value int64, found bool, err error) {
    234 	for _, cfg := range configs {
    235 		if p, ok := cfg.(requestMinCompressSizeBytesProvider); ok {
    236 			value, found, err = p.getRequestMinCompressSizeBytes(ctx)
    237 			if err != nil || found {
    238 				break
    239 			}
    240 		}
    241 	}
    242 	return
    243 }
    244 
    245 // accountIDEndpointModeProvider provides access to the AccountIDEndpointMode
    246 type accountIDEndpointModeProvider interface {
    247 	getAccountIDEndpointMode(context.Context) (aws.AccountIDEndpointMode, bool, error)
    248 }
    249 
    250 func getAccountIDEndpointMode(ctx context.Context, configs configs) (value aws.AccountIDEndpointMode, found bool, err error) {
    251 	for _, cfg := range configs {
    252 		if p, ok := cfg.(accountIDEndpointModeProvider); ok {
    253 			value, found, err = p.getAccountIDEndpointMode(ctx)
    254 			if err != nil || found {
    255 				break
    256 			}
    257 		}
    258 	}
    259 	return
    260 }
    261 
    262 // requestChecksumCalculationProvider provides access to the RequestChecksumCalculation
    263 type requestChecksumCalculationProvider interface {
    264 	getRequestChecksumCalculation(context.Context) (aws.RequestChecksumCalculation, bool, error)
    265 }
    266 
    267 func getRequestChecksumCalculation(ctx context.Context, configs configs) (value aws.RequestChecksumCalculation, found bool, err error) {
    268 	for _, cfg := range configs {
    269 		if p, ok := cfg.(requestChecksumCalculationProvider); ok {
    270 			value, found, err = p.getRequestChecksumCalculation(ctx)
    271 			if err != nil || found {
    272 				break
    273 			}
    274 		}
    275 	}
    276 	return
    277 }
    278 
    279 // responseChecksumValidationProvider provides access to the ResponseChecksumValidation
    280 type responseChecksumValidationProvider interface {
    281 	getResponseChecksumValidation(context.Context) (aws.ResponseChecksumValidation, bool, error)
    282 }
    283 
    284 func getResponseChecksumValidation(ctx context.Context, configs configs) (value aws.ResponseChecksumValidation, found bool, err error) {
    285 	for _, cfg := range configs {
    286 		if p, ok := cfg.(responseChecksumValidationProvider); ok {
    287 			value, found, err = p.getResponseChecksumValidation(ctx)
    288 			if err != nil || found {
    289 				break
    290 			}
    291 		}
    292 	}
    293 	return
    294 }
    295 
    296 // ec2IMDSRegionProvider provides access to the ec2 imds region
    297 // configuration value
    298 type ec2IMDSRegionProvider interface {
    299 	getEC2IMDSRegion(ctx context.Context) (string, bool, error)
    300 }
    301 
    302 // getEC2IMDSRegion searches the configs for a ec2IMDSRegionProvider and
    303 // returns the value if found. Returns an error if a provider fails before
    304 // a value is found.
    305 func getEC2IMDSRegion(ctx context.Context, configs configs) (region string, found bool, err error) {
    306 	for _, cfg := range configs {
    307 		if provider, ok := cfg.(ec2IMDSRegionProvider); ok {
    308 			region, found, err = provider.getEC2IMDSRegion(ctx)
    309 			if err != nil || found {
    310 				break
    311 			}
    312 		}
    313 	}
    314 	return
    315 }
    316 
    317 // credentialsProviderProvider provides access to the credentials external
    318 // configuration value.
    319 type credentialsProviderProvider interface {
    320 	getCredentialsProvider(ctx context.Context) (aws.CredentialsProvider, bool, error)
    321 }
    322 
    323 // getCredentialsProvider searches the configs for a credentialsProviderProvider
    324 // and returns the value if found. Returns an error if a provider fails before a
    325 // value is found.
    326 func getCredentialsProvider(ctx context.Context, configs configs) (p aws.CredentialsProvider, found bool, err error) {
    327 	for _, cfg := range configs {
    328 		if provider, ok := cfg.(credentialsProviderProvider); ok {
    329 			p, found, err = provider.getCredentialsProvider(ctx)
    330 			if err != nil || found {
    331 				break
    332 			}
    333 		}
    334 	}
    335 	return
    336 }
    337 
    338 // credentialsCacheOptionsProvider is an interface for retrieving a function for setting
    339 // the aws.CredentialsCacheOptions.
    340 type credentialsCacheOptionsProvider interface {
    341 	getCredentialsCacheOptions(ctx context.Context) (func(*aws.CredentialsCacheOptions), bool, error)
    342 }
    343 
    344 // getCredentialsCacheOptionsProvider is an interface for retrieving a function for setting
    345 // the aws.CredentialsCacheOptions.
    346 func getCredentialsCacheOptionsProvider(ctx context.Context, configs configs) (
    347 	f func(*aws.CredentialsCacheOptions), found bool, err error,
    348 ) {
    349 	for _, config := range configs {
    350 		if p, ok := config.(credentialsCacheOptionsProvider); ok {
    351 			f, found, err = p.getCredentialsCacheOptions(ctx)
    352 			if err != nil || found {
    353 				break
    354 			}
    355 		}
    356 	}
    357 	return
    358 }
    359 
    360 // bearerAuthTokenProviderProvider provides access to the bearer authentication
    361 // token external configuration value.
    362 type bearerAuthTokenProviderProvider interface {
    363 	getBearerAuthTokenProvider(context.Context) (smithybearer.TokenProvider, bool, error)
    364 }
    365 
    366 // getBearerAuthTokenProvider searches the config sources for a
    367 // bearerAuthTokenProviderProvider and returns the value if found. Returns an
    368 // error if a provider fails before a value is found.
    369 func getBearerAuthTokenProvider(ctx context.Context, configs configs) (p smithybearer.TokenProvider, found bool, err error) {
    370 	for _, cfg := range configs {
    371 		if provider, ok := cfg.(bearerAuthTokenProviderProvider); ok {
    372 			p, found, err = provider.getBearerAuthTokenProvider(ctx)
    373 			if err != nil || found {
    374 				break
    375 			}
    376 		}
    377 	}
    378 	return
    379 }
    380 
    381 // bearerAuthTokenCacheOptionsProvider is an interface for retrieving a function for
    382 // setting the smithy-go auth/bearer#TokenCacheOptions.
    383 type bearerAuthTokenCacheOptionsProvider interface {
    384 	getBearerAuthTokenCacheOptions(context.Context) (func(*smithybearer.TokenCacheOptions), bool, error)
    385 }
    386 
    387 // getBearerAuthTokenCacheOptionsProvider is an interface for retrieving a function for
    388 // setting the smithy-go auth/bearer#TokenCacheOptions.
    389 func getBearerAuthTokenCacheOptions(ctx context.Context, configs configs) (
    390 	f func(*smithybearer.TokenCacheOptions), found bool, err error,
    391 ) {
    392 	for _, config := range configs {
    393 		if p, ok := config.(bearerAuthTokenCacheOptionsProvider); ok {
    394 			f, found, err = p.getBearerAuthTokenCacheOptions(ctx)
    395 			if err != nil || found {
    396 				break
    397 			}
    398 		}
    399 	}
    400 	return
    401 }
    402 
    403 // ssoTokenProviderOptionsProvider is an interface for retrieving a function for
    404 // setting the SDK's credentials/ssocreds#SSOTokenProviderOptions.
    405 type ssoTokenProviderOptionsProvider interface {
    406 	getSSOTokenProviderOptions(context.Context) (func(*ssocreds.SSOTokenProviderOptions), bool, error)
    407 }
    408 
    409 // getSSOTokenProviderOptions is an interface for retrieving a function for
    410 // setting the SDK's credentials/ssocreds#SSOTokenProviderOptions.
    411 func getSSOTokenProviderOptions(ctx context.Context, configs configs) (
    412 	f func(*ssocreds.SSOTokenProviderOptions), found bool, err error,
    413 ) {
    414 	for _, config := range configs {
    415 		if p, ok := config.(ssoTokenProviderOptionsProvider); ok {
    416 			f, found, err = p.getSSOTokenProviderOptions(ctx)
    417 			if err != nil || found {
    418 				break
    419 			}
    420 		}
    421 	}
    422 	return
    423 }
    424 
    425 // ssoTokenProviderOptionsProvider
    426 
    427 // processCredentialOptions is an interface for retrieving a function for setting
    428 // the processcreds.Options.
    429 type processCredentialOptions interface {
    430 	getProcessCredentialOptions(ctx context.Context) (func(*processcreds.Options), bool, error)
    431 }
    432 
    433 // getProcessCredentialOptions searches the slice of configs and returns the first function found
    434 func getProcessCredentialOptions(ctx context.Context, configs configs) (f func(*processcreds.Options), found bool, err error) {
    435 	for _, config := range configs {
    436 		if p, ok := config.(processCredentialOptions); ok {
    437 			f, found, err = p.getProcessCredentialOptions(ctx)
    438 			if err != nil || found {
    439 				break
    440 			}
    441 		}
    442 	}
    443 	return
    444 }
    445 
    446 // ec2RoleCredentialOptionsProvider is an interface for retrieving a function
    447 // for setting the ec2rolecreds.Provider options.
    448 type ec2RoleCredentialOptionsProvider interface {
    449 	getEC2RoleCredentialOptions(ctx context.Context) (func(*ec2rolecreds.Options), bool, error)
    450 }
    451 
    452 // getEC2RoleCredentialProviderOptions searches the slice of configs and returns the first function found
    453 func getEC2RoleCredentialProviderOptions(ctx context.Context, configs configs) (f func(*ec2rolecreds.Options), found bool, err error) {
    454 	for _, config := range configs {
    455 		if p, ok := config.(ec2RoleCredentialOptionsProvider); ok {
    456 			f, found, err = p.getEC2RoleCredentialOptions(ctx)
    457 			if err != nil || found {
    458 				break
    459 			}
    460 		}
    461 	}
    462 	return
    463 }
    464 
    465 // defaultRegionProvider is an interface for retrieving a default region if a region was not resolved from other sources
    466 type defaultRegionProvider interface {
    467 	getDefaultRegion(ctx context.Context) (string, bool, error)
    468 }
    469 
    470 // getDefaultRegion searches the slice of configs and returns the first fallback region found
    471 func getDefaultRegion(ctx context.Context, configs configs) (value string, found bool, err error) {
    472 	for _, config := range configs {
    473 		if p, ok := config.(defaultRegionProvider); ok {
    474 			value, found, err = p.getDefaultRegion(ctx)
    475 			if err != nil || found {
    476 				break
    477 			}
    478 		}
    479 	}
    480 	return
    481 }
    482 
    483 // endpointCredentialOptionsProvider is an interface for retrieving a function for setting
    484 // the endpointcreds.ProviderOptions.
    485 type endpointCredentialOptionsProvider interface {
    486 	getEndpointCredentialOptions(ctx context.Context) (func(*endpointcreds.Options), bool, error)
    487 }
    488 
    489 // getEndpointCredentialProviderOptions searches the slice of configs and returns the first function found
    490 func getEndpointCredentialProviderOptions(ctx context.Context, configs configs) (f func(*endpointcreds.Options), found bool, err error) {
    491 	for _, config := range configs {
    492 		if p, ok := config.(endpointCredentialOptionsProvider); ok {
    493 			f, found, err = p.getEndpointCredentialOptions(ctx)
    494 			if err != nil || found {
    495 				break
    496 			}
    497 		}
    498 	}
    499 	return
    500 }
    501 
    502 // webIdentityRoleCredentialOptionsProvider is an interface for retrieving a function for setting
    503 // the stscreds.WebIdentityRoleProvider.
    504 type webIdentityRoleCredentialOptionsProvider interface {
    505 	getWebIdentityRoleCredentialOptions(ctx context.Context) (func(*stscreds.WebIdentityRoleOptions), bool, error)
    506 }
    507 
    508 // getWebIdentityCredentialProviderOptions searches the slice of configs and returns the first function found
    509 func getWebIdentityCredentialProviderOptions(ctx context.Context, configs configs) (f func(*stscreds.WebIdentityRoleOptions), found bool, err error) {
    510 	for _, config := range configs {
    511 		if p, ok := config.(webIdentityRoleCredentialOptionsProvider); ok {
    512 			f, found, err = p.getWebIdentityRoleCredentialOptions(ctx)
    513 			if err != nil || found {
    514 				break
    515 			}
    516 		}
    517 	}
    518 	return
    519 }
    520 
    521 // assumeRoleCredentialOptionsProvider is an interface for retrieving a function for setting
    522 // the stscreds.AssumeRoleOptions.
    523 type assumeRoleCredentialOptionsProvider interface {
    524 	getAssumeRoleCredentialOptions(ctx context.Context) (func(*stscreds.AssumeRoleOptions), bool, error)
    525 }
    526 
    527 // getAssumeRoleCredentialProviderOptions searches the slice of configs and returns the first function found
    528 func getAssumeRoleCredentialProviderOptions(ctx context.Context, configs configs) (f func(*stscreds.AssumeRoleOptions), found bool, err error) {
    529 	for _, config := range configs {
    530 		if p, ok := config.(assumeRoleCredentialOptionsProvider); ok {
    531 			f, found, err = p.getAssumeRoleCredentialOptions(ctx)
    532 			if err != nil || found {
    533 				break
    534 			}
    535 		}
    536 	}
    537 	return
    538 }
    539 
    540 // HTTPClient is an HTTP client implementation
    541 type HTTPClient interface {
    542 	Do(*http.Request) (*http.Response, error)
    543 }
    544 
    545 // httpClientProvider is an interface for retrieving HTTPClient
    546 type httpClientProvider interface {
    547 	getHTTPClient(ctx context.Context) (HTTPClient, bool, error)
    548 }
    549 
    550 // getHTTPClient searches the slice of configs and returns the HTTPClient set on configs
    551 func getHTTPClient(ctx context.Context, configs configs) (client HTTPClient, found bool, err error) {
    552 	for _, config := range configs {
    553 		if p, ok := config.(httpClientProvider); ok {
    554 			client, found, err = p.getHTTPClient(ctx)
    555 			if err != nil || found {
    556 				break
    557 			}
    558 		}
    559 	}
    560 	return
    561 }
    562 
    563 // apiOptionsProvider is an interface for retrieving APIOptions
    564 type apiOptionsProvider interface {
    565 	getAPIOptions(ctx context.Context) ([]func(*middleware.Stack) error, bool, error)
    566 }
    567 
    568 // getAPIOptions searches the slice of configs and returns the APIOptions set on configs
    569 func getAPIOptions(ctx context.Context, configs configs) (apiOptions []func(*middleware.Stack) error, found bool, err error) {
    570 	for _, config := range configs {
    571 		if p, ok := config.(apiOptionsProvider); ok {
    572 			// retrieve APIOptions from configs and set it on cfg
    573 			apiOptions, found, err = p.getAPIOptions(ctx)
    574 			if err != nil || found {
    575 				break
    576 			}
    577 		}
    578 	}
    579 	return
    580 }
    581 
    582 // endpointResolverProvider is an interface for retrieving an aws.EndpointResolver from a configuration source
    583 type endpointResolverProvider interface {
    584 	getEndpointResolver(ctx context.Context) (aws.EndpointResolver, bool, error)
    585 }
    586 
    587 // getEndpointResolver searches the provided config sources for a EndpointResolverFunc that can be used
    588 // to configure the aws.Config.EndpointResolver value.
    589 func getEndpointResolver(ctx context.Context, configs configs) (f aws.EndpointResolver, found bool, err error) {
    590 	for _, c := range configs {
    591 		if p, ok := c.(endpointResolverProvider); ok {
    592 			f, found, err = p.getEndpointResolver(ctx)
    593 			if err != nil || found {
    594 				break
    595 			}
    596 		}
    597 	}
    598 	return
    599 }
    600 
    601 // endpointResolverWithOptionsProvider is an interface for retrieving an aws.EndpointResolverWithOptions from a configuration source
    602 type endpointResolverWithOptionsProvider interface {
    603 	getEndpointResolverWithOptions(ctx context.Context) (aws.EndpointResolverWithOptions, bool, error)
    604 }
    605 
    606 // getEndpointResolver searches the provided config sources for a EndpointResolverFunc that can be used
    607 // to configure the aws.Config.EndpointResolver value.
    608 func getEndpointResolverWithOptions(ctx context.Context, configs configs) (f aws.EndpointResolverWithOptions, found bool, err error) {
    609 	for _, c := range configs {
    610 		if p, ok := c.(endpointResolverWithOptionsProvider); ok {
    611 			f, found, err = p.getEndpointResolverWithOptions(ctx)
    612 			if err != nil || found {
    613 				break
    614 			}
    615 		}
    616 	}
    617 	return
    618 }
    619 
    620 // loggerProvider is an interface for retrieving a logging.Logger from a configuration source.
    621 type loggerProvider interface {
    622 	getLogger(ctx context.Context) (logging.Logger, bool, error)
    623 }
    624 
    625 // getLogger searches the provided config sources for a logging.Logger that can be used
    626 // to configure the aws.Config.Logger value.
    627 func getLogger(ctx context.Context, configs configs) (l logging.Logger, found bool, err error) {
    628 	for _, c := range configs {
    629 		if p, ok := c.(loggerProvider); ok {
    630 			l, found, err = p.getLogger(ctx)
    631 			if err != nil || found {
    632 				break
    633 			}
    634 		}
    635 	}
    636 	return
    637 }
    638 
    639 // clientLogModeProvider is an interface for retrieving the aws.ClientLogMode from a configuration source.
    640 type clientLogModeProvider interface {
    641 	getClientLogMode(ctx context.Context) (aws.ClientLogMode, bool, error)
    642 }
    643 
    644 func getClientLogMode(ctx context.Context, configs configs) (m aws.ClientLogMode, found bool, err error) {
    645 	for _, c := range configs {
    646 		if p, ok := c.(clientLogModeProvider); ok {
    647 			m, found, err = p.getClientLogMode(ctx)
    648 			if err != nil || found {
    649 				break
    650 			}
    651 		}
    652 	}
    653 	return
    654 }
    655 
    656 // retryProvider is an configuration provider for custom Retryer.
    657 type retryProvider interface {
    658 	getRetryer(ctx context.Context) (func() aws.Retryer, bool, error)
    659 }
    660 
    661 func getRetryer(ctx context.Context, configs configs) (v func() aws.Retryer, found bool, err error) {
    662 	for _, c := range configs {
    663 		if p, ok := c.(retryProvider); ok {
    664 			v, found, err = p.getRetryer(ctx)
    665 			if err != nil || found {
    666 				break
    667 			}
    668 		}
    669 	}
    670 	return
    671 }
    672 
    673 // logConfigurationWarningsProvider is an configuration provider for
    674 // retrieving a boolean indicating whether configuration issues should
    675 // be logged when loading from config sources
    676 type logConfigurationWarningsProvider interface {
    677 	getLogConfigurationWarnings(ctx context.Context) (bool, bool, error)
    678 }
    679 
    680 func getLogConfigurationWarnings(ctx context.Context, configs configs) (v bool, found bool, err error) {
    681 	for _, c := range configs {
    682 		if p, ok := c.(logConfigurationWarningsProvider); ok {
    683 			v, found, err = p.getLogConfigurationWarnings(ctx)
    684 			if err != nil || found {
    685 				break
    686 			}
    687 		}
    688 	}
    689 	return
    690 }
    691 
    692 // ssoCredentialOptionsProvider is an interface for retrieving a function for setting
    693 // the ssocreds.Options.
    694 type ssoCredentialOptionsProvider interface {
    695 	getSSOProviderOptions(context.Context) (func(*ssocreds.Options), bool, error)
    696 }
    697 
    698 func getSSOProviderOptions(ctx context.Context, configs configs) (v func(options *ssocreds.Options), found bool, err error) {
    699 	for _, c := range configs {
    700 		if p, ok := c.(ssoCredentialOptionsProvider); ok {
    701 			v, found, err = p.getSSOProviderOptions(ctx)
    702 			if err != nil || found {
    703 				break
    704 			}
    705 		}
    706 	}
    707 	return v, found, err
    708 }
    709 
    710 type defaultsModeIMDSClientProvider interface {
    711 	getDefaultsModeIMDSClient(context.Context) (*imds.Client, bool, error)
    712 }
    713 
    714 func getDefaultsModeIMDSClient(ctx context.Context, configs configs) (v *imds.Client, found bool, err error) {
    715 	for _, c := range configs {
    716 		if p, ok := c.(defaultsModeIMDSClientProvider); ok {
    717 			v, found, err = p.getDefaultsModeIMDSClient(ctx)
    718 			if err != nil || found {
    719 				break
    720 			}
    721 		}
    722 	}
    723 	return v, found, err
    724 }
    725 
    726 type defaultsModeProvider interface {
    727 	getDefaultsMode(context.Context) (aws.DefaultsMode, bool, error)
    728 }
    729 
    730 func getDefaultsMode(ctx context.Context, configs configs) (v aws.DefaultsMode, found bool, err error) {
    731 	for _, c := range configs {
    732 		if p, ok := c.(defaultsModeProvider); ok {
    733 			v, found, err = p.getDefaultsMode(ctx)
    734 			if err != nil || found {
    735 				break
    736 			}
    737 		}
    738 	}
    739 	return v, found, err
    740 }
    741 
    742 type retryMaxAttemptsProvider interface {
    743 	GetRetryMaxAttempts(context.Context) (int, bool, error)
    744 }
    745 
    746 func getRetryMaxAttempts(ctx context.Context, configs configs) (v int, found bool, err error) {
    747 	for _, c := range configs {
    748 		if p, ok := c.(retryMaxAttemptsProvider); ok {
    749 			v, found, err = p.GetRetryMaxAttempts(ctx)
    750 			if err != nil || found {
    751 				break
    752 			}
    753 		}
    754 	}
    755 	return v, found, err
    756 }
    757 
    758 type retryModeProvider interface {
    759 	GetRetryMode(context.Context) (aws.RetryMode, bool, error)
    760 }
    761 
    762 func getRetryMode(ctx context.Context, configs configs) (v aws.RetryMode, found bool, err error) {
    763 	for _, c := range configs {
    764 		if p, ok := c.(retryModeProvider); ok {
    765 			v, found, err = p.GetRetryMode(ctx)
    766 			if err != nil || found {
    767 				break
    768 			}
    769 		}
    770 	}
    771 	return v, found, err
    772 }
    773 
    774 func getAuthSchemePreference(ctx context.Context, configs configs) ([]string, bool) {
    775 	type provider interface {
    776 		getAuthSchemePreference() ([]string, bool)
    777 	}
    778 
    779 	for _, cfg := range configs {
    780 		if p, ok := cfg.(provider); ok {
    781 			if v, ok := p.getAuthSchemePreference(); ok {
    782 				return v, true
    783 			}
    784 		}
    785 	}
    786 	return nil, false
    787 }
    788 
    789 type serviceOptionsProvider interface {
    790 	getServiceOptions(ctx context.Context) ([]func(string, any), bool, error)
    791 }
    792 
    793 func getServiceOptions(ctx context.Context, configs configs) (v []func(string, any), found bool, err error) {
    794 	for _, c := range configs {
    795 		if p, ok := c.(serviceOptionsProvider); ok {
    796 			v, found, err = p.getServiceOptions(ctx)
    797 			if err != nil || found {
    798 				break
    799 			}
    800 		}
    801 	}
    802 	return v, found, err
    803 }
    804 
    805 type restrictFilePermissionsProvider interface {
    806 	getRestrictFilePermissions(context.Context) (aws.RestrictFilePermissions, bool, error)
    807 }
    808 
    809 func getRestrictFilePermissions(ctx context.Context, configs configs) (value aws.RestrictFilePermissions, found bool, err error) {
    810 	for _, cfg := range configs {
    811 		if p, ok := cfg.(restrictFilePermissionsProvider); ok {
    812 			value, found, err = p.getRestrictFilePermissions(ctx)
    813 			if err != nil || found {
    814 				break
    815 			}
    816 		}
    817 	}
    818 	return
    819 }