diff --git a/terraform-client/src/main/java/com/microsoft/terraform/TerraformClient.java b/terraform-client/src/main/java/com/microsoft/terraform/TerraformClient.java index 96d59d0..e8f2870 100644 --- a/terraform-client/src/main/java/com/microsoft/terraform/TerraformClient.java +++ b/terraform-client/src/main/java/com/microsoft/terraform/TerraformClient.java @@ -22,6 +22,7 @@ public class TerraformClient implements AutoCloseable { private File workingDirectory; private boolean inheritIO; private Consumer outputListener, errorListener; + private Map extraEnvVars = Collections.emptyMap(); public TerraformClient() { this(new TerraformOptions()); @@ -68,6 +69,10 @@ public void setInheritIO(boolean inheritIO) { this.inheritIO = inheritIO; } + public void setExtraEnvVars(Map envVars) { + this.extraEnvVars = envVars; + } + public CompletableFuture version() throws IOException { ProcessLauncher launcher = this.getTerraformLauncher(VERSION_COMMAND); StringBuilder version = new StringBuilder(); @@ -130,6 +135,7 @@ private ProcessLauncher getTerraformLauncher(String command) throws IOException launcher.setEnvironmentVariable(CLIENT_ID_ENV_NAME, this.options.getArmClientId()); launcher.setEnvironmentVariable(SECRET_ENV_NAME, this.options.getArmClientSecret()); launcher.setEnvironmentVariable(TENANT_ID_ENV_NAME, this.options.getArmTenantId()); + extraEnvVars.forEach(launcher::setEnvironmentVariable); launcher.appendCommands(NON_INTERACTIVE_COMMAND_MAP.get(command)); launcher.setOutputListener(this.getOutputListener()); launcher.setErrorListener(this.getErrorListener());