diff --git a/README.md b/README.md
index 11330a0..869d08d 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@ Simply add the following dependency to your project's `pom.xml` will enable you
org.azbuilder.terraform
terraform-client
- 0.0.3
+ 0.0.6
```
@@ -56,16 +56,15 @@ System.out.println(terraformDownloader.downloadTerraformVersion("0.14.9"));
TerraformClient terraformClient = new TerraformClient();
-System.out.println(terraformClient.version().get());
terraformClient.setTerraformVersion("0.15.0");
-
System.out.println(terraformClient.version().get());
-terraformClient.setTerraformVersion("0.14.9");
+terraformClient.setTerraformVersion("0.14.9");
System.out.println(terraformClient.version().get());
-terraformClient.setTerraformVersion("0.14.7");
+terraformClient.setTerraformVersion("0.14.7");
System.out.println(terraformClient.version().get());
+
```
### Spring boot
@@ -76,7 +75,7 @@ Let's still use the terraform file `storage.tf` under `/some/local/path/` folder
org.azbuilder.terraform
terraform-spring-boot-starter
- 0.0.3
+ 0.0.6
```
@@ -104,6 +103,7 @@ public class SpringStarterSampleApp implements CommandLineRunner {
this.terraform.setOutputListener(System.out::println);
this.terraform.setErrorListener(System.err::println);
+ this.terraform.setTerraformVersion("0.15.0");
this.terraform.setWorkingDirectory("/some/local/path/");
this.terraform.plan().get();
this.terraform.apply().get();
diff --git a/terraform-client/pom.xml b/terraform-client/pom.xml
index fac42f4..8e0b3b6 100644
--- a/terraform-client/pom.xml
+++ b/terraform-client/pom.xml
@@ -19,10 +19,11 @@
UTF-8
- 0.0.5
+ 0.0.6
false
4.9.1
2.8.0
+ 3.8.1
@@ -104,6 +105,12 @@
log4j-slf4j-impl
+
+ org.apache.maven
+ maven-artifact
+ ${maven-artifact.version}
+
+
diff --git a/terraform-client/src/main/java/org/azbuilder/terraform/TerraformClient.java b/terraform-client/src/main/java/org/azbuilder/terraform/TerraformClient.java
index 2712900..7a92f7b 100644
--- a/terraform-client/src/main/java/org/azbuilder/terraform/TerraformClient.java
+++ b/terraform-client/src/main/java/org/azbuilder/terraform/TerraformClient.java
@@ -1,6 +1,7 @@
package org.azbuilder.terraform;
import lombok.extern.slf4j.Slf4j;
+import org.apache.maven.artifact.versioning.ComparableVersion;
import java.io.*;
import java.nio.file.*;
@@ -143,6 +144,9 @@ private void checkRunningParameters() {
if (this.getWorkingDirectory() == null) {
throw new IllegalArgumentException("working directory should not be null");
}
+ if (this.terraformVersion == null) {
+ throw new IllegalArgumentException("Terraform version should not be null");
+ }
}
private ProcessLauncher getTerraformLauncher(TerraformCommand command) throws IOException {
@@ -156,7 +160,7 @@ private ProcessLauncher getTerraformLauncher(TerraformCommand command) throws IO
switch (command) {
case init:
- if(getBackendConfig() !=null){
+ if (getBackendConfig() != null) {
launcher.appendCommands("-backend-config=".concat(this.getBackendConfig()));
}
break;
@@ -172,7 +176,12 @@ private ProcessLauncher getTerraformLauncher(TerraformCommand command) throws IO
launcher.appendCommands("-auto-approve");
break;
case destroy:
- launcher.appendCommands("-force");
+ ComparableVersion version0_15_0 = new ComparableVersion("0.15.0"); //https://www.terraform.io/upgrade-guides/0-15.html#other-minor-command-line-behavior-changes
+ ComparableVersion version = new ComparableVersion(this.terraformVersion);
+ if (version.compareTo(version0_15_0) < 0)
+ launcher.appendCommands("-force");
+ else
+ launcher.appendCommands("-auto-approve");
break;
}
launcher.setOutputListener(this.getOutputListener());
diff --git a/terraform-spring-boot-autoconfigure/pom.xml b/terraform-spring-boot-autoconfigure/pom.xml
index bde4b5a..92f7eb9 100644
--- a/terraform-spring-boot-autoconfigure/pom.xml
+++ b/terraform-spring-boot-autoconfigure/pom.xml
@@ -18,7 +18,7 @@
UTF-8
- 0.0.5
+ 0.0.6
false
diff --git a/terraform-spring-boot-samples/pom.xml b/terraform-spring-boot-samples/pom.xml
index 2b64138..fa4c477 100644
--- a/terraform-spring-boot-samples/pom.xml
+++ b/terraform-spring-boot-samples/pom.xml
@@ -18,7 +18,7 @@
UTF-8
- 0.0.5
+ 0.0.6
true
diff --git a/terraform-spring-boot-samples/raw-client-library-sample/src/main/java/org/azbuilder/samples/RawClientLibSampleApp.java b/terraform-spring-boot-samples/raw-client-library-sample/src/main/java/org/azbuilder/samples/RawClientLibSampleApp.java
index e436269..c66954e 100644
--- a/terraform-spring-boot-samples/raw-client-library-sample/src/main/java/org/azbuilder/samples/RawClientLibSampleApp.java
+++ b/terraform-spring-boot-samples/raw-client-library-sample/src/main/java/org/azbuilder/samples/RawClientLibSampleApp.java
@@ -19,9 +19,9 @@ public static void main(String[] args) throws Exception {
TerraformClient terraformClient = new TerraformClient();
- System.out.println(terraformClient.version().get());
terraformClient.setTerraformVersion("0.15.0");
System.out.println(terraformClient.version().get());
+
terraformClient.setTerraformVersion("0.14.9");
System.out.println(terraformClient.version().get());
terraformClient.setTerraformVersion("0.14.7");
diff --git a/terraform-spring-boot-starter/pom.xml b/terraform-spring-boot-starter/pom.xml
index 49863ee..70ac8ac 100644
--- a/terraform-spring-boot-starter/pom.xml
+++ b/terraform-spring-boot-starter/pom.xml
@@ -13,7 +13,7 @@
UTF-8
- 0.0.5
+ 0.0.6
false