refactor: introduce render in commands wrapper for property string (#7430)

This commit is contained in:
Mathieu Gabelle
2025-02-17 10:44:54 +01:00
committed by GitHub
parent 410cf0e389
commit e061a3617c

View File

@@ -32,6 +32,8 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import static io.kestra.core.utils.Rethrow.throwFunction;
@AllArgsConstructor
@Getter
public class CommandsWrapper implements TaskCommands {
@@ -265,6 +267,17 @@ public class CommandsWrapper implements TaskCommands {
);
}
public String render(RunContext runContext, Property<String> command) throws IllegalVariableEvaluationException, IOException {
TaskRunner<?> taskRunner = this.getTaskRunner();
if (command == null) {
return null;
}
return runContext.render(command).as(String.class, taskRunner.additionalVars(runContext, this))
.map(throwFunction(c -> ScriptService.replaceInternalStorage(runContext, c, taskRunner instanceof RemoteRunnerInterface)))
.orElse(null);
}
public List<String> renderCommands(RunContext runContext, Property<List<String>> commands) throws IllegalVariableEvaluationException, IOException {
TaskRunner<?> taskRunner = this.getTaskRunner();
return ScriptService.replaceInternalStorage(