Skip to content

Commit

Permalink
Merge branch 'main' into feat-document-async-task-output
Browse files Browse the repository at this point in the history
  • Loading branch information
cdavernas authored Jan 8, 2025
2 parents 9b7bf32 + 691ca1f commit 80eea36
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 12 deletions.
55 changes: 54 additions & 1 deletion dsl-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
+ [HTTP Response](#http-response)
+ [HTTP Request](#http-request)
+ [URI Template](#uri-template)
+ [Process Result](#process-result)

## Abstract

Expand Down Expand Up @@ -411,7 +412,7 @@ The [OpenAPI Call](#openapi-call) enables workflows to interact with external se
|:--|:---:|:---:|:---|
| document | [`externalResource`](#external-resource) | `yes` | The OpenAPI document that defines the operation to call. |
| operationId | `string` | `yes` | The id of the OpenAPI operation to call. |
| arguments | `map` | `no` | A name/value mapping of the parameters, if any, of the OpenAPI operation to call. |
| parameters | `map` | `no` | A name/value mapping of the parameters, if any, of the OpenAPI operation to call. |
| authentication | [`authentication`](#authentication) | `no` | The authentication policy, or the name of the authentication policy, to use when calling the OpenAPI operation. |
| output | `string` | `no` | The OpenAPI call's output format.<br>*Supported values are:*<br>*- `raw`, which output's the base-64 encoded [http response](#http-response) content, if any.*<br>*- `content`, which outputs the content of [http response](#http-response), possibly deserialized.*<br>*- `response`, which outputs the [http response](#http-response).*<br>*Defaults to `content`.* |

Expand Down Expand Up @@ -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.<br>*Required if `container`, `script` and `workflow` have not been set.* |
| run.workflow | [`workflow`](#workflow-process) | `no` | The definition of the workflow to run.<br>*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.<br>*When set to `false`, the task cannot wait for the process to complete and thus cannot output the process’s result. In this case, it should simply output its transformed input.*<br>*Defaults to `true`.* |
| return | `string` | `no` | Configures the output of the process.<br>*Supported values are:*<br>*- `stdout`: Outputs the content of the process **STDOUT**.*<br>*- `stderr`: Outputs the content of the process **STDERR**.*<br>*- `code`: Outputs the process's **exit code**.*<br>*- `all`: Outputs the **exit code**, the **STDOUT** content and the **STDERR** content, wrapped into a new [processResult](#process-result) object.*<br>*- `none`: Does not output anything.*<br>*Defaults to `stdout`.* |

##### Examples

Expand Down Expand Up @@ -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
```
31 changes: 20 additions & 11 deletions dsl.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,18 +343,20 @@ When the evaluation of an expression fails, runtimes **must** raise an error wit
| input | `any` | The task's transformed input. |
| output | `any` | The task's transformed output. |
| secrets | `map` | A key/value map of the workflow secrets.<br>To avoid unintentional bleeding, secrets can only be used in the `input.from` runtime expression. |
| authorization | [`authorizationDescriptor`](#authorization-descriptor) | Describes the resolved authorization, as defined by the task's authentication, if any. |
| task | [`taskDescriptor`](#task-descriptor) | Describes the current task. |
| workflow | [`workflowDescriptor`](#workflow-descriptor) | Describes the current workflow. |
| runtime | [`runtimeDescriptor`](#runtime-descriptor) | Describes the runtime. |


##### Runtime Descriptor

This argument contains information about the runtime executing the workflow.

| Name | Type | Description | Example |
|:-----|:----:|:------------| ------- |
|:-----|:----:|:------------|:--------|
| name | `string` | A human friendly name for the runtime. | `Synapse`, `Sonata` |
| version | `string` | The version of the runtime. This can be an arbitrary string | a incrementing positive integer (`362`), semantic version (`1.4.78`), commit hash (`04cd3be6da98fc35422c8caa821e0aa1ef6b2c02`) or container image label (`v0.7.43-alpine`) |
| version | `string` | The version of the runtime. This can be an arbitrary string | An incrementing positive integer (`362`), semantic version (`1.4.78`), commit hash (`04cd3be6da98fc35422c8caa821e0aa1ef6b2c02`) or container image label (`v0.7.43-alpine`) |
| metadata | `map` | An object/map of implementation specific key-value pairs. This can be chosen by runtime implementors and usage of this argument signals that a given workflow definition might not be runtime agnostic | A Software as a Service (SaaS) provider might choose to expose information about the tenant the workflow is executed for e.g. `{ "organization": { "id": "org-ff51cff2-fc83-4d70-9af1-8dacdbbce0be", "name": "example-corp" }, "featureFlags": ["fastZip", "arm64"] }`. |

##### Workflow Descriptor
Expand All @@ -377,6 +379,13 @@ This argument contains information about the runtime executing the workflow.
| output | `any` | The task's *raw* output (i.e. *BEFORE* the `output.as` expression). | |
| startedAt | [`dateTimeDescriptor`](#datetime-descriptor) | The start time of the task | |

##### Authorization Descriptor

| Name | Type | Description | Example |
|:-------|:------:|:------------|:--------|
| scheme | `string` | The resolved authorization scheme. | `Bearer` |
| parameter | `string` | The resolved authorization parameter. | `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJVadQssw5c` |

##### DateTime Descriptor

| Name | Type | Description | Example |
Expand All @@ -387,15 +396,15 @@ This argument contains information about the runtime executing the workflow.

The following table shows which arguments are available for each runtime expression:

| Runtime Expression | Evaluated on | Produces | `$context` | `$input` | `$output` | `$secrets` | `$task` | `$workflow` |
|:-------------------|:---------:|:---------:|:---------:|:---------:|:-------:|:---------:|:-------:|:----------:|
| Workflow `input.from` | Raw workflow input | Transformed workflow input | | | || ||
| Task `input.from` | Raw task input (i.e. transformed workflow input for the first task, transformed output from previous task otherwise) | Transformed task input || | ||||
| Task `if` | Transformed task input | ||| ||||
| Task definition | Transformed task input | ||| ||||
| Task `output.as` | Raw task output | Transformed task output ||| ||||
| Task `export.as` | Transformed task output | `$context` |||||||
| Workflow `output.as` | Last task's transformed output | Transformed workflow output || | || ||
| Runtime Expression | Evaluated on | Produces | `$context` | `$input` | `$output` | `$secrets` | `$task` | `$workflow` | `$runtime` | `$authorization` |
|:-------------------|:---------:|:---------:|:---------:|:---------:|:-------:|:---------:|:-------:|:----------:|:----------:|:----------:|
| Workflow `input.from` | Raw workflow input | Transformed workflow input | | | || ||| |
| Task `input.from` | Raw task input (i.e. transformed workflow input for the first task, transformed output from previous task otherwise) | Transformed task input || | ||||| |
| Task `if` | Transformed task input | ||| ||||| |
| Task definition | Transformed task input | ||| ||||||
| Task `output.as` | Raw task output | Transformed task output ||| ||||||
| Task `export.as` | Transformed task output | `$context` |||||||||
| Workflow `output.as` | Last task's transformed output | Transformed workflow output || | || ||| |

### Fault Tolerance

Expand Down
11 changes: 11 additions & 0 deletions examples/run-return-all.yaml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions examples/run-return-code.yaml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions examples/run-return-none.yaml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions examples/run-return-stderr.yaml
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions schema/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 ]

0 comments on commit 80eea36

Please sign in to comment.