Skip to content

Commit

Permalink
Add vaultAndItemUUID function
Browse files Browse the repository at this point in the history
This function extracts the vault and item UUIDs from the terraform ID.

This matches the function with the same name from the old provider code.
  • Loading branch information
edif2008 committed Apr 19, 2024
1 parent 80792b3 commit 40de119
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/provider/onepassword_item_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,16 @@ func (r *OnePasswordItemResource) ImportState(ctx context.Context, req resource.
resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp)
}

func vaultAndItemUUID(tfID string) (vaultUUID, itemUUID string) {
elements := strings.Split(tfID, "/")

if len(elements) != 4 {
return "", ""
}

return elements[1], elements[3]
}

func itemToData(ctx context.Context, item *op.Item, data *OnePasswordItemResourceModel) diag.Diagnostics {
data.ID = types.StringValue(terraformItemID(item))
data.UUID = types.StringValue(item.ID)
Expand Down

0 comments on commit 40de119

Please sign in to comment.