From 251044b79da6098d213faa14b24416862a4ab3c0 Mon Sep 17 00:00:00 2001 From: Mathieu Gabelle Date: Thu, 26 Sep 2024 09:59:38 +0200 Subject: [PATCH] fix(v2 property): back to v1 when annotation != @NotNull V2 properties does not support other annotations than @NotNull for now. To prevent bugs we just revert the properties to v1 when other annotations are involved --- src/main/java/io/kestra/plugin/dbt/cli/AbstractDbt.java | 1 - src/main/java/io/kestra/plugin/dbt/cli/DbtCLI.java | 5 +++-- src/main/java/io/kestra/plugin/dbt/cli/Setup.java | 5 +++-- src/test/java/io/kestra/plugin/dbt/cli/DbtCLITest.java | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/kestra/plugin/dbt/cli/AbstractDbt.java b/src/main/java/io/kestra/plugin/dbt/cli/AbstractDbt.java index e992125..e8e00ea 100644 --- a/src/main/java/io/kestra/plugin/dbt/cli/AbstractDbt.java +++ b/src/main/java/io/kestra/plugin/dbt/cli/AbstractDbt.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.annotation.JsonSetter; import io.kestra.core.exceptions.IllegalVariableEvaluationException; -import io.kestra.core.models.annotations.Plugin; import io.kestra.core.models.annotations.PluginProperty; import io.kestra.core.models.property.Property; import io.kestra.core.models.tasks.*; diff --git a/src/main/java/io/kestra/plugin/dbt/cli/DbtCLI.java b/src/main/java/io/kestra/plugin/dbt/cli/DbtCLI.java index 45c3035..549503e 100644 --- a/src/main/java/io/kestra/plugin/dbt/cli/DbtCLI.java +++ b/src/main/java/io/kestra/plugin/dbt/cli/DbtCLI.java @@ -181,7 +181,8 @@ public class DbtCLI extends AbstractExecScript { ) @NotNull @NotEmpty - private Property> commands; + @PluginProperty(dynamic = true) + private List commands; @Schema( title = "The `profiles.yml` file content.", @@ -266,7 +267,7 @@ public void accept(String line, Boolean isStdErr) { List commandsArgs = ScriptService.scriptCommands( this.interpreter, this.getBeforeCommandsWithOptions(), - this.commands.asList(runContext, String.class).stream().map(command -> command.concat(" --log-format json")).toList() + runContext.render(this.commands).stream().map(command -> command.concat(" --log-format json")).toList() ); // check that if a command uses --project-dir, the projectDir must be set diff --git a/src/main/java/io/kestra/plugin/dbt/cli/Setup.java b/src/main/java/io/kestra/plugin/dbt/cli/Setup.java index 03b1ff4..2623166 100644 --- a/src/main/java/io/kestra/plugin/dbt/cli/Setup.java +++ b/src/main/java/io/kestra/plugin/dbt/cli/Setup.java @@ -110,7 +110,8 @@ public class Setup extends AbstractExecScript implements RunnableTask pythonPath = Property.of(DEFAULT_IMAGE); + @PluginProperty(dynamic = true) + private final String pythonPath = DEFAULT_IMAGE; @Schema( title = "List of python dependencies to add to the python execution process.", @@ -213,7 +214,7 @@ public ScriptOutput run(RunContext runContext) throws Exception { private List virtualEnvCommand(RunContext runContext, Path workingDirectory, List requirements) throws IllegalVariableEvaluationException { List renderer = new ArrayList<>(); - renderer.add(this.pythonPath.as(runContext, String.class) + " -m venv --system-site-packages " + workingDirectory + " > /dev/null"); + renderer.add(runContext.render(this.pythonPath) + " -m venv --system-site-packages " + workingDirectory + " > /dev/null"); if (requirements != null) { renderer.addAll(Arrays.asList( diff --git a/src/test/java/io/kestra/plugin/dbt/cli/DbtCLITest.java b/src/test/java/io/kestra/plugin/dbt/cli/DbtCLITest.java index 1209737..c29ee6b 100644 --- a/src/test/java/io/kestra/plugin/dbt/cli/DbtCLITest.java +++ b/src/test/java/io/kestra/plugin/dbt/cli/DbtCLITest.java @@ -62,7 +62,7 @@ void run() throws Exception { """) ) .containerImage("ghcr.io/kestra-io/dbt-bigquery:latest") - .commands(Property.of(List.of("dbt build"))) + .commands(List.of("dbt build")) .build(); RunContext runContext = TestsUtils.mockRunContext(runContextFactory, execute, Map.of());