MCPcopy Create free account
hub / github.com/bytebase/bytebase / GetPlan

Method GetPlan

backend/api/v1/plan_service.go:52–74  ·  view source on GitHub ↗

GetPlan gets a plan.

(ctx context.Context, request *connect.Request[v1pb.GetPlanRequest])

Source from the content-addressed store, hash-verified

50
51// GetPlan gets a plan.
52func (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.
77func (s *PlanService) ListPlans(ctx context.Context, request *connect.Request[v1pb.ListPlansRequest]) (*connect.Response[v1pb.ListPlansResponse], error) {

Callers

nothing calls this directly

Calls 5

GetProjectIDPlanIDFunction · 0.92
convertToPlanFunction · 0.85
ErrorfMethod · 0.80
GetPlanMethod · 0.65

Tested by

no test coverage detected