Replace an 'if' block with 'switch'
This commit is contained in:
parent
8e03c1448b
commit
dccfc413d4
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue