Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/provider/resource_project_ownership.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,5 +225,5 @@ func (r *ProjectOwnershipResource) Delete(ctx context.Context, req resource.Dele
}

func (r *ProjectOwnershipResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
tfutils.ImportStateThreePartId(ctx, "organization", "project", req, resp)
tfutils.ImportStateTwoPart(ctx, "organization", "project", req, resp)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would this clash with the project resource? 🤔

}
10 changes: 10 additions & 0 deletions internal/tfutils/import_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,13 @@ func ImportStateFourPartId(ctx context.Context, part1 string, part2 string, part
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root(part3), part3Value)...)
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("id"), id)...)
}

func ImportStateTwoPart(ctx context.Context, part1 string, part2 string, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
part1Value, part2Value, err := SplitTwoPartId(req.ID, part1, part2)
if err != nil {
resp.Diagnostics.Append(diagutils.NewImportError(err))
return
}
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root(part1), part1Value)...)
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root(part2), part2Value)...)
}
Loading