Skip to content

Commit

Permalink
feature(invitations): remove retry on delete since it will be hamilto…
Browse files Browse the repository at this point in the history
…n's responsability
  • Loading branch information
romainDavaze committed Jun 9, 2021
1 parent ab55e79 commit 862e58e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 40 deletions.
31 changes: 0 additions & 31 deletions internal/helpers/msgraph/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,37 +39,6 @@ func WaitForCreationReplication(ctx context.Context, f func() (interface{}, int,
}).WaitForStateContext(ctx)
}

func WaitForDeletionReplication(ctx context.Context, f func() (interface{}, int, error)) (interface{}, error) {
deadline, ok := ctx.Deadline()
if !ok {
return nil, fmt.Errorf("context has no deadline")
}
timeout := time.Until(deadline)
return (&resource.StateChangeConf{
Pending: []string{"Found", "BadCast"},
Target: []string{"NotFound"},
Timeout: timeout,
MinTimeout: 1 * time.Second,
ContinuousTargetOccurence: 3,
Refresh: func() (interface{}, string, error) {
i, status, err := f()

switch {
case status >= 200 && status < 300:
return i, "Found", nil
case status == 404:
return i, "NotFound", nil
case i == nil:
return nil, "BadCast", nil
case err != nil:
return i, "Error", fmt.Errorf("unable to retrieve object, received response with status %d: %v", status, err)
}

return i, "Error", fmt.Errorf("unrecognised response with status %d", status)
},
}).WaitForStateContext(ctx)
}

func WaitForListAdd(ctx context.Context, item string, f func() ([]string, error)) (interface{}, error) {
deadline, ok := ctx.Deadline()
if !ok {
Expand Down
9 changes: 0 additions & 9 deletions internal/services/invitations/invitation_resource_msgraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,6 @@ func invitationResourceDeleteMsGraph(ctx context.Context, d *schema.ResourceData
return tf.ErrorDiagPathF(err, "id", "Deleting user with object ID %q, got status %d", userID, status)
}

_, err = helpers.WaitForDeletionReplication(ctx, func() (interface{}, int, error) {
userClient := meta.(*clients.Client).Users.MsClient
return userClient.Get(ctx, userID)
})

if err != nil {
return tf.ErrorDiagF(err, "Waiting for deletion of User with object ID: %q", userID)
}

return nil
}

Expand Down

0 comments on commit 862e58e

Please sign in to comment.