Workflow parameters: types, defaults, checked before a run (#23, #11)
CI / Test (jest) (pull_request) Successful in 26s
CI / Lint (eslint) (pull_request) Successful in 29s
CI / Security (npm audit) (pull_request) Successful in 13s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 1m36s
CI / Integration (api) (pull_request) Successful in 2m26s
CI / UI (playwright) (pull_request) Successful in 2m25s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
CI / UI screenshots (before/after) (pull_request) Successful in 2m3s
CI / Test (jest) (pull_request) Successful in 26s
CI / Lint (eslint) (pull_request) Successful in 29s
CI / Security (npm audit) (pull_request) Successful in 13s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 1m36s
CI / Integration (api) (pull_request) Successful in 2m26s
CI / UI (playwright) (pull_request) Successful in 2m25s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
CI / UI screenshots (before/after) (pull_request) Successful in 2m3s
#23 - Parameters can be text (default), number (min, max), select (options), boolean, or worker, with a default. The Run dialog shows a matching field, the allowed characters for text, and the range for numbers; worker parameters choose from the connected workers. - Values are checked before anything starts: in the dialog, naming the characters that are not allowed, and by the server (resolveParams), which answers 400 "Invalid parameters: ..." and creates no execution. A bad value used to fail mid-run as "Unsafe value for workflow parameter". Server errors now show in the dialog instead of a toast. #11 - Saving a workflow checks its shape (definitionErrors): known step types and their required fields, unique ids, prompt routes that match options, route conditions, and parameter definitions. Unknown step types were silently skipped at run time. - README documents the parameter types and the checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7204c806df
commit
a6d693c13e
8 files changed
+477
-39
No files matched your search
@@ -338,7 +338,10 @@ A workflow is a JSON definition with a list of steps, created on the **Workflows
|
||||
|
||||
```json
|
||||
{
|
||||
"params": [{ "name": "host", "label": "Host", "required": true }],
|
||||
"params": [
|
||||
{ "name": "host", "label": "Host", "required": true },
|
||||
{ "name": "service", "type": "select", "options": ["nginx", "myservice"], "default": "myservice" }
|
||||
],
|
||||
"steps": [
|
||||
{ "id": "probe", "type": "execute", "command": "ping -c 1 {{host}} >/dev/null && echo UP=yes || echo UP=no", "targets": ["node-01"] },
|
||||
{ "id": "read", "type": "parse" },
|
||||
@@ -347,7 +350,7 @@ A workflow is a JSON definition with a list of steps, created on the **Workflows
|
||||
{ "default": true, "goto": "ask" }
|
||||
] },
|
||||
{ "id": "ask", "type": "prompt", "message": "{{host}} is down. Restart its service?", "options": ["Restart", "Skip"], "routes": { "Skip": "end" } },
|
||||
{ "id": "restart", "type": "execute", "command": "systemctl restart myservice", "targets": ["node-01"], "retries": 2 }
|
||||
{ "id": "restart", "type": "execute", "command": "systemctl restart {{service}}", "targets": ["node-01"], "retries": 2 }
|
||||
]
|
||||
}
|
||||
```
|
||||
@@ -360,8 +363,10 @@ A workflow is a JSON definition with a list of steps, created on the **Workflows
|
||||
| `prompt` | `message`, `options`, `key`, `routes` (`{ "<option>": "<step id>" }`) | Waits for someone to answer in the UI (up to 60 min, never past the execution's time limit). An unanswered prompt fails the workflow |
|
||||
| `wait` | `duration` (seconds) | Pauses, never past the execution's time limit |
|
||||
|
||||
Any step can have `goto: "<step id>"` or `goto: "end"`. Ids must be unique, and every goto
|
||||
must name an existing step: saving a workflow checks this.
|
||||
Any step can have `goto: "<step id>"` or `goto: "end"`. Saving a workflow checks its shape
|
||||
and refuses it with the reasons: each step's `type` and required fields (an `execute` needs a
|
||||
`command`, a `prompt` needs `message` and `options`, a `route` needs `conditions`), unique ids,
|
||||
every goto naming an existing step, conditions that parse, and the `params` definitions.
|
||||
|
||||
**Conditions** (`condition`, route `if`) are expressions over `state.*` (values from `parse`
|
||||
and prompt answers), `params.*` and `promptResponse`: comparisons (`=== !== < > <= >=`),
|
||||
@@ -370,8 +375,21 @@ methods `trim`, `toLowerCase`, `toUpperCase`, `includes`, `startsWith`, `endsWit
|
||||
evaluated by a small interpreter (`lib/condition.js`), never as JavaScript, and a condition
|
||||
that doesn't parse is rejected when the workflow is saved.
|
||||
|
||||
**Parameters** (`params`) are asked for when the workflow starts and substituted into
|
||||
commands as `{{name}}`. Values may only contain letters, digits and `. _ : @ / -`.
|
||||
**Parameters** (`params`) are asked for in the Run dialog and substituted into commands as
|
||||
`{{name}}`. Each has a `name`, and optionally `label`, `required`, `default`, `placeholder` and
|
||||
a `type`:
|
||||
|
||||
| `type` | Field | Value |
|
||||
|---|---|---|
|
||||
| `text` (default) | text box | letters, digits and `. _ : @ / -` only |
|
||||
| `number` | number box; `min`, `max` | a number in range |
|
||||
| `select` | dropdown of `options` | one of the options |
|
||||
| `boolean` | checkbox | `true` or `false` |
|
||||
| `worker` | dropdown of connected workers | a worker's name |
|
||||
|
||||
Values are checked when the run is requested, both in the dialog and by the server (which
|
||||
answers 400 with the reasons), so a bad value never starts a run. Defaults fill in anything
|
||||
left empty.
|
||||
|
||||
**Dry run** logs each command without running it. **Abort** stops the workflow before its
|
||||
next step and kills its running commands on the workers. A workflow can have a `webhook_url`:
|
||||
|
||||
Reference in new issue
Block a user