diff --git a/src/main/java/io/kestra/plugin/soda/AbstractSoda.java b/src/main/java/io/kestra/plugin/soda/AbstractSoda.java index 8300e0f..7dac424 100644 --- a/src/main/java/io/kestra/plugin/soda/AbstractSoda.java +++ b/src/main/java/io/kestra/plugin/soda/AbstractSoda.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import io.kestra.core.exceptions.IllegalVariableEvaluationException; import io.kestra.core.models.annotations.PluginProperty; +import io.kestra.core.models.property.Property; import io.kestra.core.models.tasks.Task; import io.kestra.core.models.tasks.runners.PluginUtilsService; import io.kestra.core.models.tasks.runners.ScriptService; @@ -98,18 +99,13 @@ public void setDockerOptions(DockerOptions dockerOptions) { title = "List of python dependencies to add to the python execution process", description = "Python dependencies list to setup in the virtualenv, in the same format than requirements.txt. It must at least provides dbt." ) - @PluginProperty(dynamic = true) @NotNull - protected List requirements; + protected Property> requirements; @Schema( title = "Additional environment variables for the current process." ) - @PluginProperty( - additionalProperties = String.class, - dynamic = true - ) - protected Map env; + protected Property> env; @Schema( title = "The configuration file" @@ -128,8 +124,9 @@ protected Map finalInputFiles(RunContext runContext, Path workin } public CommandsWrapper start(RunContext runContext) throws Exception { + var env = runContext.render(this.getEnv()).asMap(String.class, String.class); CommandsWrapper commandsWrapper = new CommandsWrapper(runContext) - .withEnv(this.getEnv()) + .withEnv(env.isEmpty() ? new HashMap<>() : env) .withRunnerType(this.getRunner()) .withTaskRunner(this.taskRunner) .withContainerImage(this.getContainerImage()) @@ -139,7 +136,7 @@ public CommandsWrapper start(RunContext runContext) throws Exception { List commands = new ArrayList<>(); if (this.requirements != null) { - commands.add(this.virtualEnvCommand(runContext, workingDirectory, this.requirements)); + commands.add(this.virtualEnvCommand(runContext, workingDirectory, runContext.render(this.requirements).asList(String.class))); commands.add("./bin/python {{workingDir}}/main.py"); } else { commands.add("python {{workingDir}}/main.py"); diff --git a/src/main/java/io/kestra/plugin/soda/Scan.java b/src/main/java/io/kestra/plugin/soda/Scan.java index dfb1aa0..a3450c8 100644 --- a/src/main/java/io/kestra/plugin/soda/Scan.java +++ b/src/main/java/io/kestra/plugin/soda/Scan.java @@ -6,6 +6,7 @@ import io.kestra.core.models.annotations.PluginProperty; import io.kestra.core.models.executions.metrics.Counter; import io.kestra.core.models.flows.State; +import io.kestra.core.models.property.Property; import io.kestra.core.models.tasks.RunnableTask; import io.kestra.core.runners.RunContext; import io.kestra.core.serializers.JacksonMapper; @@ -39,7 +40,7 @@ code = """ id: soda_scan namespacae: company.team - + tasks: - id: scan type: io.kestra.plugin.soda.Scan @@ -80,15 +81,13 @@ public class Scan extends AbstractSoda implements RunnableTask { @Schema( title = "The variables to pass" ) - @PluginProperty(dynamic = true) - Map variables; + Property> variables; @Schema( title = "Whether to enable verbose logging" ) - @PluginProperty @Builder.Default - Boolean verbose = false; + Property verbose = Property.of(false); @Override protected Map finalInputFiles(RunContext runContext, Path workingDirectory) throws IOException, IllegalVariableEvaluationException { @@ -111,12 +110,12 @@ protected Map finalInputFiles(RunContext runContext, Path workin "scan.add_sodacl_yaml_file(\"{{workingDir}}/checks.yml\")\n" + "\n"; - if (verbose) { + if (runContext.render(verbose).as(Boolean.class).orElseThrow()) { main += "scan.set_verbose()"; } if (variables != null) { - main += "scan.add_variables(" + JacksonMapper.ofJson().writeValueAsString(runContext.render(variables)) + ")"; + main += "scan.add_variables(" + JacksonMapper.ofJson().writeValueAsString(runContext.render(variables).asMap(String.class, Object.class)) + ")"; } main += "\n" + diff --git a/src/test/java/io/kestra/plugin/soda/ScanTest.java b/src/test/java/io/kestra/plugin/soda/ScanTest.java index 3158b76..4ea54c2 100644 --- a/src/test/java/io/kestra/plugin/soda/ScanTest.java +++ b/src/test/java/io/kestra/plugin/soda/ScanTest.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.google.common.collect.ImmutableMap; import io.kestra.core.models.flows.State; +import io.kestra.core.models.property.Property; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.serializers.JacksonMapper; @@ -118,7 +119,7 @@ void error() throws Exception { " - row_count > 0", TYPE_REFERENCE )) - .requirements(List.of("soda-core-bigquery")) + .requirements(Property.of(List.of("soda-core-bigquery"))) .build(); RunContext runContext = TestsUtils.mockRunContext(runContextFactory, task, ImmutableMap.of());