Skip to content

Commit

Permalink
fix: Expect an integer when importing sender
Browse files Browse the repository at this point in the history
The ID in the state is an integer not a string so we have to convert it
before attempting the import of the ressource.

Closes #14
  • Loading branch information
LeSuisse committed Apr 22, 2024
1 parent e3534a5 commit 1ff94a3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion mailjet/sender_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,5 +309,15 @@ func (r *senderResource) Delete(ctx context.Context, req resource.DeleteRequest,
}

func (r *senderResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp)
id, err := strconv.ParseInt(req.ID, 10, 64)

if err != nil {
resp.Diagnostics.AddError(
"Error importing item",
"Could not import the Mailjet sender, the ID should be an integer: "+err.Error(),
)
return
}

resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("id"), id)...)
}

0 comments on commit 1ff94a3

Please sign in to comment.