aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go')
-rw-r--r--vendor/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go33
1 files changed, 16 insertions, 17 deletions
diff --git a/vendor/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go b/vendor/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go
index 7fb7cbf..51e21e0 100644
--- a/vendor/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go
+++ b/vendor/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go
@@ -3,11 +3,11 @@ package credentials
3import ( 3import (
4 "fmt" 4 "fmt"
5 "os" 5 "os"
6 "path/filepath"
7 6
8 "github.com/go-ini/ini" 7 "github.com/go-ini/ini"
9 8
10 "github.com/aws/aws-sdk-go/aws/awserr" 9 "github.com/aws/aws-sdk-go/aws/awserr"
10 "github.com/aws/aws-sdk-go/internal/shareddefaults"
11) 11)
12 12
13// SharedCredsProviderName provides a name of SharedCreds provider 13// SharedCredsProviderName provides a name of SharedCreds provider
@@ -15,8 +15,6 @@ const SharedCredsProviderName = "SharedCredentialsProvider"
15 15
16var ( 16var (
17 // ErrSharedCredentialsHomeNotFound is emitted when the user directory cannot be found. 17 // ErrSharedCredentialsHomeNotFound is emitted when the user directory cannot be found.
18 //
19 // @readonly
20 ErrSharedCredentialsHomeNotFound = awserr.New("UserHomeNotFound", "user home directory not found.", nil) 18 ErrSharedCredentialsHomeNotFound = awserr.New("UserHomeNotFound", "user home directory not found.", nil)
21) 19)
22 20
@@ -117,22 +115,23 @@ func loadProfile(filename, profile string) (Value, error) {
117// 115//
118// Will return an error if the user's home directory path cannot be found. 116// Will return an error if the user's home directory path cannot be found.
119func (p *SharedCredentialsProvider) filename() (string, error) { 117func (p *SharedCredentialsProvider) filename() (string, error) {
120 if p.Filename == "" { 118 if len(p.Filename) != 0 {
121 if p.Filename = os.Getenv("AWS_SHARED_CREDENTIALS_FILE"); p.Filename != "" { 119 return p.Filename, nil
122 return p.Filename, nil 120 }
123 } 121
124 122 if p.Filename = os.Getenv("AWS_SHARED_CREDENTIALS_FILE"); len(p.Filename) != 0 {
125 homeDir := os.Getenv("HOME") // *nix 123 return p.Filename, nil
126 if homeDir == "" { // Windows
127 homeDir = os.Getenv("USERPROFILE")
128 }
129 if homeDir == "" {
130 return "", ErrSharedCredentialsHomeNotFound
131 }
132
133 p.Filename = filepath.Join(homeDir, ".aws", "credentials")
134 } 124 }
135 125
126 if home := shareddefaults.UserHomeDir(); len(home) == 0 {
127 // Backwards compatibility of home directly not found error being returned.
128 // This error is too verbose, failure when opening the file would of been
129 // a better error to return.
130 return "", ErrSharedCredentialsHomeNotFound
131 }
132
133 p.Filename = shareddefaults.SharedCredentialsFilename()
134
136 return p.Filename, nil 135 return p.Filename, nil
137} 136}
138 137