]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blobdiff - vendor/github.com/aws/aws-sdk-go/aws/session/session.go
deps: use go modules for dep mgmt
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / aws / aws-sdk-go / aws / session / session.go
index 4792d3ae8a1427bf9a0941dfc029d18730f791b5..9f75d5ac58893649ec434894bbbdb01ecaff00bb 100644 (file)
@@ -155,6 +155,10 @@ type Options struct {
        // and enable or disable the shared config functionality.
        SharedConfigState SharedConfigState
 
+       // Ordered list of files the session will load configuration from.
+       // It will override environment variable AWS_SHARED_CREDENTIALS_FILE, AWS_CONFIG_FILE.
+       SharedConfigFiles []string
+
        // When the SDK's shared config is configured to assume a role with MFA
        // this option is required in order to provide the mechanism that will
        // retrieve the MFA token. There is no default value for this field. If
@@ -239,6 +243,13 @@ func NewSessionWithOptions(opts Options) (*Session, error) {
                envCfg.EnableSharedConfig = true
        }
 
+       if len(envCfg.SharedCredentialsFile) == 0 {
+               envCfg.SharedCredentialsFile = defaults.SharedCredentialsFilename()
+       }
+       if len(envCfg.SharedConfigFile) == 0 {
+               envCfg.SharedConfigFile = defaults.SharedConfigFilename()
+       }
+
        // Only use AWS_CA_BUNDLE if session option is not provided.
        if len(envCfg.CustomCABundle) != 0 && opts.CustomCABundle == nil {
                f, err := os.Open(envCfg.CustomCABundle)
@@ -304,13 +315,18 @@ func newSession(opts Options, envCfg envConfig, cfgs ...*aws.Config) (*Session,
        userCfg := &aws.Config{}
        userCfg.MergeIn(cfgs...)
 
-       // Order config files will be loaded in with later files overwriting
+       // Ordered config files will be loaded in with later files overwriting
        // previous config file values.
-       cfgFiles := []string{envCfg.SharedConfigFile, envCfg.SharedCredentialsFile}
-       if !envCfg.EnableSharedConfig {
-               // The shared config file (~/.aws/config) is only loaded if instructed
-               // to load via the envConfig.EnableSharedConfig (AWS_SDK_LOAD_CONFIG).
-               cfgFiles = cfgFiles[1:]
+       var cfgFiles []string
+       if opts.SharedConfigFiles != nil {
+               cfgFiles = opts.SharedConfigFiles
+       } else {
+               cfgFiles = []string{envCfg.SharedConfigFile, envCfg.SharedCredentialsFile}
+               if !envCfg.EnableSharedConfig {
+                       // The shared config file (~/.aws/config) is only loaded if instructed
+                       // to load via the envConfig.EnableSharedConfig (AWS_SDK_LOAD_CONFIG).
+                       cfgFiles = cfgFiles[1:]
+               }
        }
 
        // Load additional config from file(s)