diff --git a/core/src/main/java/io/kestra/core/runners/FlowableUtils.java b/core/src/main/java/io/kestra/core/runners/FlowableUtils.java index e0d39560915..cb22a12407a 100644 --- a/core/src/main/java/io/kestra/core/runners/FlowableUtils.java +++ b/core/src/main/java/io/kestra/core/runners/FlowableUtils.java @@ -193,15 +193,36 @@ public static List resolveParallelNexts( private final static TypeReference> TYPE_REFERENCE = new TypeReference<>() {}; private final static ObjectMapper MAPPER = JacksonMapper.ofJson(); - public static List resolveEachTasks(RunContext runContext, TaskRun parentTaskRun, List tasks, String value) throws IllegalVariableEvaluationException { - String renderValue = runContext.render(value); - + public static List resolveEachTasks(RunContext runContext, TaskRun parentTaskRun, List tasks, Object value) throws IllegalVariableEvaluationException { List values; - try { - values = MAPPER.readValue(renderValue, TYPE_REFERENCE); - } catch (JsonProcessingException e) { - throw new IllegalVariableEvaluationException(e); + + if(value instanceof String) { + String renderValue = runContext.render((String) value); + try { + values = MAPPER.readValue(renderValue, TYPE_REFERENCE); + } catch (JsonProcessingException e) { + throw new IllegalVariableEvaluationException(e); + } + } + else if(value instanceof List) { + values = new ArrayList<>(((List) value).size()); + for(Object obj: (List) value) { + if(obj instanceof String){ + values.add(runContext.render((String) obj)); + } + else if(obj instanceof Map) { + //JSON or YAML map + values.add(runContext.render((Map) obj)); + } + else { + throw new IllegalVariableEvaluationException("Unknown value element type: " + obj.getClass()); + } + } } + else { + throw new IllegalVariableEvaluationException("Unknown value type: " + value.getClass()); + } + List distinctValue = values .stream() diff --git a/core/src/main/java/io/kestra/core/tasks/debugs/Echo.java b/core/src/main/java/io/kestra/core/tasks/debugs/Echo.java index 31611604ca2..4afe4e8acf1 100644 --- a/core/src/main/java/io/kestra/core/tasks/debugs/Echo.java +++ b/core/src/main/java/io/kestra/core/tasks/debugs/Echo.java @@ -22,9 +22,9 @@ @Getter @NoArgsConstructor @Schema( - title = "Simple debugging task that log a renderer value.", + title = "Debugging task that logs a rendered value.", description = "This task is mostly useful for debugging purpose.\n\n" + - "This one allow you to logs inputs or outputs variables for example, or to debug some templated functions." + "It allows you to log inputs or outputs variables or to debug some templated functions." ) @Plugin( examples = { diff --git a/core/src/main/java/io/kestra/core/tasks/debugs/Return.java b/core/src/main/java/io/kestra/core/tasks/debugs/Return.java index 6bde74518e6..aef5a8a9e1d 100644 --- a/core/src/main/java/io/kestra/core/tasks/debugs/Return.java +++ b/core/src/main/java/io/kestra/core/tasks/debugs/Return.java @@ -21,9 +21,9 @@ @Getter @NoArgsConstructor @Schema( - title = "Simple debugging task that return a renderer value.", + title = "Debugging task that returns a rendered value.", description = "This task is mostly useful for debugging purpose.\n\n" + - "This one allow you to see inputs or outputs variables for example, or to debug some templated functions." + "It allows you to see inputs or outputs variables or to debug some templated functions." ) @Plugin( examples = { @@ -34,7 +34,7 @@ ) public class Return extends Task implements RunnableTask { @Schema( - title = "The templatized string to render" + title = "The templated string to render" ) @PluginProperty(dynamic = true) private String format; diff --git a/core/src/main/java/io/kestra/core/tasks/executions/Counts.java b/core/src/main/java/io/kestra/core/tasks/executions/Counts.java index 59b9223a66e..b550b358ade 100644 --- a/core/src/main/java/io/kestra/core/tasks/executions/Counts.java +++ b/core/src/main/java/io/kestra/core/tasks/executions/Counts.java @@ -31,12 +31,12 @@ @NoArgsConstructor @Schema( title = "List execution counts for a list of flow", - description = "Mostly use for send an alert if a conditions is meet about execution counts." + description = "Can be used to send an alert if a condition is met about execution counts." ) @Plugin( examples = { @Example( - title = "Send a slack notification if no execution for a flow on last 24h", + title = "Send a slack notification if no execution for a flow on the last 24h", full = true, code = { "id: executions-count", diff --git a/core/src/main/java/io/kestra/core/tasks/flows/AllowFailure.java b/core/src/main/java/io/kestra/core/tasks/flows/AllowFailure.java index f2f0b76f552..3671bbb0fd2 100644 --- a/core/src/main/java/io/kestra/core/tasks/flows/AllowFailure.java +++ b/core/src/main/java/io/kestra/core/tasks/flows/AllowFailure.java @@ -27,8 +27,8 @@ @Getter @NoArgsConstructor @Schema( - title = "Allow a task to failed", - description = "If any child tasks failed, the flow will stop child tasks, but will continue the main flow." + title = "Allow a list of task to fail", + description = "If any child tasks failed, the flow will stop executing child tasks, but will continue on the main flow execution." ) @Plugin( examples = { diff --git a/core/src/main/java/io/kestra/core/tasks/flows/EachParallel.java b/core/src/main/java/io/kestra/core/tasks/flows/EachParallel.java index 288ef72c5f1..abb2aebe5d5 100644 --- a/core/src/main/java/io/kestra/core/tasks/flows/EachParallel.java +++ b/core/src/main/java/io/kestra/core/tasks/flows/EachParallel.java @@ -33,12 +33,12 @@ @Getter @NoArgsConstructor @Schema( - title = "Execute a tasks for a list of value in parallel.", - description = "For each `value`, `tasks` will be executed\n" + - "The value must be valid json string representing an arrays, like `[\"value1\", \"value2\"]` or `[{\"key\":\"value1\"}, {\"key\":\"value2\"}]` \n" + - "The current value is available on vars `{{ taskrun.value }}`.\n" + - "The task list will be executed in parallel, for example if you have a 3 value with each one 2 tasks, all the " + - "6 tasks will be computed in parallel with out any garantee on the order.\n" + + title = "Execute a task for a list of values in parallel.", + description = "For each `value`, the `tasks` list will be executed\n" + + "The value must be valid json string representing an arrays, like `[\"value1\", \"value2\"]` or `[{\"key\":\"value1\"}, {\"key\":\"value2\"}]` or an array of valid JSON strings.\n" + + "The current value is available on the variable `{{ taskrun.value }}`.\n" + + "The task list will be executed in parallel, for example if you have a 3 values with 2 tasks, all the " + + "6 tasks will be computed in parallel without any guarantee on the order.\n" + "If you want to have each value in parallel, but no concurrent task for each value, you need to wrap the tasks " + "with a `Sequential` tasks" ) @@ -54,7 +54,19 @@ } ), @Example( - title = "Handling each value in parralel but only 1 child task for each value at the same time.", + code = { + "value: ", + "- value 1", + "- value 2", + "- value 3", + "tasks:", + " - id: each-value", + " type: io.kestra.core.tasks.debugs.Return", + " format: \"{{ task.id }} with current value '{{ taskrun.value }}'\"", + } + ), + @Example( + title = "Handling each value in parallel but only 1 child task for each value at the same time.", code = { "value: '[\"value 1\", \"value 2\", \"value 3\"]'", "tasks:", @@ -80,7 +92,7 @@ public class EachParallel extends Parallel implements FlowableTask { @NotBlank @Builder.Default @Schema( - title = "Number of concurrent parrallels tasks", + title = "Number of concurrent parallel tasks", description = "If the value is `0`, no limit exist and all the tasks will start at the same time" ) @PluginProperty @@ -89,7 +101,12 @@ public class EachParallel extends Parallel implements FlowableTask { @NotNull @NotBlank @PluginProperty(dynamic = true) - private String value; + @Schema( + title = "The list of values for this task", + description = "The value car be passed as a String, a list of String, or a list of objects", + anyOf = {String.class, Object[].class} + ) + private Object value; @Valid @PluginProperty diff --git a/core/src/main/java/io/kestra/core/tasks/flows/EachSequential.java b/core/src/main/java/io/kestra/core/tasks/flows/EachSequential.java index f19d6307217..9cd20c2c856 100644 --- a/core/src/main/java/io/kestra/core/tasks/flows/EachSequential.java +++ b/core/src/main/java/io/kestra/core/tasks/flows/EachSequential.java @@ -36,10 +36,10 @@ @Getter @NoArgsConstructor @Schema( - title = "Execute a tasks for a list of value sequentially", - description = "For each `value`, `tasks` will be executed\n" + - "The value must be valid json string representing an arrays, like `[\"value1\", \"value2\"]` or `[{\"key\":\"value1\"}, {\"key\":\"value2\"}]` \n" + - "The current value is available on vars `{{ taskrun.value }}`." + title = "Execute a task for a list of values sequentially", + description = "For each `value`, the `tasks` list will be executed\n" + + "The value must be valid json string representing an arrays, like `[\"value1\", \"value2\"]` or `[{\"key\":\"value1\"}, {\"key\":\"value2\"}]` or an array of valid JSON strings.\n" + + "The current value is available on the variable `{{ taskrun.value }}`." ) @Plugin( examples = { @@ -51,14 +51,31 @@ " type: io.kestra.core.tasks.debugs.Return", " format: \"{{ task.id }} with current value '{{ taskrun.value }}'\"", } - ) + ), + @Example( + code = { + "value: ", + "- value 1", + "- value 2", + "- value 3", + "tasks:", + " - id: each-value", + " type: io.kestra.core.tasks.debugs.Return", + " format: \"{{ task.id }} with current value '{{ taskrun.value }}'\"", + } + ), } ) public class EachSequential extends Sequential implements FlowableTask { @NotNull @NotBlank @PluginProperty(dynamic = true) - private String value; + @Schema( + title = "The list of values for this task", + description = "The value car be passed as a String, a list of String, or a list of objects", + anyOf = {String.class, Object[].class} + ) + private Object value; @Valid @PluginProperty diff --git a/core/src/main/java/io/kestra/core/tasks/flows/Flow.java b/core/src/main/java/io/kestra/core/tasks/flows/Flow.java index ff0c0d5daff..5c5e6da1746 100644 --- a/core/src/main/java/io/kestra/core/tasks/flows/Flow.java +++ b/core/src/main/java/io/kestra/core/tasks/flows/Flow.java @@ -32,7 +32,7 @@ @Plugin( examples = { @Example( - title = "Trigger another flow, passing some file and arguments", + title = "Trigger another flow, passing some files and arguments as inputs", code = { "namespace: io.kestra.tests", "flowId: my-sub-flows", @@ -54,13 +54,13 @@ public class Flow extends Task implements RunnableTask { @NotNull @Schema( - title = "The flowId to trigger" + title = "The identifier of the flow to trigger" ) @PluginProperty(dynamic = true) private String flowId; @Schema( - title = "The revision of the flow you want to trigger", + title = "The revision of the flow to trigger", description = "By default, we trigger the last version." ) @PluginProperty(dynamic = true) @@ -90,7 +90,7 @@ public class Flow extends Task implements RunnableTask { @Schema( title = "Extract outputs from triggered executions.", - description = "Allow to specify key value (with value renderered), in order to extract any outputs from " + + description = "Allow to specify key value (with value rendered), in order to extract any outputs from " + "triggered execution." ) @PluginProperty(dynamic = true) diff --git a/core/src/main/java/io/kestra/core/tasks/flows/Parallel.java b/core/src/main/java/io/kestra/core/tasks/flows/Parallel.java index 57c31243fcd..2e69bc38562 100644 --- a/core/src/main/java/io/kestra/core/tasks/flows/Parallel.java +++ b/core/src/main/java/io/kestra/core/tasks/flows/Parallel.java @@ -33,8 +33,8 @@ @Getter @NoArgsConstructor @Schema( - title = "Process task in parallel", - description = "This task processes tasks in parallel. It makes it convinient to process many tasks at once." + title = "Process tasks in parallel", + description = "This task processes tasks in parallel. It makes it convenient to process many tasks at once." ) @Plugin( examples = { @@ -66,7 +66,7 @@ public class Parallel extends Task implements FlowableTask { @NotBlank @Builder.Default @Schema( - title = "Number of concurrent parrallels tasks", + title = "Number of concurrent parallel tasks", description = "If the value is `0`, no limit exist and all the tasks will start at the same time" ) @PluginProperty diff --git a/core/src/main/java/io/kestra/core/tasks/flows/Pause.java b/core/src/main/java/io/kestra/core/tasks/flows/Pause.java index 49846d46773..b35ff2b1047 100644 --- a/core/src/main/java/io/kestra/core/tasks/flows/Pause.java +++ b/core/src/main/java/io/kestra/core/tasks/flows/Pause.java @@ -30,7 +30,7 @@ @Getter @NoArgsConstructor @Schema( - title = "Pause current execution and wait for a manual approval or a delay" + title = "Pause the current execution and wait for a manual approval (changing the task state from the UI) or a delay" ) @Plugin( examples = { diff --git a/core/src/main/java/io/kestra/core/tasks/flows/Sequential.java b/core/src/main/java/io/kestra/core/tasks/flows/Sequential.java index 600a1413c14..eca8c0fa581 100644 --- a/core/src/main/java/io/kestra/core/tasks/flows/Sequential.java +++ b/core/src/main/java/io/kestra/core/tasks/flows/Sequential.java @@ -35,8 +35,8 @@ @Getter @NoArgsConstructor @Schema( - title = "Process tasks ones after others sequentially", - description = "Mostly use in order to group tasks." + title = "Process tasks one after the other sequentially", + description = "Used to group tasks." ) @Plugin( examples = { diff --git a/core/src/main/java/io/kestra/core/tasks/flows/Switch.java b/core/src/main/java/io/kestra/core/tasks/flows/Switch.java index 8d6cd20dc10..26b3b1c9a54 100644 --- a/core/src/main/java/io/kestra/core/tasks/flows/Switch.java +++ b/core/src/main/java/io/kestra/core/tasks/flows/Switch.java @@ -41,8 +41,8 @@ @Getter @NoArgsConstructor @Schema( - title = "Process some tasks conditionnaly depending on a contextual value", - description = "Allow some workflow based on context variables, allow you to branch your based on previous task." + title = "Process some tasks conditionally depending on a contextual value", + description = "Allow some workflow based on context variables, for example branch a flow based on a previous task." ) @Plugin( examples = { diff --git a/core/src/main/java/io/kestra/core/tasks/flows/Template.java b/core/src/main/java/io/kestra/core/tasks/flows/Template.java index 3efcde2b073..c82d2bdc4ea 100644 --- a/core/src/main/java/io/kestra/core/tasks/flows/Template.java +++ b/core/src/main/java/io/kestra/core/tasks/flows/Template.java @@ -48,7 +48,7 @@ @NoArgsConstructor @Slf4j @Schema( - title = "Include a resuable template inside a flow" + title = "Include a reusable template inside a flow" ) @Plugin( examples = { diff --git a/core/src/main/java/io/kestra/core/tasks/scripts/Node.java b/core/src/main/java/io/kestra/core/tasks/scripts/Node.java index 1a1683df243..ebea8569f9b 100644 --- a/core/src/main/java/io/kestra/core/tasks/scripts/Node.java +++ b/core/src/main/java/io/kestra/core/tasks/scripts/Node.java @@ -27,8 +27,8 @@ @NoArgsConstructor @Schema( title = "Execute a Node.js script", - description = "With this Node task, we can execute a full javascript script.\n" + - "The task will create a temprorary folder for every tasks and allows you to install some npm packages defined in an optional `package.json` file.\n" + + description = "With the Node task, you can execute a full javascript script.\n" + + "The task will create a temporary folder for each tasks and allows to install some npm packages defined in an optional `package.json` file.\n" + "\n" + "By convention, you need to define at least a `main.js` files in `inputFiles` that will be the script used.\n" + "You can also add as many javascript files as you need in `inputFiles`.\n" + diff --git a/core/src/main/java/io/kestra/core/tasks/scripts/Python.java b/core/src/main/java/io/kestra/core/tasks/scripts/Python.java index 12ed0c62398..c2a962e6391 100644 --- a/core/src/main/java/io/kestra/core/tasks/scripts/Python.java +++ b/core/src/main/java/io/kestra/core/tasks/scripts/Python.java @@ -27,8 +27,8 @@ @NoArgsConstructor @Schema( title = "Execute a Python script", - description = "With this Python task, we can execute a full python script.\n" + - "The task will create a fresh `virtualenv` for every tasks and allow you to install some python package define in `requirements` property.\n" + + description = "With the Python task, you can execute a full Python script.\n" + + "The task will create a fresh `virtualenv` for every tasks and allows to install some Python package define in `requirements` property.\n" + "\n" + "By convention, you need to define at least a `main.py` files in `inputFiles` that will be the script used.\n" + "But you are also able to add as many script as you need in `inputFiles`.\n" + diff --git a/core/src/main/java/io/kestra/core/tasks/states/Delete.java b/core/src/main/java/io/kestra/core/tasks/states/Delete.java index 3134e0db670..0dc58803979 100644 --- a/core/src/main/java/io/kestra/core/tasks/states/Delete.java +++ b/core/src/main/java/io/kestra/core/tasks/states/Delete.java @@ -17,17 +17,26 @@ @Getter @NoArgsConstructor @Schema( - title = "Delete a state from internal storage." + title = "Delete a state from the state store." ) @Plugin( examples = { @Example( - title = "Delete a state isolated by flow with `default` state name ", + title = "Delete the default state for the current flow", code = { "id: getState", "type: io.kestra.core.tasks.states.Delete", }, full = true + ), + @Example( + title = "Delete the `myState` state for the current flow", + code = { + "id: getState", + "type: io.kestra.core.tasks.states.Delete", + "name: myState", + }, + full = true ) } ) diff --git a/core/src/main/java/io/kestra/core/tasks/states/Get.java b/core/src/main/java/io/kestra/core/tasks/states/Get.java index a5880b981c1..ef3d71ae314 100644 --- a/core/src/main/java/io/kestra/core/tasks/states/Get.java +++ b/core/src/main/java/io/kestra/core/tasks/states/Get.java @@ -18,17 +18,26 @@ @Getter @NoArgsConstructor @Schema( - title = "Get a state from internal storage." + title = "Get a state from the state store." ) @Plugin( examples = { @Example( - title = "Get a state isolated by flow with `default` state name ", + title = "Get the default state for the current flow", code = { "id: getState", "type: io.kestra.core.tasks.states.Get", }, full = true + ), + @Example( + title = "Get the `myState` state for the current flow", + code = { + "id: getState", + "type: io.kestra.core.tasks.states.Get", + "name: myState", + }, + full = true ) } ) diff --git a/core/src/main/java/io/kestra/core/tasks/states/Set.java b/core/src/main/java/io/kestra/core/tasks/states/Set.java index c406af25aac..7bcb60c993a 100644 --- a/core/src/main/java/io/kestra/core/tasks/states/Set.java +++ b/core/src/main/java/io/kestra/core/tasks/states/Set.java @@ -19,7 +19,7 @@ @Getter @NoArgsConstructor @Schema( - title = "Set a state from internal storage.", + title = "Set a state in the state store.", description = "Values will be merged: \n" + "* If you provide a new key, the new key will be added\n" + "* If you provide an existing key, the previous key will be overwrite\n" + @@ -32,7 +32,17 @@ @Plugin( examples = { @Example( - title = "Set a state key isolated by flow with `default` state name ", + title = "Set the default state for the current flow", + code = { + "id: setState", + "type: io.kestra.core.tasks.states.Set", + "data:", + " '{{ inputs.store }}': '{{ outputs.download.md5 }}'", + }, + full = true + ), + @Example( + title = "Set the `myState` state for the current flow", code = { "id: setState", "type: io.kestra.core.tasks.states.Set", diff --git a/core/src/main/java/io/kestra/core/tasks/storages/Concat.java b/core/src/main/java/io/kestra/core/tasks/storages/Concat.java index f08e3d3104d..54ad463d933 100644 --- a/core/src/main/java/io/kestra/core/tasks/storages/Concat.java +++ b/core/src/main/java/io/kestra/core/tasks/storages/Concat.java @@ -28,7 +28,7 @@ @Getter @NoArgsConstructor @Schema( - title = "Concat files from internal storage." + title = "Concat files from the internal storage." ) @Plugin( examples = { @@ -42,7 +42,7 @@ } ), @Example( - title = "Concat file generated by a each tasks", + title = "Concat files generated by an each task", code = { "tasks:", " - id: each", @@ -65,7 +65,7 @@ full = true ), @Example( - title = "Concat dynamic number of files", + title = "Concat a dynamic number of files", code = { "tasks:", " - id: echo", diff --git a/core/src/main/java/io/kestra/core/tasks/storages/Delete.java b/core/src/main/java/io/kestra/core/tasks/storages/Delete.java index 8631a59c796..a79052ebc72 100644 --- a/core/src/main/java/io/kestra/core/tasks/storages/Delete.java +++ b/core/src/main/java/io/kestra/core/tasks/storages/Delete.java @@ -20,7 +20,7 @@ @Getter @NoArgsConstructor @Schema( - title = "Delete a file from internal storage." + title = "Delete a file from the internal storage." ) @Plugin( examples = { diff --git a/core/src/main/java/io/kestra/core/tasks/storages/PurgeExecution.java b/core/src/main/java/io/kestra/core/tasks/storages/PurgeExecution.java index acb05ea33ab..eb6b83ffda2 100644 --- a/core/src/main/java/io/kestra/core/tasks/storages/PurgeExecution.java +++ b/core/src/main/java/io/kestra/core/tasks/storages/PurgeExecution.java @@ -18,13 +18,13 @@ @Getter @NoArgsConstructor @Schema( - title = "Purge all files from internal storage created by this execution.", + title = "Purge all files from the internal storage created by this execution.", description = "Will delete all the generated files from a flow for this current execution. This will delete:\n+" + "- inputs\n" + "- outputs\n" + "- triggers\n\n + " + "If the current execution don't have any generated files, the task will not failed.\n" + - "If you pass a internal storage uri from another execution, it **will not** be deleted, only current execution is deleted." + "If you pass an internal storage URI from another execution, it **will not** be deleted, only files from the current execution are deleted." ) @Plugin( examples = { diff --git a/core/src/main/java/io/kestra/core/tasks/storages/Size.java b/core/src/main/java/io/kestra/core/tasks/storages/Size.java index 77ab1fd5b7c..89c8b5bb869 100644 --- a/core/src/main/java/io/kestra/core/tasks/storages/Size.java +++ b/core/src/main/java/io/kestra/core/tasks/storages/Size.java @@ -19,7 +19,7 @@ @Getter @NoArgsConstructor @Schema( - title = "Get a filesize from internal storage." + title = "Get the size of a file from the internal storage." ) @Plugin( examples = { @@ -33,7 +33,7 @@ public class Size extends Task implements RunnableTask { @Schema( title = "the file", - description = "Must be a `kestra://` storage url" + description = "Must be a `kestra://` storage URL" ) @PluginProperty(dynamic = true) private String uri; diff --git a/core/src/main/java/io/kestra/core/tasks/storages/Split.java b/core/src/main/java/io/kestra/core/tasks/storages/Split.java index 5df73f47499..fa76c306d7b 100644 --- a/core/src/main/java/io/kestra/core/tasks/storages/Split.java +++ b/core/src/main/java/io/kestra/core/tasks/storages/Split.java @@ -30,26 +30,26 @@ @Getter @NoArgsConstructor @Schema( - title = "Split files from internal storage on multiple files." + title = "Split a file from the internal storage onto multiple files." ) @Plugin( examples = { @Example( - title = "Split file by file size.", + title = "Split a file by size.", code = { "from: \"kestra://long/url/file1.txt\"", "bytes: 10MB" } ), @Example( - title = "Split file by rows count.", + title = "Split a file by rows count.", code = { "from: \"kestra://long/url/file1.txt\"", "rows: 1000" } ), @Example( - title = "Partition a file in a defined number of partitions.", + title = "Split a file in a defined number of partitions.", code = { "from: \"kestra://long/url/file1.txt\"", "partitions: 8" @@ -59,7 +59,7 @@ ) public class Split extends Task implements RunnableTask { @Schema( - title = "The file to be splitted." + title = "The file to be split." ) @PluginProperty(dynamic = true) private String from; diff --git a/core/src/test/java/io/kestra/core/Helpers.java b/core/src/test/java/io/kestra/core/Helpers.java index 3fe142ef906..9cc950bc135 100644 --- a/core/src/test/java/io/kestra/core/Helpers.java +++ b/core/src/test/java/io/kestra/core/Helpers.java @@ -19,7 +19,7 @@ import java.util.function.Consumer; public class Helpers { - public static long FLOWS_COUNT = 55; + public static long FLOWS_COUNT = 56; public static ApplicationContext applicationContext() throws URISyntaxException { return applicationContext( diff --git a/core/src/test/java/io/kestra/core/docs/DocumentationGeneratorTest.java b/core/src/test/java/io/kestra/core/docs/DocumentationGeneratorTest.java index 23347db994f..f02ae74d7fe 100644 --- a/core/src/test/java/io/kestra/core/docs/DocumentationGeneratorTest.java +++ b/core/src/test/java/io/kestra/core/docs/DocumentationGeneratorTest.java @@ -71,7 +71,7 @@ void returnDoc() throws IOException { String render = DocumentationGenerator.render(doc); - assertThat(render, containsString("debugging task that return")); + assertThat(render, containsString("Debugging task that return")); assertThat(render, containsString("is mostly useful")); } diff --git a/core/src/test/java/io/kestra/core/tasks/flows/EachSequentialTest.java b/core/src/test/java/io/kestra/core/tasks/flows/EachSequentialTest.java index 8824848b6d9..c9dfd78a044 100644 --- a/core/src/test/java/io/kestra/core/tasks/flows/EachSequentialTest.java +++ b/core/src/test/java/io/kestra/core/tasks/flows/EachSequentialTest.java @@ -1,6 +1,5 @@ package io.kestra.core.tasks.flows; -import org.hamcrest.Matchers; import org.junit.jupiter.api.Test; import io.kestra.core.exceptions.InternalException; import io.kestra.core.models.executions.Execution; @@ -45,6 +44,15 @@ void object() throws TimeoutException { assertThat((String) execution.getTaskRunList().get(6).getOutputs().get("value"), containsString("json > JSON > [\"my-complex\"]")); } + @Test + void objectInList() throws TimeoutException { + Execution execution = runnerUtils.runOne("io.kestra.tests", "each-object-in-list"); + + assertThat(execution.getTaskRunList(), hasSize(8)); + assertThat(execution.getState().getCurrent(), is(State.Type.SUCCESS)); + assertThat((String) execution.getTaskRunList().get(6).getOutputs().get("value"), containsString("json > JSON > [\"my-complex\"]")); + } + @Test void sequentialNested() throws TimeoutException, InternalException { Execution execution = runnerUtils.runOne("io.kestra.tests", "each-sequential-nested"); diff --git a/core/src/test/resources/flows/valids/each-object-in-list.yaml b/core/src/test/resources/flows/valids/each-object-in-list.yaml new file mode 100644 index 00000000000..8384291942e --- /dev/null +++ b/core/src/test/resources/flows/valids/each-object-in-list.yaml @@ -0,0 +1,31 @@ +id: each-object-in-list +namespace: io.kestra.tests + +tasks: + - id: 1_each + type: io.kestra.core.tasks.flows.EachSequential + value: + - value 1 + - {"key": "my-key", "value": "my-value"} + - key: my-complex + value: + sub: 1 + bool: true + + tasks: + - id: is-json + type: io.kestra.core.tasks.flows.Switch + value: "{{ taskrun.value is json }}" + cases: + "false": + - id: not-json + type: io.kestra.core.tasks.debugs.Return + format: "{{task.id}} > STRING > {{parent.taskrun.value}}" + defaults: + - id: json + type: io.kestra.core.tasks.debugs.Return + format: "{{task.id}} > JSON > {{ parent.taskrun.value | jq('.key') }} > {{ parent.taskrun.value | jq('.value') }}" + + - id: 2_end + type: io.kestra.core.tasks.debugs.Return + format: "{{task.id}} > {{taskrun.startDate}}" diff --git a/core/src/test/resources/flows/valids/each-parallel-nested.yaml b/core/src/test/resources/flows/valids/each-parallel-nested.yaml index 31b0823aba5..667ac7bbe16 100644 --- a/core/src/test/resources/flows/valids/each-parallel-nested.yaml +++ b/core/src/test/resources/flows/valids/each-parallel-nested.yaml @@ -4,7 +4,10 @@ namespace: io.kestra.tests tasks: - id: 1_each type: io.kestra.core.tasks.flows.EachParallel - value: '["value 1", "value 2", "value 3"]' + value: + - value 1 + - value 2 + - value 3 tasks: - id: 2-1_seq type: io.kestra.core.tasks.flows.Sequential diff --git a/core/src/test/resources/flows/valids/each-sequential-nested.yaml b/core/src/test/resources/flows/valids/each-sequential-nested.yaml index 41b398b13fe..dd9518e5e5c 100644 --- a/core/src/test/resources/flows/valids/each-sequential-nested.yaml +++ b/core/src/test/resources/flows/valids/each-sequential-nested.yaml @@ -4,7 +4,7 @@ namespace: io.kestra.tests tasks: - id: 1_each type: io.kestra.core.tasks.flows.EachSequential - value: '["s1", "s2", "s3"]' + value: ["s1", "s2", "s3"] tasks: - id: 1-1_return type: io.kestra.core.tasks.debugs.Return