Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 35 additions & 5 deletions dsl-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,8 @@ Enables the execution of external processes encapsulated within a containerized
| ports | `map` | `no` | The container's port mappings, if any |
| volumes | `map` | `no` | The container's volume mappings, if any |
| environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured process |
| stdin | `string` | `no` | A runtime expression, if any, passed as argv to the command or default container CMD|
| arguments | `string[]` | `no` | A list of the arguments, if any, passed as argv to the command or default container CMD |
| lifetime | [`containerLifetime`](#container-lifetime) | `no` | An object used to configure the container's lifetime. |

###### Examples
Expand All @@ -939,10 +941,23 @@ document:
name: run-container-example
version: '0.1.0'
do:
- setInput:
set:
message: Hello World
- runContainer:
input:
from: ${ .message }
run:
container:
image: fake-image
image: alpine
stdin: ${ . }
command: |
input=$(cat)
echo "STDIN was: $input"
echo "ARGS are $1 $2"
arguments:
- Foo
- Bar
```

> [!NOTE]
Expand All @@ -961,9 +976,11 @@ Enables the execution of custom scripts or code within a workflow, empowering wo
| language | `string` | `yes` | The language of the script to run.<br>*Supported values are: [`js`](https://tc39.es/ecma262/2024/) and [`python`](https://www.python.org/downloads/release/python-3131/).* |
| code | `string` | `no` | The script's code.<br>*Required if `source` has not been set.* |
| source | [externalResource](#external-resource) | `no` | The script's resource.<br>*Required if `code` has not been set.* |
| arguments | `map` | `no` | A list of the arguments, if any, of the script to run |
| stdin | `string` | `no` | A runtime expression, if any, to the script as standard input (stdin).|
| arguments | `string[]` | `no` | A list of the arguments, if any, to the script as argv |
| environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured script process |


> [!WARNING]
> To ensure cross-compatibility, Serverless Workflow strictly limits the versions of supported scripting languages. These versions may evolve with future releases. If you wish to use a different version of a language, you may do so by utilizing the [`container process`](#container-process).

Expand Down Expand Up @@ -1001,7 +1018,8 @@ Enables the execution of shell commands within a workflow, enabling workflows to
| Name | Type | Required | Description |
|:--|:---:|:---:|:---|
| command | `string` | `yes` | The shell command to run |
| arguments | `map` | `no` | A list of the arguments of the shell command to run |
| stdin | `string` | `no` | A runtime expression, if any, to the shell command as standard input (stdin).|
| arguments | `string[]` | `no` | A list of the arguments, if any, to the shell command as argv |
| environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured process |

###### Examples
Expand All @@ -1013,10 +1031,22 @@ document:
name: run-shell-example
version: '0.1.0'
do:
- setInput:
set:
message: Hello World
- runShell:
input:
from: ${ .message }
run:
shell:
command: 'echo "Hello, ${ .user.name }"'
stdin: ${ . }
command: |
input=$(cat)
echo "STDIN was: $input"
echo "ARGS are $1 $2"
arguments:
- Foo
- Bar
```

##### Workflow Process
Expand Down Expand Up @@ -2829,4 +2859,4 @@ Describes the client of a [Model Context Protocol (MCP)](https://modelcontextpro
```yaml
name: synapse
version: '1.0.0-alpha5.2'
```
```
23 changes: 23 additions & 0 deletions examples/run-container-stdin-and-arguments.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
document:
dsl: '1.0.2'
namespace: test
name: run-container-stdin-and-arguments
version: '0.1.0'
do:
- setInput:
set:
message: Hello World
- runContainer:
input:
from: ${ .message }
run:
container:
image: alpine
command: |
input=$(cat)
echo "STDIN was: $input"
echo "ARGS are $1 $2"
stdin: ${ . }
arguments:
- Foo
- Bar
14 changes: 0 additions & 14 deletions examples/run-script-with-arguments.yaml

This file was deleted.

30 changes: 30 additions & 0 deletions examples/run-script-with-stdin-and-arguments.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
document:
dsl: 1.0.2
namespace: examples
name: run-script-with-stdin-and-arguments
version: 1.0.0
do:
- runScript:
output:
as: "${ fromjson }"
run:
script:
language: javascript
stdin: "Hello Workflow"
environment:
foo: bar
arguments:
- hello
code: |
// Reading Input from STDIN
import { readFileSync } from 'node:fs';
const stdin = readFileSync(process.stdin.fd, 'utf8');
console.log('stdin > ', stdin) // Output: stdin > Hello Workflow
// Reading from argv
const [_, __, arg] = process.argv;
console.log('arg > ', arg) // Output: arg > hello
// Reading from env
const foo = process.env.foo;
console.log('env > ', foo) // Output: env > bar
22 changes: 22 additions & 0 deletions examples/run-shell-stdin-and-arguments.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
document:
dsl: 1.0.2
namespace: examples
name: run-script-with-stdin-and-arguments
version: 1.0.0
do:
- setInput:
set:
message: Hello World
- runShell:
input:
from: ${ .message }
run:
shell:
stdin: ${ . }
command: |
input=$(cat)
echo "STDIN was: $input"
echo "ARGS are $1 $2"
arguments:
- Foo
- Bar
34 changes: 27 additions & 7 deletions schema/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,16 @@ $defs:
type: object
title: ContainerEnvironment
description: A key/value mapping of the environment variables, if any, to use when running the configured process.
stdin:
type: string
title: ContainerStdin
description: A runtime expression, if any, passed as argv to the command or default container CMD
arguments:
type: array
title: ContainerArguments
description: A list of the arguments, if any, passed as argv to the command or default container CMD
items:
type: string
lifetime:
$ref: '#/$defs/containerLifetime'
title: ContainerLifetime
Expand All @@ -828,11 +838,16 @@ $defs:
type: string
title: ScriptLanguage
description: The language of the script to run.
stdin:
type: string
title: ScriptStdin
description: A runtime expression, if any, to the script as standard input (stdin).
arguments:
type: object
type: array
title: ScriptArguments
description: A key/value mapping of the arguments, if any, to use when running the configured script.
additionalProperties: true
description: A list of the arguments, if any, to the script as argv
items:
type: string
environment:
type: object
title: ScriptEnvironment
Expand Down Expand Up @@ -870,11 +885,16 @@ $defs:
type: string
title: ShellCommand
description: The shell command to run.
stdin:
type: string
title: ShellStdin
description: A runtime expression, if any, to the shell command as standard input (stdin).
arguments:
type: object
type: array
title: ShellArguments
description: A list of the arguments of the shell command to run.
additionalProperties: true
description: A list of the arguments, if any, to the shell command as argv
items:
type: string
environment:
type: object
title: ShellEnvironment
Expand Down Expand Up @@ -1928,4 +1948,4 @@ $defs:
export:
$ref: '#/$defs/export'
title: SubscriptionIteratorExport
description: An object, if any, used to customize the content of the workflow context.
description: An object, if any, used to customize the content of the workflow context.
Loading