From 2d59f039bae10476a356c5da7dc66989b29f01f6 Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Wed, 8 Jan 2025 15:08:18 +0100 Subject: [PATCH 1/4] Add a new `return` property to the `run` task, used to configure the output of the process to execute Closes #1051 Signed-off-by: Charles d'Avernas --- dsl-reference.md | 53 +++++++++++++++++++++++++++++++++ examples/run-return-all.yaml | 11 +++++++ examples/run-return-code.yaml | 11 +++++++ examples/run-return-none.yaml | 11 +++++++ examples/run-return-stderr.yaml | 11 +++++++ 5 files changed, 97 insertions(+) create mode 100644 examples/run-return-all.yaml create mode 100644 examples/run-return-code.yaml create mode 100644 examples/run-return-none.yaml create mode 100644 examples/run-return-stderr.yaml diff --git a/dsl-reference.md b/dsl-reference.md index 92b02d60..4f3fd799 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -55,6 +55,7 @@ + [HTTP Response](#http-response) + [HTTP Request](#http-request) + [URI Template](#uri-template) + + [Process Result](#process-result) ## Abstract @@ -723,6 +724,7 @@ Provides the capability to execute external [containers](#container-process), [s | run.shell | [`shell`](#shell-process) | `no` | The definition of the shell command to run.
*Required if `container`, `script` and `workflow` have not been set.* | | run.workflow | [`workflow`](#workflow-process) | `no` | The definition of the workflow to run.
*Required if `container`, `script` and `shell` have not been set.* | | await | `boolean` | `no` | Determines whether or not the process to run should be awaited for.
*Defaults to `true`.* | +| return | `string` | `no` | Configures the output of the process.
*Supported values are:*
*- `stdout`: Outputs the content of the process **STDOUT**.*
*- `stderr`: Outputs the content of the process **STDERR**.*
*- `code`: Outputs the process's **exit code**.*
*- `all`: Outputs the **exit code**, the **STDOUT** content and the **STDERR** content, wrapped into a new [processResult](#process-result) object.*
*- `none`: Does not output anything.*
*Defaults to `stdout`.* | ##### Examples @@ -1888,3 +1890,54 @@ This has the following limitations compared to runtime expressions: ```yaml uri: https://petstore.swagger.io/v2/pet/{petId} ``` + +### Process Result + +Describes the result of a process. + +#### Properties + +| Name | Type | Required | Description| +|:--|:---:|:---:|:---| +| code | `integer` | `yes` | The process's exit code. | +| stdout | `string` | `yes` | The process's **STDOUT** output. | +| stderr | `string` | `yes` | The process's **STDERR** output. | + +#### Examples + +```yaml +document: + dsl: '1.0.0-alpha5' + namespace: test + name: run-example + version: '0.1.0' +do: + - runContainer: + run: + container: + image: fake-image + return: stderr + + - runScript: + run: + script: + language: js + code: > + Some cool multiline script + return: code + + - runShell: + run: + shell: + command: 'echo "Hello, ${ .user.name }"' + return: all + + - runWorkflow: + run: + workflow: + namespace: another-one + name: do-stuff + version: '0.1.0' + input: {} + return: none +``` \ No newline at end of file diff --git a/examples/run-return-all.yaml b/examples/run-return-all.yaml new file mode 100644 index 00000000..966d2215 --- /dev/null +++ b/examples/run-return-all.yaml @@ -0,0 +1,11 @@ +document: + dsl: '1.0.0-alpha5' + namespace: test + name: run-container + version: '0.1.0' +do: + - runContainer: + run: + container: + image: hello-world + return: all \ No newline at end of file diff --git a/examples/run-return-code.yaml b/examples/run-return-code.yaml new file mode 100644 index 00000000..bdde3ef5 --- /dev/null +++ b/examples/run-return-code.yaml @@ -0,0 +1,11 @@ +document: + dsl: '1.0.0-alpha5' + namespace: test + name: run-container + version: '0.1.0' +do: + - runContainer: + run: + container: + image: hello-world + return: code \ No newline at end of file diff --git a/examples/run-return-none.yaml b/examples/run-return-none.yaml new file mode 100644 index 00000000..e0ea1159 --- /dev/null +++ b/examples/run-return-none.yaml @@ -0,0 +1,11 @@ +document: + dsl: '1.0.0-alpha5' + namespace: test + name: run-container + version: '0.1.0' +do: + - runContainer: + run: + container: + image: hello-world + return: none \ No newline at end of file diff --git a/examples/run-return-stderr.yaml b/examples/run-return-stderr.yaml new file mode 100644 index 00000000..73d07242 --- /dev/null +++ b/examples/run-return-stderr.yaml @@ -0,0 +1,11 @@ +document: + dsl: '1.0.0-alpha5' + namespace: test + name: run-container + version: '0.1.0' +do: + - runContainer: + run: + container: + image: hello-world + return: stderr \ No newline at end of file From e229effbb762b1587ee3330daba7f2978d078e4e Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Wed, 8 Jan 2025 15:14:23 +0100 Subject: [PATCH 2/4] Update the schema to include new features Signed-off-by: Charles d'Avernas --- schema/workflow.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/schema/workflow.yaml b/schema/workflow.yaml index aecbeacb..d35ab774 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -581,6 +581,12 @@ $defs: default: true title: AwaitProcessCompletion description: Whether to await the process completion before continuing. + return: + type: string + title: ProcessReturnType + description: Configures the output of the process. + enum: [ stdout, stderr, code, all, none ] + default: stdout oneOf: - title: RunContainer description: Enables the execution of external processes encapsulated within a containerized environment. @@ -1535,3 +1541,21 @@ $defs: title: RuntimeExpression description: A runtime expression. pattern: "^\\s*\\$\\{.+\\}\\s*$" + processResult: + type: object + title: ProcessResult + description: The object returned by a run task when its return type has been set 'all' + properties: + code: + type: integer + title: ProcessExitCode + description: The process's exit code. + stdout: + type: string + title: ProcessStandardOutput + description: The content of the process's STDOUT + stderr: + type: string + title: ProcessStandardError + description: The content of the process's STDERR + required: [ code, stdout, stderr ] \ No newline at end of file From 78997cb9b93bd83ac96c5dccd0144906e7a2fc5d Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Wed, 8 Jan 2025 15:24:07 +0100 Subject: [PATCH 3/4] Fix samples Signed-off-by: Charles d'Avernas --- examples/run-return-all.yaml | 2 +- examples/run-return-code.yaml | 2 +- examples/run-return-none.yaml | 2 +- examples/run-return-stderr.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/run-return-all.yaml b/examples/run-return-all.yaml index 966d2215..0de552f3 100644 --- a/examples/run-return-all.yaml +++ b/examples/run-return-all.yaml @@ -8,4 +8,4 @@ do: run: container: image: hello-world - return: all \ No newline at end of file + return: all \ No newline at end of file diff --git a/examples/run-return-code.yaml b/examples/run-return-code.yaml index bdde3ef5..9ea77ab9 100644 --- a/examples/run-return-code.yaml +++ b/examples/run-return-code.yaml @@ -8,4 +8,4 @@ do: run: container: image: hello-world - return: code \ No newline at end of file + return: code \ No newline at end of file diff --git a/examples/run-return-none.yaml b/examples/run-return-none.yaml index e0ea1159..ee9359b1 100644 --- a/examples/run-return-none.yaml +++ b/examples/run-return-none.yaml @@ -8,4 +8,4 @@ do: run: container: image: hello-world - return: none \ No newline at end of file + return: none \ No newline at end of file diff --git a/examples/run-return-stderr.yaml b/examples/run-return-stderr.yaml index 73d07242..940ca991 100644 --- a/examples/run-return-stderr.yaml +++ b/examples/run-return-stderr.yaml @@ -8,4 +8,4 @@ do: run: container: image: hello-world - return: stderr \ No newline at end of file + return: stderr \ No newline at end of file From 2cab5bf04024be1a0d9468b0e5cdb289c40cbb92 Mon Sep 17 00:00:00 2001 From: Charles d'Avernas Date: Wed, 8 Jan 2025 15:24:42 +0100 Subject: [PATCH 4/4] Fix Process Result examples in the `dsl-reference.md` Signed-off-by: Charles d'Avernas --- dsl-reference.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dsl-reference.md b/dsl-reference.md index 4f3fd799..9e1bb836 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -1916,7 +1916,7 @@ do: run: container: image: fake-image - return: stderr + return: stderr - runScript: run: @@ -1924,13 +1924,13 @@ do: language: js code: > Some cool multiline script - return: code + return: code - runShell: run: shell: command: 'echo "Hello, ${ .user.name }"' - return: all + return: all - runWorkflow: run: @@ -1939,5 +1939,5 @@ do: name: do-stuff version: '0.1.0' input: {} - return: none + return: none ``` \ No newline at end of file