Replace an 'if' block with 'switch'

This commit is contained in:
vishalnayak 2016-06-17 12:35:44 -04:00
parent 8e03c1448b
commit dccfc413d4
2 changed files with 7 additions and 3 deletions

View file

@ -265,8 +265,7 @@ func (b *backend) pathLoginUpdate(
if instanceDesc.Reservations[0].Instances[0].IamInstanceProfile.Arn == nil {
return nil, fmt.Errorf("Arn in the instance description is nil")
}
iamRoleArn := ""
iamRoleArn = *instanceDesc.Reservations[0].Instances[0].IamInstanceProfile.Arn
iamRoleArn := *instanceDesc.Reservations[0].Instances[0].IamInstanceProfile.Arn
if iamRoleArn != roleEntry.BoundIamARN {
return logical.ErrorResponse(fmt.Sprintf("IAM Role ARN %s does not belong to role %s", iamRoleArn, roleName)), nil
}

View file

@ -222,7 +222,12 @@ func (b *backend) pathRoleCreateUpdate(
}
// Ensure that at least one bound is set on the role
if roleEntry.BoundAccountID == "" && roleEntry.BoundAmiID == "" && roleEntry.BoundIamARN == "" {
switch {
case roleEntry.BoundAccountID != "":
case roleEntry.BoundAmiID != "":
case roleEntry.BoundIamARN != "":
default:
return logical.ErrorResponse("at least be one bound parameter should be specified on the role"), nil
}