Skip to content

Commit

Permalink
Merge pull request #11 from AzBuilder/terraform-ouput
Browse files Browse the repository at this point in the history
Support Terraform Ouput and Show in json
  • Loading branch information
alfespa17 authored Oct 22, 2021
2 parents e2b8fe1 + 82efdaa commit 4bd2c32
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>0.5.0-beta.2</revision>
<revision>0.5.0-beta.3</revision>
<sonar.organization>azbuilder</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<maven.deploy.skip>true</maven.deploy.skip>
Expand Down
2 changes: 1 addition & 1 deletion terraform-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>0.5.0-beta.2</revision>
<revision>0.5.0-beta.3</revision>
<maven.deploy.skip>false</maven.deploy.skip>
<okhttp.version>4.9.1</okhttp.version>
<commons-io.version>2.8.0</commons-io.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.function.*;
import java.util.stream.*;

final class ProcessLauncher {
public final class ProcessLauncher {
private Process process;
private ProcessBuilder builder;
private Consumer<String> outputListener, errorListener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,23 @@ public CompletableFuture<Boolean> destroy() throws IOException {
return this.run(TerraformCommand.destroy);
}

public CompletableFuture<Boolean> output(@NonNull String terraformVersion, @NonNull File workingDirectory, @NonNull Consumer<String> outputListener, @NonNull Consumer<String> errorListener) throws IOException {
return this.run(
terraformVersion,
workingDirectory,
null,
new HashMap<>(),
new HashMap<>(),
outputListener,
errorListener,
TerraformCommand.output);
}

public CompletableFuture<Boolean> output() throws IOException {
this.checkRunningParameters();
return this.run(TerraformCommand.output);
}

private CompletableFuture<Boolean> run(String terraformVersion, File workingDirectory, String terraformBackendConfigFileName, Map<String, String> terraformVariables, Map<String, String> terraformEnvironmentVariables, Consumer<String> outputListener, Consumer<String> errorListener, TerraformCommand... commands) throws IOException {
assert commands.length > 0;
ProcessLauncher[] launchers = new ProcessLauncher[commands.length];
Expand Down Expand Up @@ -254,6 +271,10 @@ private ProcessLauncher getTerraformLauncher(String terraformVersion, File worki
else
launcher.appendCommands(TERRAFORM_PARAM_AUTO_APPROVED);
break;
case show:
case output:
launcher.appendCommands(TERRAFORM_PARAM_JSON);
break;
case showPlan:
launcher.appendCommands(TERRAFORM_PARAM_OUTPUT_PLAN_FILE);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public enum TerraformCommand {
destroy("destroy"),
version("version"),
show("show"),
showPlan("show");
showPlan("show"),
output("output");

private String label;

Expand Down
2 changes: 1 addition & 1 deletion terraform-spring-boot-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>0.5.0-beta.2</revision>
<revision>0.5.0-beta.3</revision>
<maven.deploy.skip>false</maven.deploy.skip>
<lombok.version>1.18.20</lombok.version>
</properties>
Expand Down
2 changes: 1 addition & 1 deletion terraform-spring-boot-samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>0.5.0-beta.2</revision>
<revision>0.5.0-beta.3</revision>
<maven.deploy.skip>true</maven.deploy.skip>
</properties>

Expand Down
2 changes: 1 addition & 1 deletion terraform-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>0.5.0-beta.2</revision>
<revision>0.5.0-beta.3</revision>
<maven.deploy.skip>false</maven.deploy.skip>
</properties>

Expand Down

0 comments on commit 4bd2c32

Please sign in to comment.