Skip to content

Commit

Permalink
Merge pull request #10 from AzBuilder/split-init
Browse files Browse the repository at this point in the history
Separate logic for terraform init
  • Loading branch information
alfespa17 authored Oct 19, 2021
2 parents 6ff14bd + d01c677 commit e2b8fe1
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 15 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-beta1</revision>
<revision>0.5.0-beta.2</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-beta1</revision>
<revision>0.5.0-beta.2</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 @@ -65,12 +65,12 @@ public CompletableFuture<Boolean> show(@NonNull String terraformVersion, @NonNul
new HashMap(),
outputListener,
errorListener,
TerraformCommand.init, TerraformCommand.show);
TerraformCommand.show);
}

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

public CompletableFuture<Boolean> showPlan(@NonNull String terraformVersion, @NonNull File workingDirectory, String terraformBackendConfigFileName, @NonNull Consumer<String> outputListener, @NonNull Consumer<String> errorListener) throws IOException {
Expand All @@ -82,12 +82,29 @@ public CompletableFuture<Boolean> showPlan(@NonNull String terraformVersion, @No
new HashMap(),
outputListener,
errorListener,
TerraformCommand.init, TerraformCommand.showPlan);
TerraformCommand.showPlan);
}

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

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

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

public CompletableFuture<Boolean> plan(@NonNull String terraformVersion, @NonNull File workingDirectory, String terraformBackendConfigFileName, @NonNull Map<String, String> terraformVariables, @NonNull Map<String, String> terraformEnvironmentVariables, @NonNull Consumer<String> outputListener, @NonNull Consumer<String> errorListener) throws IOException {
Expand All @@ -99,12 +116,12 @@ public CompletableFuture<Boolean> plan(@NonNull String terraformVersion, @NonNul
terraformEnvironmentVariables,
outputListener,
errorListener,
TerraformCommand.init, TerraformCommand.plan);
TerraformCommand.plan);
}

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

public CompletableFuture<Boolean> apply(@NonNull String terraformVersion, @NonNull File workingDirectory, String terraformBackendConfigFileName, @NonNull Map<String, String> terraformVariables, @NonNull Map<String, String> terraformEnvironmentVariables, @NonNull Consumer<String> outputListener, @NonNull Consumer<String> errorListener) throws IOException {
Expand All @@ -116,12 +133,12 @@ public CompletableFuture<Boolean> apply(@NonNull String terraformVersion, @NonNu
terraformEnvironmentVariables,
outputListener,
errorListener,
TerraformCommand.init, TerraformCommand.apply);
TerraformCommand.apply);
}

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

public CompletableFuture<Boolean> destroy(@NonNull String terraformVersion, @NonNull File workingDirectory, String terraformBackendConfigFileName, @NonNull Map<String, String> terraformEnvironmentVariables, @NonNull Consumer<String> outputListener, @NonNull Consumer<String> errorListener) throws IOException {
Expand All @@ -133,12 +150,12 @@ public CompletableFuture<Boolean> destroy(@NonNull String terraformVersion, @Non
terraformEnvironmentVariables,
outputListener,
errorListener,
TerraformCommand.init, TerraformCommand.destroy);
TerraformCommand.destroy);
}

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

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 {
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-beta1</revision>
<revision>0.5.0-beta.2</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-beta1</revision>
<revision>0.5.0-beta.2</revision>
<maven.deploy.skip>true</maven.deploy.skip>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public static void main(String[] args) throws Exception {

try (TerraformClient client = TerraformClient.builder().terraformParameters(terraformParameters).environmentVariables(environmentVariables).build()) {

client.init();

System.out.println(client.version().get());
client.setOutputListener(System.out::println);
client.setErrorListener(System.err::println);
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-beta1</revision>
<revision>0.5.0-beta.2</revision>
<maven.deploy.skip>false</maven.deploy.skip>
</properties>

Expand Down

0 comments on commit e2b8fe1

Please sign in to comment.