Closed alfespa17 closed 1 year ago
Adding varFile parameters in the different methods.
package org.terrakube.terraform; import java.io.File; import java.io.IOException; import java.util.HashMap; import java.util.concurrent.ExecutionException; public final class Main { public static void main(String[] args) { withoutVarFile(); withVarFile(); } private static void withoutVarFile(){ String terraformVersion="1.3.9"; TerraformClient terraformClient = TerraformClient .builder() .jsonOutput(false) .showColor(true) .build(); try { File workingDirectory = new File("/home/user/somepath"); TerraformProcessData terraformProcessData = TerraformProcessData.builder() .terraformVersion(terraformVersion) .workingDirectory(workingDirectory) .build(); terraformClient.init(terraformProcessData, System.out::println, System.err::println).get(); System.out.println("Terraform Plan"); terraformClient.plan(terraformProcessData, System.out::println, System.err::println).get(); System.out.println("Terraform Apply"); terraformClient.apply(terraformProcessData, System.out::println, System.err::println).get(); System.out.println("Terraform PLan Destroy"); terraformClient.planDestroy(terraformProcessData, System.out::println, System.err::println).get(); System.out.println("Terraform Apply to Destroy"); terraformClient.apply(terraformProcessData, System.out::println, System.err::println).get(); } catch (IOException | ExecutionException | InterruptedException exception) { exception.printStackTrace(); } } private static void withVarFile(){ String terraformVersion="1.3.9"; String varFile="testing.tfvars"; TerraformClient terraformClient = TerraformClient .builder() .jsonOutput(false) .showColor(true) .build(); try { File workingDirectory = new File("/home/user/somepath"); TerraformProcessData terraformProcessData = TerraformProcessData.builder() .terraformVersion(terraformVersion) .workingDirectory(workingDirectory) .build(); terraformClient.init(terraformProcessData, System.out::println, System.err::println).get(); terraformProcessData = TerraformProcessData.builder() .terraformVersion(terraformVersion) .workingDirectory(workingDirectory) .varFileName(varFile) .build(); System.out.println("Terraform Plan"); terraformClient.plan(terraformProcessData, System.out::println, System.err::println).get(); System.out.println("Terraform Apply"); terraformClient.apply(terraformProcessData, System.out::println, System.err::println).get(); System.out.println("Terraform PLan Destroy"); terraformClient.planDestroy(terraformProcessData,System.out::println, System.err::println).get(); System.out.println("Terraform Apply to Destroy"); terraformClient.apply(terraformProcessData, System.out::println, System.err::println).get(); } catch (IOException | ExecutionException | InterruptedException exception) { exception.printStackTrace(); } } }
Fixes #32
Kudos, SonarCloud Quality Gate passed!
0 Bugs 0 Vulnerabilities 0 Security Hotspots 1 Code Smell
0.0% Coverage 0.0% Duplication
Adding varFile parameters in the different methods.
Fixes #32