Skip to content

Commit

Permalink
fix: projectDir should not be used to retrieve the profile
Browse files Browse the repository at this point in the history
Fixes #123
  • Loading branch information
loicmathieu committed Jun 28, 2024
1 parent 950072e commit caa92df
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/io/kestra/plugin/dbt/cli/DbtCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@ public void accept(String line, Boolean isStdErr) {
}
});

Path workingDirectory = projectDir == null ? commands.getWorkingDirectory() : commands.getWorkingDirectory().resolve(projectDir);
Path projectWorkingDirectory = projectDir == null ? commands.getWorkingDirectory() : commands.getWorkingDirectory().resolve(projectDir);

if (profiles != null && !profiles.isEmpty()) {
if (Files.exists(Path.of(".profiles/profiles.yml"))) {
runContext.logger().warn("A 'profiles.yml' file already exist in the task working directory, it will be overridden.");
}

FileUtils.writeStringToFile(
new File(workingDirectory.toString(), "profiles.yml"),
new File(commands.getWorkingDirectory().toString(), "profiles.yml"),
runContext.render(profiles),
StandardCharsets.UTF_8
);
Expand All @@ -219,13 +219,13 @@ public void accept(String line, Boolean isStdErr) {
.withCommands(commandsArgs)
.run();

if (this.parseRunResults && workingDirectory.resolve("target/run_results.json").toFile().exists()) {
URI results = ResultParser.parseRunResult(runContext, workingDirectory.resolve("target/run_results.json").toFile());
if (this.parseRunResults && projectWorkingDirectory.resolve("target/run_results.json").toFile().exists()) {
URI results = ResultParser.parseRunResult(runContext, projectWorkingDirectory.resolve("target/run_results.json").toFile());
run.getOutputFiles().put("run_results.json", results);
}

if (workingDirectory.resolve("target/manifest.json").toFile().exists()) {
URI manifest = ResultParser.parseManifest(runContext, workingDirectory.resolve("target/manifest.json").toFile());
if (projectWorkingDirectory.resolve("target/manifest.json").toFile().exists()) {
URI manifest = ResultParser.parseManifest(runContext, projectWorkingDirectory.resolve("target/manifest.json").toFile());
run.getOutputFiles().put("manifest.json", manifest);
}

Expand Down

0 comments on commit caa92df

Please sign in to comment.