-
Notifications
You must be signed in to change notification settings - Fork 0
feat: decompose V1 CRUD routes into pipeline primitives (#86) #123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1026,27 +1026,118 @@ workflows: | |||||||||||||||||||||||||||||||||||||||||||||
| config: | ||||||||||||||||||||||||||||||||||||||||||||||
| status: 200 | ||||||||||||||||||||||||||||||||||||||||||||||
| body_from: "steps.get-versions.rows" | ||||||||||||||||||||||||||||||||||||||||||||||
| # Deploy and Stop delegate to V1APIHandler which manages RuntimeManager | ||||||||||||||||||||||||||||||||||||||||||||||
| # Deploy: update workflow status to 'active' | ||||||||||||||||||||||||||||||||||||||||||||||
| - method: POST | ||||||||||||||||||||||||||||||||||||||||||||||
| path: "/api/v1/admin/workflows/{id}/deploy" | ||||||||||||||||||||||||||||||||||||||||||||||
| handler: admin-commands | ||||||||||||||||||||||||||||||||||||||||||||||
| middlewares: [admin-cors, admin-auth-middleware] | ||||||||||||||||||||||||||||||||||||||||||||||
| pipeline: | ||||||||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||||||||
| - name: deploy-workflow | ||||||||||||||||||||||||||||||||||||||||||||||
| type: step.delegate | ||||||||||||||||||||||||||||||||||||||||||||||
| - name: parse-request | ||||||||||||||||||||||||||||||||||||||||||||||
| type: step.request_parse | ||||||||||||||||||||||||||||||||||||||||||||||
| config: | ||||||||||||||||||||||||||||||||||||||||||||||
| service: admin-v1-mgmt | ||||||||||||||||||||||||||||||||||||||||||||||
| path_params: [id] | ||||||||||||||||||||||||||||||||||||||||||||||
| - name: check-exists | ||||||||||||||||||||||||||||||||||||||||||||||
| type: step.db_query | ||||||||||||||||||||||||||||||||||||||||||||||
| config: | ||||||||||||||||||||||||||||||||||||||||||||||
| database: admin-db | ||||||||||||||||||||||||||||||||||||||||||||||
| query: "SELECT id FROM workflows WHERE id = ?" | ||||||||||||||||||||||||||||||||||||||||||||||
| params: ["{{index .steps \"parse-request\" \"path_params\" \"id\"}}"] | ||||||||||||||||||||||||||||||||||||||||||||||
| mode: single | ||||||||||||||||||||||||||||||||||||||||||||||
| - name: check-found | ||||||||||||||||||||||||||||||||||||||||||||||
| type: step.conditional | ||||||||||||||||||||||||||||||||||||||||||||||
| config: | ||||||||||||||||||||||||||||||||||||||||||||||
| field: "steps.check-exists.found" | ||||||||||||||||||||||||||||||||||||||||||||||
| routes: | ||||||||||||||||||||||||||||||||||||||||||||||
| "false": not-found | ||||||||||||||||||||||||||||||||||||||||||||||
| default: set-now | ||||||||||||||||||||||||||||||||||||||||||||||
| - name: set-now | ||||||||||||||||||||||||||||||||||||||||||||||
| type: step.set | ||||||||||||||||||||||||||||||||||||||||||||||
| config: | ||||||||||||||||||||||||||||||||||||||||||||||
| values: | ||||||||||||||||||||||||||||||||||||||||||||||
| now: "{{ now }}" | ||||||||||||||||||||||||||||||||||||||||||||||
| - name: activate | ||||||||||||||||||||||||||||||||||||||||||||||
| type: step.db_exec | ||||||||||||||||||||||||||||||||||||||||||||||
| config: | ||||||||||||||||||||||||||||||||||||||||||||||
| database: admin-db | ||||||||||||||||||||||||||||||||||||||||||||||
| query: "UPDATE workflows SET status='active', updated_at=? WHERE id=?" | ||||||||||||||||||||||||||||||||||||||||||||||
| params: | ||||||||||||||||||||||||||||||||||||||||||||||
| - "{{index .steps \"set-now\" \"now\"}}" | ||||||||||||||||||||||||||||||||||||||||||||||
| - "{{index .steps \"parse-request\" \"path_params\" \"id\"}}" | ||||||||||||||||||||||||||||||||||||||||||||||
| - name: get-workflow | ||||||||||||||||||||||||||||||||||||||||||||||
| type: step.db_query | ||||||||||||||||||||||||||||||||||||||||||||||
| config: | ||||||||||||||||||||||||||||||||||||||||||||||
| database: admin-db | ||||||||||||||||||||||||||||||||||||||||||||||
| query: "SELECT id, project_id, name, slug, description, config_yaml, version, status, is_system, workspace_dir, created_by, updated_by, created_at, updated_at FROM workflows WHERE id = ?" | ||||||||||||||||||||||||||||||||||||||||||||||
| params: ["{{index .steps \"parse-request\" \"path_params\" \"id\"}}"] | ||||||||||||||||||||||||||||||||||||||||||||||
| mode: single | ||||||||||||||||||||||||||||||||||||||||||||||
| - name: respond | ||||||||||||||||||||||||||||||||||||||||||||||
| type: step.json_response | ||||||||||||||||||||||||||||||||||||||||||||||
| config: | ||||||||||||||||||||||||||||||||||||||||||||||
| status: 200 | ||||||||||||||||||||||||||||||||||||||||||||||
| body_from: "steps.get-workflow.row" | ||||||||||||||||||||||||||||||||||||||||||||||
| - name: not-found | ||||||||||||||||||||||||||||||||||||||||||||||
| type: step.json_response | ||||||||||||||||||||||||||||||||||||||||||||||
| config: | ||||||||||||||||||||||||||||||||||||||||||||||
| status: 404 | ||||||||||||||||||||||||||||||||||||||||||||||
| body: | ||||||||||||||||||||||||||||||||||||||||||||||
| error: "workflow not found" | ||||||||||||||||||||||||||||||||||||||||||||||
| # Stop: update workflow status to 'stopped' | ||||||||||||||||||||||||||||||||||||||||||||||
| - method: POST | ||||||||||||||||||||||||||||||||||||||||||||||
| path: "/api/v1/admin/workflows/{id}/stop" | ||||||||||||||||||||||||||||||||||||||||||||||
| handler: admin-commands | ||||||||||||||||||||||||||||||||||||||||||||||
| middlewares: [admin-cors, admin-auth-middleware] | ||||||||||||||||||||||||||||||||||||||||||||||
| pipeline: | ||||||||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||||||||
| - name: stop-workflow | ||||||||||||||||||||||||||||||||||||||||||||||
| type: step.delegate | ||||||||||||||||||||||||||||||||||||||||||||||
| - name: parse-request | ||||||||||||||||||||||||||||||||||||||||||||||
| type: step.request_parse | ||||||||||||||||||||||||||||||||||||||||||||||
| config: | ||||||||||||||||||||||||||||||||||||||||||||||
| service: admin-v1-mgmt | ||||||||||||||||||||||||||||||||||||||||||||||
| path_params: [id] | ||||||||||||||||||||||||||||||||||||||||||||||
| - name: check-exists | ||||||||||||||||||||||||||||||||||||||||||||||
| type: step.db_query | ||||||||||||||||||||||||||||||||||||||||||||||
| config: | ||||||||||||||||||||||||||||||||||||||||||||||
| database: admin-db | ||||||||||||||||||||||||||||||||||||||||||||||
| query: "SELECT id FROM workflows WHERE id = ?" | ||||||||||||||||||||||||||||||||||||||||||||||
| params: ["{{index .steps \"parse-request\" \"path_params\" \"id\"}}"] | ||||||||||||||||||||||||||||||||||||||||||||||
| mode: single | ||||||||||||||||||||||||||||||||||||||||||||||
| - name: check-found | ||||||||||||||||||||||||||||||||||||||||||||||
| type: step.conditional | ||||||||||||||||||||||||||||||||||||||||||||||
| config: | ||||||||||||||||||||||||||||||||||||||||||||||
| field: "steps.check-exists.found" | ||||||||||||||||||||||||||||||||||||||||||||||
| routes: | ||||||||||||||||||||||||||||||||||||||||||||||
| "false": not-found | ||||||||||||||||||||||||||||||||||||||||||||||
| default: set-now | ||||||||||||||||||||||||||||||||||||||||||||||
| - name: set-now | ||||||||||||||||||||||||||||||||||||||||||||||
| type: step.set | ||||||||||||||||||||||||||||||||||||||||||||||
| config: | ||||||||||||||||||||||||||||||||||||||||||||||
| values: | ||||||||||||||||||||||||||||||||||||||||||||||
| now: "{{ now }}" | ||||||||||||||||||||||||||||||||||||||||||||||
| - name: deactivate | ||||||||||||||||||||||||||||||||||||||||||||||
| type: step.db_exec | ||||||||||||||||||||||||||||||||||||||||||||||
| config: | ||||||||||||||||||||||||||||||||||||||||||||||
| database: admin-db | ||||||||||||||||||||||||||||||||||||||||||||||
| query: "UPDATE workflows SET status='stopped', updated_at=? WHERE id=?" | ||||||||||||||||||||||||||||||||||||||||||||||
| params: | ||||||||||||||||||||||||||||||||||||||||||||||
| - "{{index .steps \"set-now\" \"now\"}}" | ||||||||||||||||||||||||||||||||||||||||||||||
| - "{{index .steps \"parse-request\" \"path_params\" \"id\"}}" | ||||||||||||||||||||||||||||||||||||||||||||||
| - name: get-workflow | ||||||||||||||||||||||||||||||||||||||||||||||
| type: step.db_query | ||||||||||||||||||||||||||||||||||||||||||||||
| config: | ||||||||||||||||||||||||||||||||||||||||||||||
| database: admin-db | ||||||||||||||||||||||||||||||||||||||||||||||
| query: "SELECT id, project_id, name, slug, description, config_yaml, version, status, is_system, workspace_dir, created_by, updated_by, created_at, updated_at FROM workflows WHERE id = ?" | ||||||||||||||||||||||||||||||||||||||||||||||
| params: ["{{index .steps \"parse-request\" \"path_params\" \"id\"}}"] | ||||||||||||||||||||||||||||||||||||||||||||||
| mode: single | ||||||||||||||||||||||||||||||||||||||||||||||
| - name: respond | ||||||||||||||||||||||||||||||||||||||||||||||
| type: step.json_response | ||||||||||||||||||||||||||||||||||||||||||||||
| config: | ||||||||||||||||||||||||||||||||||||||||||||||
| status: 200 | ||||||||||||||||||||||||||||||||||||||||||||||
| body_from: "steps.get-workflow.row" | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1130
to
+1134
|
||||||||||||||||||||||||||||||||||||||||||||||
| - name: respond | |
| type: step.json_response | |
| config: | |
| status: 200 | |
| body_from: "steps.get-workflow.row" | |
| - name: respond-if-found | |
| type: step.condition | |
| config: | |
| condition: "{{index .steps \"get-workflow\" \"found\"}}" | |
| true_steps: | |
| - name: respond | |
| type: step.json_response | |
| config: | |
| status: 200 | |
| body_from: "steps.get-workflow.row" | |
| false_steps: | |
| - name: respond-not-found | |
| type: step.json_response | |
| config: | |
| status: 404 | |
| body: | |
| error: "workflow not found" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The deploy pipeline always responds 200 with
steps.get-workflow.roweven when the workflow ID doesn't exist.step.db_queryinmode: singlereturnsfound: falseand an emptyrow, so this endpoint will return{}with 200 instead of a 404 (unlike the GET/PUT/DELETE workflow routes above).Add a conditional step on
steps.get-workflow.foundand anot-foundjson_response (404) route, or otherwise fail the pipeline when no row is found.