provider.go raw

   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 []interface{}) (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  // requestMinCompressSizeBytesProvider provides access to the MinCompressSizeBytes
 212  type requestMinCompressSizeBytesProvider interface {
 213  	getRequestMinCompressSizeBytes(context.Context) (int64, bool, error)
 214  }
 215  
 216  func getRequestMinCompressSizeBytes(ctx context.Context, configs configs) (value int64, found bool, err error) {
 217  	for _, cfg := range configs {
 218  		if p, ok := cfg.(requestMinCompressSizeBytesProvider); ok {
 219  			value, found, err = p.getRequestMinCompressSizeBytes(ctx)
 220  			if err != nil || found {
 221  				break
 222  			}
 223  		}
 224  	}
 225  	return
 226  }
 227  
 228  // accountIDEndpointModeProvider provides access to the AccountIDEndpointMode
 229  type accountIDEndpointModeProvider interface {
 230  	getAccountIDEndpointMode(context.Context) (aws.AccountIDEndpointMode, bool, error)
 231  }
 232  
 233  func getAccountIDEndpointMode(ctx context.Context, configs configs) (value aws.AccountIDEndpointMode, found bool, err error) {
 234  	for _, cfg := range configs {
 235  		if p, ok := cfg.(accountIDEndpointModeProvider); ok {
 236  			value, found, err = p.getAccountIDEndpointMode(ctx)
 237  			if err != nil || found {
 238  				break
 239  			}
 240  		}
 241  	}
 242  	return
 243  }
 244  
 245  // requestChecksumCalculationProvider provides access to the RequestChecksumCalculation
 246  type requestChecksumCalculationProvider interface {
 247  	getRequestChecksumCalculation(context.Context) (aws.RequestChecksumCalculation, bool, error)
 248  }
 249  
 250  func getRequestChecksumCalculation(ctx context.Context, configs configs) (value aws.RequestChecksumCalculation, found bool, err error) {
 251  	for _, cfg := range configs {
 252  		if p, ok := cfg.(requestChecksumCalculationProvider); ok {
 253  			value, found, err = p.getRequestChecksumCalculation(ctx)
 254  			if err != nil || found {
 255  				break
 256  			}
 257  		}
 258  	}
 259  	return
 260  }
 261  
 262  // responseChecksumValidationProvider provides access to the ResponseChecksumValidation
 263  type responseChecksumValidationProvider interface {
 264  	getResponseChecksumValidation(context.Context) (aws.ResponseChecksumValidation, bool, error)
 265  }
 266  
 267  func getResponseChecksumValidation(ctx context.Context, configs configs) (value aws.ResponseChecksumValidation, found bool, err error) {
 268  	for _, cfg := range configs {
 269  		if p, ok := cfg.(responseChecksumValidationProvider); ok {
 270  			value, found, err = p.getResponseChecksumValidation(ctx)
 271  			if err != nil || found {
 272  				break
 273  			}
 274  		}
 275  	}
 276  	return
 277  }
 278  
 279  // ec2IMDSRegionProvider provides access to the ec2 imds region
 280  // configuration value
 281  type ec2IMDSRegionProvider interface {
 282  	getEC2IMDSRegion(ctx context.Context) (string, bool, error)
 283  }
 284  
 285  // getEC2IMDSRegion searches the configs for a ec2IMDSRegionProvider and
 286  // returns the value if found. Returns an error if a provider fails before
 287  // a value is found.
 288  func getEC2IMDSRegion(ctx context.Context, configs configs) (region string, found bool, err error) {
 289  	for _, cfg := range configs {
 290  		if provider, ok := cfg.(ec2IMDSRegionProvider); ok {
 291  			region, found, err = provider.getEC2IMDSRegion(ctx)
 292  			if err != nil || found {
 293  				break
 294  			}
 295  		}
 296  	}
 297  	return
 298  }
 299  
 300  // credentialsProviderProvider provides access to the credentials external
 301  // configuration value.
 302  type credentialsProviderProvider interface {
 303  	getCredentialsProvider(ctx context.Context) (aws.CredentialsProvider, bool, error)
 304  }
 305  
 306  // getCredentialsProvider searches the configs for a credentialsProviderProvider
 307  // and returns the value if found. Returns an error if a provider fails before a
 308  // value is found.
 309  func getCredentialsProvider(ctx context.Context, configs configs) (p aws.CredentialsProvider, found bool, err error) {
 310  	for _, cfg := range configs {
 311  		if provider, ok := cfg.(credentialsProviderProvider); ok {
 312  			p, found, err = provider.getCredentialsProvider(ctx)
 313  			if err != nil || found {
 314  				break
 315  			}
 316  		}
 317  	}
 318  	return
 319  }
 320  
 321  // credentialsCacheOptionsProvider is an interface for retrieving a function for setting
 322  // the aws.CredentialsCacheOptions.
 323  type credentialsCacheOptionsProvider interface {
 324  	getCredentialsCacheOptions(ctx context.Context) (func(*aws.CredentialsCacheOptions), bool, error)
 325  }
 326  
 327  // getCredentialsCacheOptionsProvider is an interface for retrieving a function for setting
 328  // the aws.CredentialsCacheOptions.
 329  func getCredentialsCacheOptionsProvider(ctx context.Context, configs configs) (
 330  	f func(*aws.CredentialsCacheOptions), found bool, err error,
 331  ) {
 332  	for _, config := range configs {
 333  		if p, ok := config.(credentialsCacheOptionsProvider); ok {
 334  			f, found, err = p.getCredentialsCacheOptions(ctx)
 335  			if err != nil || found {
 336  				break
 337  			}
 338  		}
 339  	}
 340  	return
 341  }
 342  
 343  // bearerAuthTokenProviderProvider provides access to the bearer authentication
 344  // token external configuration value.
 345  type bearerAuthTokenProviderProvider interface {
 346  	getBearerAuthTokenProvider(context.Context) (smithybearer.TokenProvider, bool, error)
 347  }
 348  
 349  // getBearerAuthTokenProvider searches the config sources for a
 350  // bearerAuthTokenProviderProvider and returns the value if found. Returns an
 351  // error if a provider fails before a value is found.
 352  func getBearerAuthTokenProvider(ctx context.Context, configs configs) (p smithybearer.TokenProvider, found bool, err error) {
 353  	for _, cfg := range configs {
 354  		if provider, ok := cfg.(bearerAuthTokenProviderProvider); ok {
 355  			p, found, err = provider.getBearerAuthTokenProvider(ctx)
 356  			if err != nil || found {
 357  				break
 358  			}
 359  		}
 360  	}
 361  	return
 362  }
 363  
 364  // bearerAuthTokenCacheOptionsProvider is an interface for retrieving a function for
 365  // setting the smithy-go auth/bearer#TokenCacheOptions.
 366  type bearerAuthTokenCacheOptionsProvider interface {
 367  	getBearerAuthTokenCacheOptions(context.Context) (func(*smithybearer.TokenCacheOptions), bool, error)
 368  }
 369  
 370  // getBearerAuthTokenCacheOptionsProvider is an interface for retrieving a function for
 371  // setting the smithy-go auth/bearer#TokenCacheOptions.
 372  func getBearerAuthTokenCacheOptions(ctx context.Context, configs configs) (
 373  	f func(*smithybearer.TokenCacheOptions), found bool, err error,
 374  ) {
 375  	for _, config := range configs {
 376  		if p, ok := config.(bearerAuthTokenCacheOptionsProvider); ok {
 377  			f, found, err = p.getBearerAuthTokenCacheOptions(ctx)
 378  			if err != nil || found {
 379  				break
 380  			}
 381  		}
 382  	}
 383  	return
 384  }
 385  
 386  // ssoTokenProviderOptionsProvider is an interface for retrieving a function for
 387  // setting the SDK's credentials/ssocreds#SSOTokenProviderOptions.
 388  type ssoTokenProviderOptionsProvider interface {
 389  	getSSOTokenProviderOptions(context.Context) (func(*ssocreds.SSOTokenProviderOptions), bool, error)
 390  }
 391  
 392  // getSSOTokenProviderOptions is an interface for retrieving a function for
 393  // setting the SDK's credentials/ssocreds#SSOTokenProviderOptions.
 394  func getSSOTokenProviderOptions(ctx context.Context, configs configs) (
 395  	f func(*ssocreds.SSOTokenProviderOptions), found bool, err error,
 396  ) {
 397  	for _, config := range configs {
 398  		if p, ok := config.(ssoTokenProviderOptionsProvider); ok {
 399  			f, found, err = p.getSSOTokenProviderOptions(ctx)
 400  			if err != nil || found {
 401  				break
 402  			}
 403  		}
 404  	}
 405  	return
 406  }
 407  
 408  // ssoTokenProviderOptionsProvider
 409  
 410  // processCredentialOptions is an interface for retrieving a function for setting
 411  // the processcreds.Options.
 412  type processCredentialOptions interface {
 413  	getProcessCredentialOptions(ctx context.Context) (func(*processcreds.Options), bool, error)
 414  }
 415  
 416  // getProcessCredentialOptions searches the slice of configs and returns the first function found
 417  func getProcessCredentialOptions(ctx context.Context, configs configs) (f func(*processcreds.Options), found bool, err error) {
 418  	for _, config := range configs {
 419  		if p, ok := config.(processCredentialOptions); ok {
 420  			f, found, err = p.getProcessCredentialOptions(ctx)
 421  			if err != nil || found {
 422  				break
 423  			}
 424  		}
 425  	}
 426  	return
 427  }
 428  
 429  // ec2RoleCredentialOptionsProvider is an interface for retrieving a function
 430  // for setting the ec2rolecreds.Provider options.
 431  type ec2RoleCredentialOptionsProvider interface {
 432  	getEC2RoleCredentialOptions(ctx context.Context) (func(*ec2rolecreds.Options), bool, error)
 433  }
 434  
 435  // getEC2RoleCredentialProviderOptions searches the slice of configs and returns the first function found
 436  func getEC2RoleCredentialProviderOptions(ctx context.Context, configs configs) (f func(*ec2rolecreds.Options), found bool, err error) {
 437  	for _, config := range configs {
 438  		if p, ok := config.(ec2RoleCredentialOptionsProvider); ok {
 439  			f, found, err = p.getEC2RoleCredentialOptions(ctx)
 440  			if err != nil || found {
 441  				break
 442  			}
 443  		}
 444  	}
 445  	return
 446  }
 447  
 448  // defaultRegionProvider is an interface for retrieving a default region if a region was not resolved from other sources
 449  type defaultRegionProvider interface {
 450  	getDefaultRegion(ctx context.Context) (string, bool, error)
 451  }
 452  
 453  // getDefaultRegion searches the slice of configs and returns the first fallback region found
 454  func getDefaultRegion(ctx context.Context, configs configs) (value string, found bool, err error) {
 455  	for _, config := range configs {
 456  		if p, ok := config.(defaultRegionProvider); ok {
 457  			value, found, err = p.getDefaultRegion(ctx)
 458  			if err != nil || found {
 459  				break
 460  			}
 461  		}
 462  	}
 463  	return
 464  }
 465  
 466  // endpointCredentialOptionsProvider is an interface for retrieving a function for setting
 467  // the endpointcreds.ProviderOptions.
 468  type endpointCredentialOptionsProvider interface {
 469  	getEndpointCredentialOptions(ctx context.Context) (func(*endpointcreds.Options), bool, error)
 470  }
 471  
 472  // getEndpointCredentialProviderOptions searches the slice of configs and returns the first function found
 473  func getEndpointCredentialProviderOptions(ctx context.Context, configs configs) (f func(*endpointcreds.Options), found bool, err error) {
 474  	for _, config := range configs {
 475  		if p, ok := config.(endpointCredentialOptionsProvider); ok {
 476  			f, found, err = p.getEndpointCredentialOptions(ctx)
 477  			if err != nil || found {
 478  				break
 479  			}
 480  		}
 481  	}
 482  	return
 483  }
 484  
 485  // webIdentityRoleCredentialOptionsProvider is an interface for retrieving a function for setting
 486  // the stscreds.WebIdentityRoleProvider.
 487  type webIdentityRoleCredentialOptionsProvider interface {
 488  	getWebIdentityRoleCredentialOptions(ctx context.Context) (func(*stscreds.WebIdentityRoleOptions), bool, error)
 489  }
 490  
 491  // getWebIdentityCredentialProviderOptions searches the slice of configs and returns the first function found
 492  func getWebIdentityCredentialProviderOptions(ctx context.Context, configs configs) (f func(*stscreds.WebIdentityRoleOptions), found bool, err error) {
 493  	for _, config := range configs {
 494  		if p, ok := config.(webIdentityRoleCredentialOptionsProvider); ok {
 495  			f, found, err = p.getWebIdentityRoleCredentialOptions(ctx)
 496  			if err != nil || found {
 497  				break
 498  			}
 499  		}
 500  	}
 501  	return
 502  }
 503  
 504  // assumeRoleCredentialOptionsProvider is an interface for retrieving a function for setting
 505  // the stscreds.AssumeRoleOptions.
 506  type assumeRoleCredentialOptionsProvider interface {
 507  	getAssumeRoleCredentialOptions(ctx context.Context) (func(*stscreds.AssumeRoleOptions), bool, error)
 508  }
 509  
 510  // getAssumeRoleCredentialProviderOptions searches the slice of configs and returns the first function found
 511  func getAssumeRoleCredentialProviderOptions(ctx context.Context, configs configs) (f func(*stscreds.AssumeRoleOptions), found bool, err error) {
 512  	for _, config := range configs {
 513  		if p, ok := config.(assumeRoleCredentialOptionsProvider); ok {
 514  			f, found, err = p.getAssumeRoleCredentialOptions(ctx)
 515  			if err != nil || found {
 516  				break
 517  			}
 518  		}
 519  	}
 520  	return
 521  }
 522  
 523  // HTTPClient is an HTTP client implementation
 524  type HTTPClient interface {
 525  	Do(*http.Request) (*http.Response, error)
 526  }
 527  
 528  // httpClientProvider is an interface for retrieving HTTPClient
 529  type httpClientProvider interface {
 530  	getHTTPClient(ctx context.Context) (HTTPClient, bool, error)
 531  }
 532  
 533  // getHTTPClient searches the slice of configs and returns the HTTPClient set on configs
 534  func getHTTPClient(ctx context.Context, configs configs) (client HTTPClient, found bool, err error) {
 535  	for _, config := range configs {
 536  		if p, ok := config.(httpClientProvider); ok {
 537  			client, found, err = p.getHTTPClient(ctx)
 538  			if err != nil || found {
 539  				break
 540  			}
 541  		}
 542  	}
 543  	return
 544  }
 545  
 546  // apiOptionsProvider is an interface for retrieving APIOptions
 547  type apiOptionsProvider interface {
 548  	getAPIOptions(ctx context.Context) ([]func(*middleware.Stack) error, bool, error)
 549  }
 550  
 551  // getAPIOptions searches the slice of configs and returns the APIOptions set on configs
 552  func getAPIOptions(ctx context.Context, configs configs) (apiOptions []func(*middleware.Stack) error, found bool, err error) {
 553  	for _, config := range configs {
 554  		if p, ok := config.(apiOptionsProvider); ok {
 555  			// retrieve APIOptions from configs and set it on cfg
 556  			apiOptions, found, err = p.getAPIOptions(ctx)
 557  			if err != nil || found {
 558  				break
 559  			}
 560  		}
 561  	}
 562  	return
 563  }
 564  
 565  // endpointResolverProvider is an interface for retrieving an aws.EndpointResolver from a configuration source
 566  type endpointResolverProvider interface {
 567  	getEndpointResolver(ctx context.Context) (aws.EndpointResolver, bool, error)
 568  }
 569  
 570  // getEndpointResolver searches the provided config sources for a EndpointResolverFunc that can be used
 571  // to configure the aws.Config.EndpointResolver value.
 572  func getEndpointResolver(ctx context.Context, configs configs) (f aws.EndpointResolver, found bool, err error) {
 573  	for _, c := range configs {
 574  		if p, ok := c.(endpointResolverProvider); ok {
 575  			f, found, err = p.getEndpointResolver(ctx)
 576  			if err != nil || found {
 577  				break
 578  			}
 579  		}
 580  	}
 581  	return
 582  }
 583  
 584  // endpointResolverWithOptionsProvider is an interface for retrieving an aws.EndpointResolverWithOptions from a configuration source
 585  type endpointResolverWithOptionsProvider interface {
 586  	getEndpointResolverWithOptions(ctx context.Context) (aws.EndpointResolverWithOptions, bool, error)
 587  }
 588  
 589  // getEndpointResolver searches the provided config sources for a EndpointResolverFunc that can be used
 590  // to configure the aws.Config.EndpointResolver value.
 591  func getEndpointResolverWithOptions(ctx context.Context, configs configs) (f aws.EndpointResolverWithOptions, found bool, err error) {
 592  	for _, c := range configs {
 593  		if p, ok := c.(endpointResolverWithOptionsProvider); ok {
 594  			f, found, err = p.getEndpointResolverWithOptions(ctx)
 595  			if err != nil || found {
 596  				break
 597  			}
 598  		}
 599  	}
 600  	return
 601  }
 602  
 603  // loggerProvider is an interface for retrieving a logging.Logger from a configuration source.
 604  type loggerProvider interface {
 605  	getLogger(ctx context.Context) (logging.Logger, bool, error)
 606  }
 607  
 608  // getLogger searches the provided config sources for a logging.Logger that can be used
 609  // to configure the aws.Config.Logger value.
 610  func getLogger(ctx context.Context, configs configs) (l logging.Logger, found bool, err error) {
 611  	for _, c := range configs {
 612  		if p, ok := c.(loggerProvider); ok {
 613  			l, found, err = p.getLogger(ctx)
 614  			if err != nil || found {
 615  				break
 616  			}
 617  		}
 618  	}
 619  	return
 620  }
 621  
 622  // clientLogModeProvider is an interface for retrieving the aws.ClientLogMode from a configuration source.
 623  type clientLogModeProvider interface {
 624  	getClientLogMode(ctx context.Context) (aws.ClientLogMode, bool, error)
 625  }
 626  
 627  func getClientLogMode(ctx context.Context, configs configs) (m aws.ClientLogMode, found bool, err error) {
 628  	for _, c := range configs {
 629  		if p, ok := c.(clientLogModeProvider); ok {
 630  			m, found, err = p.getClientLogMode(ctx)
 631  			if err != nil || found {
 632  				break
 633  			}
 634  		}
 635  	}
 636  	return
 637  }
 638  
 639  // retryProvider is an configuration provider for custom Retryer.
 640  type retryProvider interface {
 641  	getRetryer(ctx context.Context) (func() aws.Retryer, bool, error)
 642  }
 643  
 644  func getRetryer(ctx context.Context, configs configs) (v func() aws.Retryer, found bool, err error) {
 645  	for _, c := range configs {
 646  		if p, ok := c.(retryProvider); ok {
 647  			v, found, err = p.getRetryer(ctx)
 648  			if err != nil || found {
 649  				break
 650  			}
 651  		}
 652  	}
 653  	return
 654  }
 655  
 656  // logConfigurationWarningsProvider is an configuration provider for
 657  // retrieving a boolean indicating whether configuration issues should
 658  // be logged when loading from config sources
 659  type logConfigurationWarningsProvider interface {
 660  	getLogConfigurationWarnings(ctx context.Context) (bool, bool, error)
 661  }
 662  
 663  func getLogConfigurationWarnings(ctx context.Context, configs configs) (v bool, found bool, err error) {
 664  	for _, c := range configs {
 665  		if p, ok := c.(logConfigurationWarningsProvider); ok {
 666  			v, found, err = p.getLogConfigurationWarnings(ctx)
 667  			if err != nil || found {
 668  				break
 669  			}
 670  		}
 671  	}
 672  	return
 673  }
 674  
 675  // ssoCredentialOptionsProvider is an interface for retrieving a function for setting
 676  // the ssocreds.Options.
 677  type ssoCredentialOptionsProvider interface {
 678  	getSSOProviderOptions(context.Context) (func(*ssocreds.Options), bool, error)
 679  }
 680  
 681  func getSSOProviderOptions(ctx context.Context, configs configs) (v func(options *ssocreds.Options), found bool, err error) {
 682  	for _, c := range configs {
 683  		if p, ok := c.(ssoCredentialOptionsProvider); ok {
 684  			v, found, err = p.getSSOProviderOptions(ctx)
 685  			if err != nil || found {
 686  				break
 687  			}
 688  		}
 689  	}
 690  	return v, found, err
 691  }
 692  
 693  type defaultsModeIMDSClientProvider interface {
 694  	getDefaultsModeIMDSClient(context.Context) (*imds.Client, bool, error)
 695  }
 696  
 697  func getDefaultsModeIMDSClient(ctx context.Context, configs configs) (v *imds.Client, found bool, err error) {
 698  	for _, c := range configs {
 699  		if p, ok := c.(defaultsModeIMDSClientProvider); ok {
 700  			v, found, err = p.getDefaultsModeIMDSClient(ctx)
 701  			if err != nil || found {
 702  				break
 703  			}
 704  		}
 705  	}
 706  	return v, found, err
 707  }
 708  
 709  type defaultsModeProvider interface {
 710  	getDefaultsMode(context.Context) (aws.DefaultsMode, bool, error)
 711  }
 712  
 713  func getDefaultsMode(ctx context.Context, configs configs) (v aws.DefaultsMode, found bool, err error) {
 714  	for _, c := range configs {
 715  		if p, ok := c.(defaultsModeProvider); ok {
 716  			v, found, err = p.getDefaultsMode(ctx)
 717  			if err != nil || found {
 718  				break
 719  			}
 720  		}
 721  	}
 722  	return v, found, err
 723  }
 724  
 725  type retryMaxAttemptsProvider interface {
 726  	GetRetryMaxAttempts(context.Context) (int, bool, error)
 727  }
 728  
 729  func getRetryMaxAttempts(ctx context.Context, configs configs) (v int, found bool, err error) {
 730  	for _, c := range configs {
 731  		if p, ok := c.(retryMaxAttemptsProvider); ok {
 732  			v, found, err = p.GetRetryMaxAttempts(ctx)
 733  			if err != nil || found {
 734  				break
 735  			}
 736  		}
 737  	}
 738  	return v, found, err
 739  }
 740  
 741  type retryModeProvider interface {
 742  	GetRetryMode(context.Context) (aws.RetryMode, bool, error)
 743  }
 744  
 745  func getRetryMode(ctx context.Context, configs configs) (v aws.RetryMode, found bool, err error) {
 746  	for _, c := range configs {
 747  		if p, ok := c.(retryModeProvider); ok {
 748  			v, found, err = p.GetRetryMode(ctx)
 749  			if err != nil || found {
 750  				break
 751  			}
 752  		}
 753  	}
 754  	return v, found, err
 755  }
 756  
 757  func getAuthSchemePreference(ctx context.Context, configs configs) ([]string, bool) {
 758  	type provider interface {
 759  		getAuthSchemePreference() ([]string, bool)
 760  	}
 761  
 762  	for _, cfg := range configs {
 763  		if p, ok := cfg.(provider); ok {
 764  			if v, ok := p.getAuthSchemePreference(); ok {
 765  				return v, true
 766  			}
 767  		}
 768  	}
 769  	return nil, false
 770  }
 771  
 772  type serviceOptionsProvider interface {
 773  	getServiceOptions(ctx context.Context) ([]func(string, any), bool, error)
 774  }
 775  
 776  func getServiceOptions(ctx context.Context, configs configs) (v []func(string, any), found bool, err error) {
 777  	for _, c := range configs {
 778  		if p, ok := c.(serviceOptionsProvider); ok {
 779  			v, found, err = p.getServiceOptions(ctx)
 780  			if err != nil || found {
 781  				break
 782  			}
 783  		}
 784  	}
 785  	return v, found, err
 786  }
 787