aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/aws/aws-sdk-go/aws/session/env_config.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/aws/aws-sdk-go/aws/session/env_config.go')
-rw-r--r--vendor/github.com/aws/aws-sdk-go/aws/session/env_config.go43
1 files changed, 13 insertions, 30 deletions
diff --git a/vendor/github.com/aws/aws-sdk-go/aws/session/env_config.go b/vendor/github.com/aws/aws-sdk-go/aws/session/env_config.go
index e6278a7..f1adcf4 100644
--- a/vendor/github.com/aws/aws-sdk-go/aws/session/env_config.go
+++ b/vendor/github.com/aws/aws-sdk-go/aws/session/env_config.go
@@ -2,12 +2,14 @@ package session
import (
"os"
- "path/filepath"
"strconv"
"github.com/aws/aws-sdk-go/aws/credentials"
)
+// 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
@@ -77,7 +79,7 @@ type envConfig struct {
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.
+ // 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.
//
@@ -116,6 +118,12 @@ var (
"AWS_PROFILE",
"AWS_DEFAULT_PROFILE", // Only read if AWS_SDK_LOAD_CONFIG is also set
}
+ sharedCredsFileEnvKey = []string{
+ "AWS_SHARED_CREDENTIALS_FILE",
+ }
+ sharedConfigFileEnvKey = []string{
+ "AWS_CONFIG_FILE",
+ }
)
// loadEnvConfig retrieves the SDK's environment configuration.
@@ -152,7 +160,7 @@ func envConfigLoad(enableSharedConfig bool) envConfig {
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
@@ -165,8 +173,8 @@ func envConfigLoad(enableSharedConfig bool) envConfig {
setFromEnvVal(&cfg.Region, regionKeys)
setFromEnvVal(&cfg.Profile, profileKeys)
- cfg.SharedCredentialsFile = sharedCredentialsFilename()
- cfg.SharedConfigFile = sharedConfigFilename()
+ setFromEnvVal(&cfg.SharedCredentialsFile, sharedCredsFileEnvKey)
+ setFromEnvVal(&cfg.SharedConfigFile, sharedConfigFileEnvKey)
cfg.CustomCABundle = os.Getenv("AWS_CA_BUNDLE")
@@ -181,28 +189,3 @@ func setFromEnvVal(dst *string, keys []string) {
}
}
}
-
-func sharedCredentialsFilename() string {
- if name := os.Getenv("AWS_SHARED_CREDENTIALS_FILE"); len(name) > 0 {
- return name
- }
-
- return filepath.Join(userHomeDir(), ".aws", "credentials")
-}
-
-func sharedConfigFilename() string {
- if name := os.Getenv("AWS_CONFIG_FILE"); len(name) > 0 {
- return name
- }
-
- return filepath.Join(userHomeDir(), ".aws", "config")
-}
-
-func userHomeDir() string {
- homeDir := os.Getenv("HOME") // *nix
- if len(homeDir) == 0 { // windows
- homeDir = os.Getenv("USERPROFILE")
- }
-
- return homeDir
-}