use of io.kestra.core.repositories.LocalFlowRepositoryLoader in project kestra by kestra-io.
the class FlowTestCommand method call.
@Override
public Integer call() throws Exception {
super.call();
MemoryRunner runner = applicationContext.getBean(MemoryRunner.class);
LocalFlowRepositoryLoader repositoryLoader = applicationContext.getBean(LocalFlowRepositoryLoader.class);
FlowRepositoryInterface flowRepository = applicationContext.getBean(FlowRepositoryInterface.class);
RunnerUtils runnerUtils = applicationContext.getBean(RunnerUtils.class);
Map<String, String> inputs = new HashMap<>();
for (int i = 0; i < this.inputs.size(); i = i + 2) {
if (this.inputs.size() <= i + 1) {
throw new CommandLine.ParameterException(this.spec.commandLine(), "Invalid key pair value for inputs");
}
inputs.put(this.inputs.get(i), this.inputs.get(i + 1));
}
try {
runner.run();
repositoryLoader.load(file.toFile());
List<Flow> all = flowRepository.findAll();
if (all.size() != 1) {
throw new IllegalArgumentException("Too many flow found, need 1, found " + all.size());
}
runnerUtils.runOne(all.get(0), (flow, execution) -> runnerUtils.typedInputs(flow, execution, inputs), Duration.ofHours(1));
runner.close();
} catch (MissingRequiredInput e) {
throw new CommandLine.ParameterException(this.spec.commandLine(), e.getMessage());
} catch (IOException | TimeoutException e) {
throw new IllegalStateException(e);
} finally {
applicationContext.getProperty("kestra.storage.local.base-path", Path.class).ifPresent(path -> {
try {
FileUtils.deleteDirectory(path.toFile());
} catch (IOException ignored) {
}
});
}
return 0;
}
use of io.kestra.core.repositories.LocalFlowRepositoryLoader in project kestra by kestra-io.
the class StandAloneCommand method call.
@Override
public Integer call() throws Exception {
super.call();
if (flowPath != null) {
try {
LocalFlowRepositoryLoader localFlowRepositoryLoader = applicationContext.getBean(LocalFlowRepositoryLoader.class);
localFlowRepositoryLoader.load(this.flowPath);
} catch (IOException e) {
throw new CommandLine.ParameterException(this.spec.commandLine(), "Invalid flow path", e);
}
}
StandAloneRunner standAloneRunner = applicationContext.getBean(StandAloneRunner.class);
standAloneRunner.run();
this.shutdownHook(standAloneRunner::close);
Await.until(() -> !this.applicationContext.isRunning());
return 0;
}
Aggregations