GetPlan gets a plan.
(ctx context.Context, request *connect.Request[v1pb.GetPlanRequest])
| 50 | |
| 51 | // GetPlan gets a plan. |
| 52 | func (s *PlanService) GetPlan(ctx context.Context, request *connect.Request[v1pb.GetPlanRequest]) (*connect.Response[v1pb.Plan], error) { |
| 53 | req := request.Msg |
| 54 | projectID, planID, err := common.GetProjectIDPlanID(req.Name) |
| 55 | if err != nil { |
| 56 | return nil, connect.NewError(connect.CodeInvalidArgument, err) |
| 57 | } |
| 58 | plan, err := s.store.GetPlan(ctx, &store.FindPlanMessage{ |
| 59 | Workspace: common.GetWorkspaceIDFromContext(ctx), |
| 60 | UID: &planID, |
| 61 | ProjectID: projectID, |
| 62 | }) |
| 63 | if err != nil { |
| 64 | return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to get plan")) |
| 65 | } |
| 66 | if plan == nil { |
| 67 | return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("plan %d not found in project %s", planID, projectID)) |
| 68 | } |
| 69 | convertedPlan, err := convertToPlan(ctx, s.store, plan) |
| 70 | if err != nil { |
| 71 | return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to convert to plan")) |
| 72 | } |
| 73 | return connect.NewResponse(convertedPlan), nil |
| 74 | } |
| 75 | |
| 76 | // ListPlans lists plans. |
| 77 | func (s *PlanService) ListPlans(ctx context.Context, request *connect.Request[v1pb.ListPlansRequest]) (*connect.Response[v1pb.ListPlansResponse], error) { |
nothing calls this directly
no test coverage detected