Skip to content

Commit

Permalink
fix comment and remove unnecessary else block
Browse files Browse the repository at this point in the history
  • Loading branch information
vinay-gopalan committed Jul 1, 2024
1 parent 8053ffa commit 0344315
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (c *client) unassignRoles(ctx context.Context, roleIDs []string) error {

for _, id := range roleIDs {
if _, err := c.provider.DeleteRoleAssignmentByID(ctx, id); err != nil {
// If a role was deleted manually then Azure returns an error and status 204
// If a role was deleted out-of-band then Azure returns an error and status 204
respErr := new(azcore.ResponseError)
if errors.As(err, &respErr) && (respErr.StatusCode == http.StatusNoContent || respErr.StatusCode == http.StatusNotFound) {
continue
Expand Down
14 changes: 7 additions & 7 deletions provider_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,13 @@ func (m *mockProvider) DeleteRoleAssignmentByID(_ context.Context, _ string) (ar
return armauthorization.RoleAssignmentsClientDeleteByIDResponse{}, &azcore.ResponseError{
ErrorCode: "mock: fail to delete role assignment",
}
} else {
// return empty response and with status code; will ignore error and assume role
// assignment was manually deleted based on status code
return armauthorization.RoleAssignmentsClientDeleteByIDResponse{}, &azcore.ResponseError{
StatusCode: m.unassignRolesFailureParams.statusCode,
ErrorCode: "mock: fail to delete role assignment",
}
}

// return empty response and with status code; will ignore error and assume role
// assignment was manually deleted based on status code
return armauthorization.RoleAssignmentsClientDeleteByIDResponse{}, &azcore.ResponseError{
StatusCode: m.unassignRolesFailureParams.statusCode,
ErrorCode: "mock: fail to delete role assignment",
}
}
return armauthorization.RoleAssignmentsClientDeleteByIDResponse{}, nil
Expand Down

0 comments on commit 0344315

Please sign in to comment.