Skip to content

Commit c9d42f6

Browse files
authored
fix: commands wrapper to dynamic properties (#29)
1 parent f4040b5 commit c9d42f6

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

src/main/java/io/kestra/plugin/sqlmesh/cli/SQLMeshCLI.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,13 @@ public class SQLMeshCLI extends Task implements RunnableTask<ScriptOutput>, Name
6161
@Schema(
6262
title = "The commands to execute before the main list of commands, e.g. to initialize or prepare the environment"
6363
)
64-
@PluginProperty(dynamic = true)
65-
protected List<String> beforeCommands;
64+
protected Property<List<String>> beforeCommands;
6665

6766
@Schema(
6867
title = "The commands to run in the container."
6968
)
70-
@PluginProperty(dynamic = true)
7169
@NotNull
72-
@NotEmpty
73-
protected List<String> commands;
70+
protected Property<List<String>> commands;
7471

7572
@Schema(
7673
title = "Additional environment variables for the current process."
@@ -120,13 +117,9 @@ public ScriptOutput run(RunContext runContext) throws Exception {
120117
.withNamespaceFiles(namespaceFiles)
121118
.withInputFiles(inputFiles)
122119
.withOutputFiles(renderedOutputFiles.isEmpty() ? null : renderedOutputFiles)
123-
.withCommands(
124-
ScriptService.scriptCommands(
125-
List.of("/bin/sh", "-c"),
126-
Optional.ofNullable(this.beforeCommands).map(throwFunction(runContext::render)).orElse(null),
127-
runContext.render(this.commands)
128-
)
129-
)
120+
.withInterpreter(Property.of(List.of("/bin/sh", "-c")))
121+
.withBeforeCommands(this.beforeCommands)
122+
.withCommands(this.commands)
130123
.run();
131124
}
132125

src/test/java/io/kestra/plugin/sqlmesh/cli/SQLMeshCLITest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.kestra.plugin.sqlmesh.cli;
22

33
import com.google.common.collect.ImmutableMap;
4+
import io.kestra.core.models.property.Property;
45
import io.kestra.core.utils.IdUtils;
56
import io.kestra.core.utils.TestsUtils;
67
import io.kestra.plugin.scripts.exec.scripts.models.DockerOptions;
@@ -37,7 +38,7 @@ void run() throws Exception {
3738
.id(IdUtils.create())
3839
.type(SQLMeshCLI.class.getName())
3940
.docker(DockerOptions.builder().image("ghcr.io/kestra-io/sqlmesh").entryPoint(Collections.emptyList()).build())
40-
.commands(List.of("sqlmesh --version"));
41+
.commands(Property.of(List.of("sqlmesh --version")));
4142

4243
SQLMeshCLI runner = terraformBuilder.build();
4344

@@ -48,13 +49,13 @@ void run() throws Exception {
4849

4950
runner = terraformBuilder
5051
.env(Map.of("{{ inputs.environmentKey }}", "{{ inputs.environmentValue }}"))
51-
.beforeCommands(List.of("sqlmesh init duckdb"))
52-
.commands(List.of(
52+
.beforeCommands(Property.of(List.of("sqlmesh init duckdb")))
53+
.commands(Property.of(List.of(
5354
"echo \"::{\\\"outputs\\\":{" +
5455
"\\\"customEnv\\\":\\\"$" + environmentKey + "\\\"" +
5556
"}}::\"",
5657
"sqlmesh info | tr -d ' \n' | xargs -0 -I {} echo '::{\"outputs\":{}}::'"
57-
))
58+
)))
5859
.build();
5960

6061
scriptOutput = runner.run(runContext);

0 commit comments

Comments
 (0)