express_resolve.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package s3
  2. import (
  3. "github.com/aws/aws-sdk-go-v2/aws"
  4. "github.com/aws/aws-sdk-go-v2/service/s3/internal/customizations"
  5. )
  6. // If the caller hasn't provided an S3Express provider, we use our default
  7. // which will grab a reference to the S3 client itself in finalization.
  8. func resolveExpressCredentials(o *Options) {
  9. if o.ExpressCredentials == nil {
  10. o.ExpressCredentials = newDefaultS3ExpressCredentialsProvider()
  11. }
  12. }
  13. // Config finalizer: if we're using the default S3Express implementation, grab
  14. // a reference to the client for its CreateSession API, and the underlying
  15. // sigv4 credentials provider for cache keying.
  16. func finalizeExpressCredentials(o *Options, c *Client) {
  17. if p, ok := o.ExpressCredentials.(*defaultS3ExpressCredentialsProvider); ok {
  18. p.client = c
  19. p.v4creds = o.Credentials
  20. }
  21. }
  22. // Operation config finalizer: update the sigv4 credentials on the default
  23. // express provider in case it changed to ensure different cache keys
  24. func finalizeOperationExpressCredentials(o *Options, c Client) {
  25. if p, ok := o.ExpressCredentials.(*defaultS3ExpressCredentialsProvider); ok {
  26. o.ExpressCredentials = p.CloneWithBaseCredentials(o.Credentials)
  27. }
  28. }
  29. // NewFromConfig resolver: pull from opaque sources if it exists.
  30. func resolveDisableExpressAuth(cfg aws.Config, o *Options) {
  31. if v, ok := customizations.ResolveDisableExpressAuth(cfg.ConfigSources); ok {
  32. o.DisableS3ExpressSessionAuth = &v
  33. }
  34. }