Skip to content

Commit

Permalink
Add support to use state pull command (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
alfespa17 authored Mar 1, 2024
1 parent 2922c00 commit b9c76a3
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 8 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.12.0</revision>
<revision>0.13.0</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 @@ -23,7 +23,7 @@
<maven-source-plugin.version>3.3.0</maven-source-plugin.version>
<maven-javadoc-plugin.version>3.6.2</maven-javadoc-plugin.version>
<maven-gpg-plugin.version>3.1.0</maven-gpg-plugin.version>
<revision>0.12.0</revision>
<revision>0.13.0</revision>
<maven.deploy.skip>false</maven.deploy.skip>
<commons-io.version>2.15.0</commons-io.version>
<maven-artifact.version>3.9.5</maven-artifact.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class TerraformClient implements AutoCloseable {
private static final String TERRAFORM_PARAM_DISABLE_USER_INPUT = "-input=false";
private static final String TERRAFORM_PLAN_REFRESH_FALSE="-refresh=false";
private static final String TERRAFORM_PLAN_REFRESH_ONLY="-refresh-only";
private static final String TF_STATE_PULL="pull";

private final ExecutorService executor = Executors.newWorkStealingPool();

Expand Down Expand Up @@ -118,6 +119,14 @@ public CompletableFuture<Boolean> plan(TerraformProcessData terraformProcessData
TerraformCommand.plan);
}

public CompletableFuture<Boolean> statePull(TerraformProcessData terraformProcessData, @NonNull Consumer<String> outputListener, @NonNull Consumer<String> errorListener) throws IOException {
return this.run(
terraformProcessData,
outputListener,
errorListener,
TerraformCommand.statePull);
}

public CompletableFuture<Boolean> planDestroy(TerraformProcessData terraformProcessData, @NonNull Consumer<String> outputListener, @NonNull Consumer<String> errorListener) throws IOException {
return this.run(
terraformProcessData,
Expand Down Expand Up @@ -365,6 +374,9 @@ private ProcessLauncher getTerraformLauncher(TerraformProcessData terraformProce
case showPlan:
launcher.appendCommands(TERRAFORM_PARAM_OUTPUT_PLAN_FILE);
break;
case statePull:
log.info("tf state pull command");
launcher.appendCommands(TF_STATE_PULL);
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public enum TerraformCommand {
version("version"),
show("show"),
showPlan("show"),
output("output");
output("output"),
statePull("state");

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 @@ -22,7 +22,7 @@
<maven-source-plugin.version>3.3.0</maven-source-plugin.version>
<maven-javadoc-plugin.version>3.6.2</maven-javadoc-plugin.version>
<maven-gpg-plugin.version>3.1.0</maven-gpg-plugin.version>
<revision>0.12.0</revision>
<revision>0.13.0</revision>
<maven.deploy.skip>false</maven.deploy.skip>
<lombok.version>1.18.30</lombok.version>
<maven.compiler.source>11</maven.compiler.source>
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.12.0</revision>
<revision>0.13.0</revision>
<maven.deploy.skip>true</maven.deploy.skip>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.deploy.skip>true</maven.deploy.skip>
<revision>0.12.0</revision>
<revision>0.13.0</revision>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.deploy.skip>true</maven.deploy.skip>
<revision>0.12.0</revision>
<revision>0.13.0</revision>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</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 @@ -17,7 +17,7 @@
<maven-source-plugin.version>3.3.0</maven-source-plugin.version>
<maven-javadoc-plugin.version>3.6.2</maven-javadoc-plugin.version>
<maven-gpg-plugin.version>3.1.0</maven-gpg-plugin.version>
<revision>0.12.0</revision>
<revision>0.13.0</revision>
<maven.deploy.skip>false</maven.deploy.skip>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
Expand Down

0 comments on commit b9c76a3

Please sign in to comment.