]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blobdiff - vendor/github.com/aws/aws-sdk-go/aws/session/env_config.go
Upgrade to 0.12
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / aws / aws-sdk-go / aws / session / env_config.go
index 7357e545acdfaef2e15a959f2f75be22610f936b..e3959b959ef936f6b39d2fa5ee3fa31ebe840609 100644 (file)
@@ -4,9 +4,14 @@ import (
        "os"
        "strconv"
 
+       "github.com/aws/aws-sdk-go/aws"
        "github.com/aws/aws-sdk-go/aws/credentials"
+       "github.com/aws/aws-sdk-go/aws/defaults"
 )
 
+// EnvProviderName provides a name of the provider when config is loaded from environment.
+const EnvProviderName = "EnvConfigCredentials"
+
 // envConfig is a collection of environment values the SDK will read
 // setup config from. All environment values are optional. But some values
 // such as credentials require multiple values to be complete or the values
@@ -75,8 +80,8 @@ type envConfig struct {
        //      AWS_CONFIG_FILE=$HOME/my_shared_config
        SharedConfigFile string
 
-       // Sets the path to a custom Credentials Authroity (CA) Bundle PEM file
-       // that the SDK will use instead of the the system's root CA bundle.
+       // Sets the path to a custom Credentials Authority (CA) Bundle PEM file
+       // that the SDK will use instead of the system's root CA bundle.
        // Only use this if you want to configure the SDK to use a custom set
        // of CAs.
        //
@@ -92,9 +97,29 @@ type envConfig struct {
        //
        //  AWS_CA_BUNDLE=$HOME/my_custom_ca_bundle
        CustomCABundle string
+
+       csmEnabled  string
+       CSMEnabled  bool
+       CSMPort     string
+       CSMClientID string
+
+       enableEndpointDiscovery string
+       // Enables endpoint discovery via environment variables.
+       //
+       //      AWS_ENABLE_ENDPOINT_DISCOVERY=true
+       EnableEndpointDiscovery *bool
 }
 
 var (
+       csmEnabledEnvKey = []string{
+               "AWS_CSM_ENABLED",
+       }
+       csmPortEnvKey = []string{
+               "AWS_CSM_PORT",
+       }
+       csmClientIDEnvKey = []string{
+               "AWS_CSM_CLIENT_ID",
+       }
        credAccessEnvKey = []string{
                "AWS_ACCESS_KEY_ID",
                "AWS_ACCESS_KEY",
@@ -107,6 +132,10 @@ var (
                "AWS_SESSION_TOKEN",
        }
 
+       enableEndpointDiscoveryEnvKey = []string{
+               "AWS_ENABLE_ENDPOINT_DISCOVERY",
+       }
+
        regionEnvKeys = []string{
                "AWS_REGION",
                "AWS_DEFAULT_REGION", // Only read if AWS_SDK_LOAD_CONFIG is also set
@@ -153,11 +182,17 @@ func envConfigLoad(enableSharedConfig bool) envConfig {
        setFromEnvVal(&cfg.Creds.SecretAccessKey, credSecretEnvKey)
        setFromEnvVal(&cfg.Creds.SessionToken, credSessionEnvKey)
 
+       // CSM environment variables
+       setFromEnvVal(&cfg.csmEnabled, csmEnabledEnvKey)
+       setFromEnvVal(&cfg.CSMPort, csmPortEnvKey)
+       setFromEnvVal(&cfg.CSMClientID, csmClientIDEnvKey)
+       cfg.CSMEnabled = len(cfg.csmEnabled) > 0
+
        // Require logical grouping of credentials
        if len(cfg.Creds.AccessKeyID) == 0 || len(cfg.Creds.SecretAccessKey) == 0 {
                cfg.Creds = credentials.Value{}
        } else {
-               cfg.Creds.ProviderName = "EnvConfigCredentials"
+               cfg.Creds.ProviderName = EnvProviderName
        }
 
        regionKeys := regionEnvKeys
@@ -170,9 +205,22 @@ func envConfigLoad(enableSharedConfig bool) envConfig {
        setFromEnvVal(&cfg.Region, regionKeys)
        setFromEnvVal(&cfg.Profile, profileKeys)
 
+       // endpoint discovery is in reference to it being enabled.
+       setFromEnvVal(&cfg.enableEndpointDiscovery, enableEndpointDiscoveryEnvKey)
+       if len(cfg.enableEndpointDiscovery) > 0 {
+               cfg.EnableEndpointDiscovery = aws.Bool(cfg.enableEndpointDiscovery != "false")
+       }
+
        setFromEnvVal(&cfg.SharedCredentialsFile, sharedCredsFileEnvKey)
        setFromEnvVal(&cfg.SharedConfigFile, sharedConfigFileEnvKey)
 
+       if len(cfg.SharedCredentialsFile) == 0 {
+               cfg.SharedCredentialsFile = defaults.SharedCredentialsFilename()
+       }
+       if len(cfg.SharedConfigFile) == 0 {
+               cfg.SharedConfigFile = defaults.SharedConfigFilename()
+       }
+
        cfg.CustomCABundle = os.Getenv("AWS_CA_BUNDLE")
 
        return cfg