Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class TerraformClient implements AutoCloseable {
private File workingDirectory;
private boolean inheritIO;
private Consumer<String> outputListener, errorListener;
private Map<String, String> extraEnvVars = Collections.emptyMap();

public TerraformClient() {
this(new TerraformOptions());
Expand Down Expand Up @@ -68,6 +69,10 @@ public void setInheritIO(boolean inheritIO) {
this.inheritIO = inheritIO;
}

public void setExtraEnvVars(Map<String, String> envVars) {
this.extraEnvVars = envVars;
}

public CompletableFuture<String> version() throws IOException {
ProcessLauncher launcher = this.getTerraformLauncher(VERSION_COMMAND);
StringBuilder version = new StringBuilder();
Expand Down Expand Up @@ -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());
Expand Down