@@ -29,6 +29,13 @@ const (
2929 providing credentials for the AWS Provider`
3030)
3131
32+ var (
33+ // ErrNoValidCredentialSources indicates that no credentials source could be found
34+ ErrNoValidCredentialSources = errNoValidCredentialSources ()
35+ )
36+
37+ func errNoValidCredentialSources () error { return errors .New (errMsgNoValidCredentialSources ) }
38+
3239// GetAccountIDAndPartition gets the account ID and associated partition.
3340func GetAccountIDAndPartition (iamconn * iam.IAM , stsconn * sts.STS , authProviderName string ) (string , string , error ) {
3441 var accountID , partition string
@@ -175,7 +182,7 @@ func GetCredentialsFromSession(c *Config) (*awsCredentials.Credentials, error) {
175182 if c .Profile == "" {
176183 sess , err = session .NewSession ()
177184 if err != nil {
178- return nil , errors . New ( errMsgNoValidCredentialSources )
185+ return nil , ErrNoValidCredentialSources
179186 }
180187 } else {
181188 options := & session.Options {
@@ -191,7 +198,7 @@ func GetCredentialsFromSession(c *Config) (*awsCredentials.Credentials, error) {
191198 sess , err = session .NewSessionWithOptions (* options )
192199 if err != nil {
193200 if IsAWSErr (err , "NoCredentialProviders" , "" ) {
194- return nil , errors . New ( errMsgNoValidCredentialSources )
201+ return nil , ErrNoValidCredentialSources
195202 }
196203 return nil , fmt .Errorf ("Error creating AWS session: %s" , err )
197204 }
@@ -200,7 +207,7 @@ func GetCredentialsFromSession(c *Config) (*awsCredentials.Credentials, error) {
200207 creds := sess .Config .Credentials
201208 cp , err := sess .Config .Credentials .Get ()
202209 if err != nil {
203- return nil , errors . New ( errMsgNoValidCredentialSources )
210+ return nil , ErrNoValidCredentialSources
204211 }
205212
206213 log .Printf ("[INFO] Successfully derived credentials from session" )
0 commit comments