Source:
private CommandStatus runCommand(final Config params, final CommandContext commandContext) throws IOException, InterruptedException, TemplateException { final Path tempDir = workspace.createTempDir(String.format("digdag-embulk-%d-", request.getTaskId())); final Path workingDirectory = workspace.getPath(); final Path embulkYmlPath = tempDir.resolve("load.yml"); if (params.has("_command")) { String configData = params.get("_command", String.class); String data = workspace.templateFile(templateEngine, configData, UTF_8, params); ObjectNode embulkConfig; try { embulkConfig = new YamlLoader().loadString(data); } catch (RuntimeException | IOException ex) { Throwables.propagateIfInstanceOf(ex, ConfigException.class); throw new ConfigException("Failed to parse yaml file", ex); } Files.write(workingDirectory.relativize(embulkYmlPath), mapper.writeValueAsBytes(resolveSecrets(embulkConfig, context.getSecrets()))); } else { final Config embulkConfig = params.getNested("config"); try (final YAMLGenerator out = yaml.createGenerator(Files.newOutputStream(embulkYmlPath), JsonEncoding.UTF8)) { mapper.writeValue(out, embulkConfig); } } final List<String> cmdline = ImmutableList.of("embulk", "run", workingDirectory.relativize(embulkYmlPath).toString()); final Map<String, String> environments = Maps.newHashMap(); environments.putAll(System.getenv()); CommandOperators.collectEnvironmentVariables(environments, context.getPrivilegedVariables()); final CommandRequest commandRequest = buildCommandRequest(commandContext, workingDirectory, tempDir, environments, cmdline); return exec.run(commandContext, commandRequest); }

Target:
private CommandStatus runCommand(final Config params, final CommandContext commandContext) throws IOException, InterruptedException, TemplateException { final Path tempDir = workspace.createTempDir(String.format("digdag-embulk-%d-", request.getTaskId())); final Path workingDirectory = workspace.getPath(); final Path embulkYmlPath = tempDir.resolve("load.yml"); if (params.has("_command")) { String configData = params.get("_command", String.class); String data = workspace.templateFile(templateEngine, configData, UTF_8, params); ObjectNode embulkConfig; try { embulkConfig = new YamlLoader().loadString(data); } catch (RuntimeException | IOException ex) { Throwables.propagateIfInstanceOf(ex, ConfigException.class); throw new ConfigException("Failed to parse yaml file", ex); } Files.write(embulkYmlPath, mapper.writeValueAsBytes(resolveSecrets(embulkConfig, context.getSecrets()))); } else { final Config embulkConfig = params.getNested("config"); try (final YAMLGenerator out = yaml.createGenerator(Files.newOutputStream(embulkYmlPath), JsonEncoding.UTF8)) { mapper.writeValue(out, embulkConfig); } } final List<String> cmdline = ImmutableList.of("embulk", "run", workingDirectory.relativize(embulkYmlPath).toString()); final Map<String, String> environments = Maps.newHashMap(); environments.putAll(System.getenv()); CommandOperators.collectEnvironmentVariables(environments, context.getPrivilegedVariables()); final CommandRequest commandRequest = buildCommandRequest(commandContext, workingDirectory, tempDir, environments, cmdline); return exec.run(commandContext, commandRequest); }