Skip to content

Commit

Permalink
Address review: assignment scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
manicminer committed Sep 16, 2021
1 parent ed139c1 commit 8c11716
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ func directoryRoleMemberResourceCreate(ctx context.Context, d *schema.ResourceDa
return tf.ErrorDiagPathF(err, "object_id", "Retrieving directory role with object ID: %q", id.DirectoryRoleId)
}

_, status, err = client.GetMember(ctx, id.DirectoryRoleId, id.MemberId)
if err == nil {
if _, status, err = client.GetMember(ctx, id.DirectoryRoleId, id.MemberId); err == nil {
return tf.ImportAsExistsDiag("azuread_directory_role_member", id.String())
} else if status != http.StatusNotFound {
return tf.ErrorDiagF(err, "Checking for existing membership of member %q for directory role with object ID: %q", id.MemberId, id.DirectoryRoleId)
Expand Down Expand Up @@ -140,8 +139,7 @@ func directoryRoleMemberResourceRead(ctx context.Context, d *schema.ResourceData
return tf.ErrorDiagPathF(err, "id", "Parsing Directory Role Member ID %q", d.Id())
}

_, status, err := client.GetMember(ctx, id.DirectoryRoleId, id.MemberId)
if err != nil {
if _, status, err := client.GetMember(ctx, id.DirectoryRoleId, id.MemberId); err != nil {
if status == http.StatusNotFound {
log.Printf("[DEBUG] Member with ID %q was not found in directory role %q - removing from state", id.MemberId, id.DirectoryRoleId)
d.SetId("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ func (r DirectoryRoleMemberResource) Exists(ctx context.Context, clients *client
return nil, fmt.Errorf("parsing Directory Role Member ID: %v", err)
}

_, status, err := client.GetMember(ctx, id.DirectoryRoleId, id.MemberId)
if err != nil {
if _, status, err := client.GetMember(ctx, id.DirectoryRoleId, id.MemberId); err != nil {
if status == http.StatusNotFound {
return utils.Bool(false), nil
}
Expand Down

0 comments on commit 8c11716

Please sign in to comment.