From 1ff94a3954c65d453794789f935cf7e5aad736b1 Mon Sep 17 00:00:00 2001 From: Thomas Gerbet Date: Mon, 22 Apr 2024 14:58:11 +0200 Subject: [PATCH] fix: Expect an integer when importing sender 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 --- mailjet/sender_resource.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mailjet/sender_resource.go b/mailjet/sender_resource.go index 6bd796c..8ba2ab0 100644 --- a/mailjet/sender_resource.go +++ b/mailjet/sender_resource.go @@ -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)...) }