diff --git a/dsl-reference.md b/dsl-reference.md index 964a2118..833d9408 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -688,7 +688,7 @@ Allows workflows to iterate over a collection of items, executing a defined set | Name | Type | Required | Description| |:--|:---:|:---:|:---| | for.each | `string` | `no` | The name of the variable used to store the current item being enumerated.
Defaults to `item`. | -| for.in | `string` | `yes` | A [runtime expression](dsl.md#runtime-expressions) used to get the collection to enumerate. | +| for.in | `string` \| `array` | `yes` | A [runtime expression](dsl.md#runtime-expressions) or an inline array of objects used to get the collection to enumerate. | | for.at | `string` | `no` | The name of the variable used to store the index of the current item being enumerated.
Defaults to `index`. | | while | `string` | `no` | A [runtime expression](dsl.md#runtime-expressions) that represents the condition, if any, that must be met for the iteration to continue. | | do | [`map[string, task]`](#task) | `yes` | The [task(s)](#task) to perform for each item in the collection. | diff --git a/examples/for-inline-array.yaml b/examples/for-inline-array.yaml new file mode 100644 index 00000000..5efda5b4 --- /dev/null +++ b/examples/for-inline-array.yaml @@ -0,0 +1,20 @@ +document: + dsl: '1.0.3' + namespace: test + name: for-inline-array-example + version: '0.1.0' +do: + - logColors: + for: + each: color + in: + - name: red + hex: '#FF0000' + - name: green + hex: '#00FF00' + - name: blue + hex: '#0000FF' + do: + - setProcessed: + set: + processed: '${ .processed + [$color] }' diff --git a/schema/workflow.yaml b/schema/workflow.yaml index 62aede63..11ad36c3 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -695,9 +695,18 @@ $defs: description: The name of the variable used to store the current item being enumerated. default: item in: - type: string title: ForIn - description: A runtime expression used to get the collection to enumerate. + description: A runtime expression or an inline array used to get the collection to enumerate. + oneOf: + - type: string + title: ForInExpression + description: A runtime expression used to get the collection to enumerate. + - type: array + title: ForInInlineArray + description: An inline array of objects to enumerate. + items: + type: object + description: An item in the inline collection. at: type: string title: ForAt