aws: Simplify ValidateCredentials func

This commit is contained in:
Radek Simko 2015-07-21 15:57:59 +02:00
parent dfbe7bee9e
commit 4797a82e1a
1 changed files with 5 additions and 7 deletions

View File

@ -174,16 +174,14 @@ func (c *Config) ValidateRegion() error {
// Validate credentials early and fail before we do any graph walking // Validate credentials early and fail before we do any graph walking
func (c *Config) ValidateCredentials(iamconn *iam.IAM) error { func (c *Config) ValidateCredentials(iamconn *iam.IAM) error {
_, err := iamconn.GetUser(nil) _, err := iamconn.GetUser(nil)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok { if awsErr, ok := err.(awserr.Error); ok {
if awsErr.Code() == "SignatureDoesNotMatch" { if awsErr.Code() == "SignatureDoesNotMatch" {
return fmt.Errorf("Failed authenticating with AWS: please verify credentials") return fmt.Errorf("Failed authenticating with AWS: please verify credentials")
}
} }
return err
} }
return nil return err
} }
// ValidateAccountId returns a context-specific error if the configured account // ValidateAccountId returns a context-specific error if the configured account