Skip to content

Commit

Permalink
fix(v2 property): back to v1 when annotation != @NotNull
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mgabelle committed Sep 26, 2024
1 parent cedef15 commit 251044b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/main/java/io/kestra/plugin/dbt/cli/AbstractDbt.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/io/kestra/plugin/dbt/cli/DbtCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ public class DbtCLI extends AbstractExecScript {
)
@NotNull
@NotEmpty
private Property<List<String>> commands;
@PluginProperty(dynamic = true)
private List<String> commands;

@Schema(
title = "The `profiles.yml` file content.",
Expand Down Expand Up @@ -266,7 +267,7 @@ public void accept(String line, Boolean isStdErr) {
List<String> 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
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/io/kestra/plugin/dbt/cli/Setup.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ public class Setup extends AbstractExecScript implements RunnableTask<ScriptOutp
)
@NotNull
@NotEmpty
private final Property<String> 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.",
Expand Down Expand Up @@ -213,7 +214,7 @@ public ScriptOutput run(RunContext runContext) throws Exception {
private List<String> virtualEnvCommand(RunContext runContext, Path workingDirectory, List<String> requirements) throws IllegalVariableEvaluationException {
List<String> 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(
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/kestra/plugin/dbt/cli/DbtCLITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 251044b

Please sign in to comment.