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