diff --git a/internal/provider/storage_volume_snapshot_resource.go b/internal/provider/storage_volume_snapshot_resource.go index 92dda990..82db34aa 100644 --- a/internal/provider/storage_volume_snapshot_resource.go +++ b/internal/provider/storage_volume_snapshot_resource.go @@ -3,6 +3,8 @@ package provider import ( "context" "fmt" + "log" + "strings" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" @@ -181,7 +183,7 @@ func (r *StorageVolumeSnapshotResource) Create(ctx context.Context, req resource // Read refreshes the Terraform state with the latest data. func (r *StorageVolumeSnapshotResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { var data *StorageVolumeSnapshotResourceModel - + log.Printf("why why") // Read Terraform prior state data into the model resp.Diagnostics.Append(req.State.Get(ctx, &data)...) if resp.Diagnostics.HasError() { @@ -316,5 +318,16 @@ func (r *StorageVolumeSnapshotResource) Delete(ctx context.Context, req resource // ImportState imports a resource using ID from terraform import command by calling the Read method. func (r *StorageVolumeSnapshotResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + // resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + idParts := strings.Split(req.ID, ",") + log.Printf("here here") + if len(idParts) != 2 || idParts[0] == "" || idParts[1] == "" { + resp.Diagnostics.AddError( + "Unexpected Import Identifier", + fmt.Sprintf("Expected import identifier with format: name,svm_name,cx_profile_name. Got: %q", req.ID), + ) + return + } + resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("name"), idParts[0])...) + resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("cx_profile_name"), idParts[1])...) }