...

Source file src/github.com/aws/aws-sdk-go-v2/config/provider.go

Documentation: github.com/aws/aws-sdk-go-v2/config

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

View as plain text