List returns a list of workflows.
(ctx context.Context, req *pb.WorkflowServiceListRequest)
| 158 | |
| 159 | // List returns a list of workflows. |
| 160 | func (s *WorkflowService) List(ctx context.Context, req *pb.WorkflowServiceListRequest) (*pb.WorkflowServiceListResponse, error) { |
| 161 | currentOrg, err := requireCurrentOrg(ctx) |
| 162 | if err != nil { |
| 163 | return nil, err |
| 164 | } |
| 165 | |
| 166 | // Initialize the pagination options, with default values |
| 167 | paginationOpts := pagination.NewDefaultOffsetPaginationOpts() |
| 168 | |
| 169 | // Override the pagination options if they are provided |
| 170 | if req.GetPagination() != nil { |
| 171 | paginationOpts, err = pagination.NewOffsetPaginationOpts( |
| 172 | int(req.GetPagination().GetPage()), |
| 173 | int(req.GetPagination().GetPageSize()), |
| 174 | ) |
| 175 | if err != nil { |
| 176 | return nil, handleUseCaseErr(err, s.log) |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | // Initialize the filters |
| 181 | filters := &biz.WorkflowListOpts{} |
| 182 | |
| 183 | // Check the workflow name |
| 184 | if req.GetWorkflowName() != "" { |
| 185 | filters.WorkflowName = req.GetWorkflowName() |
| 186 | } |
| 187 | |
| 188 | // Check the Team |
| 189 | if req.GetWorkflowTeam() != "" { |
| 190 | filters.WorkflowTeam = req.GetWorkflowTeam() |
| 191 | } |
| 192 | |
| 193 | // Check the Workflow Description |
| 194 | if req.GetWorkflowDescription() != "" { |
| 195 | filters.WorkflowDescription = req.GetWorkflowDescription() |
| 196 | } |
| 197 | |
| 198 | // Check the Project Name |
| 199 | if len(req.GetProjectNames()) != 0 { |
| 200 | filters.WorkflowProjectNames = req.GetProjectNames() |
| 201 | } |
| 202 | |
| 203 | // Workflow visibility |
| 204 | if req.WorkflowPublic != nil { |
| 205 | val := req.GetWorkflowPublic() |
| 206 | filters.WorkflowPublic = &val |
| 207 | } |
| 208 | |
| 209 | // Workflow Run Runner Type |
| 210 | if req.GetWorkflowRunRunnerType() != schema.CraftingSchema_Runner_RUNNER_TYPE_UNSPECIFIED { |
| 211 | filters.WorkflowRunRunnerType = req.GetWorkflowRunRunnerType().String() |
| 212 | } |
| 213 | |
| 214 | // Workflow Last Known Status |
| 215 | if req.GetWorkflowRunLastStatus() != pb.RunStatus_RUN_STATUS_UNSPECIFIED { |
| 216 | status, err := pbWorkflowRunStatusToBiz(req.GetWorkflowRunLastStatus()) |
| 217 | if err != nil { |
nothing calls this directly
no test coverage detected