Skip to content

Commit

Permalink
fix: merge conflict
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Theuermann <[email protected]>
  • Loading branch information
mati007thm committed Jul 17, 2024
1 parent c9304c1 commit b1387c8
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions internal/provider/custom_framework_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"fmt"
"os"
"strings"

"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
Expand Down Expand Up @@ -217,5 +217,24 @@ func (r *customFrameworkResource) Delete(ctx context.Context, req resource.Delet
}

func (r *customFrameworkResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
resource.ImportStatePassthroughID(ctx, path.Root("mrn"), req, resp)
// resource.ImportStatePassthroughID(ctx, path.Root("mrn"), req, resp)
mrn := req.ID
splitMrn := strings.Split(mrn, "/")
spaceMrn := spacePrefix + splitMrn[len(splitMrn)-3]
spaceId := splitMrn[len(splitMrn)-3]
uid := splitMrn[len(splitMrn)-1]

framework, err := r.client.GetFramework(ctx, spaceMrn, spaceId, uid)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to get Compliance Framework, got error: %s", err))
return
}

model := customFrameworkResourceModel{
Mrn: types.StringValue(string(framework.Mrn)),
DataUrl: types.StringPointerValue(nil),
SpaceId: types.StringValue(spaceId),
}

resp.State.Set(ctx, &model)
}

0 comments on commit b1387c8

Please sign in to comment.