MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / Run

Method Run

app/cli/pkg/action/workflow_list.go:59–94  ·  view source on GitHub ↗

Run executes the workflow list action

(page int, pageSize int)

Source from the content-addressed store, hash-verified

57
58// Run executes the workflow list action
59func (action *WorkflowList) Run(page int, pageSize int) (*WorkflowListResult, error) {
60 if page < 1 {
61 return nil, fmt.Errorf("page must be greater or equal to 1")
62 }
63 if pageSize < 1 {
64 return nil, fmt.Errorf("page-size must be greater or equal to 1")
65 }
66
67 client := pb.NewWorkflowServiceClient(action.cfg.CPConnection)
68 res := &WorkflowListResult{}
69
70 resp, err := client.List(context.Background(), &pb.WorkflowServiceListRequest{
71 Pagination: &pb.OffsetPaginationRequest{
72 Page: int32(page),
73 PageSize: int32(pageSize),
74 },
75 })
76 if err != nil {
77 return nil, err
78 }
79
80 // Convert the response to the output format
81 for _, p := range resp.Result {
82 res.Workflows = append(res.Workflows, pbWorkflowItemToAction(p))
83 }
84
85 // Add the pagination details
86 res.Pagination = &OffsetPagination{
87 Page: int(resp.GetPagination().GetPage()),
88 PageSize: int(resp.GetPagination().GetPageSize()),
89 TotalPages: int(resp.GetPagination().GetTotalPages()),
90 TotalCount: int(resp.GetPagination().GetTotalCount()),
91 }
92
93 return res, nil
94}
95
96// pbWorkflowItemToAction converts API response to WorkflowItem
97func pbWorkflowItemToAction(wf *pb.WorkflowItem) *WorkflowItem {

Callers

nothing calls this directly

Calls 7

ListMethod · 0.95
pbWorkflowItemToActionFunction · 0.85
GetTotalPagesMethod · 0.80
GetTotalCountMethod · 0.80
GetPageMethod · 0.45
GetPaginationMethod · 0.45
GetPageSizeMethod · 0.45

Tested by

no test coverage detected