From 8d60e83dba7f61735aaa0ce32d56324dde51ac42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=80b=C3=A9j=C3=ADd=C3=A9=20=C3=80yod=C3=A9l=C3=A9?= Date: Sat, 13 May 2023 14:24:16 -0500 Subject: [PATCH] remove workspace env var and not set it to an empty string. (#388) Setting the environment variable to an empty string confuses the terraform binary as seen below: ``` TF_WORKSPACE= terraform init -no-color -input=false -get=false -upgrade=false -backend=false Error: Terraform Cloud returned an unexpected error invalid value for workspace ``` With this patch the `TF_WORKSPACE` will not exist and avoids the above problem. --- tfexec/cmd.go | 2 +- tfexec/cmd_test.go | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tfexec/cmd.go b/tfexec/cmd.go index 083dc4d5..5e160324 100644 --- a/tfexec/cmd.go +++ b/tfexec/cmd.go @@ -169,7 +169,7 @@ func (tf *Terraform) buildEnv(mergeEnv map[string]string) []string { env[automationEnvVar] = "1" // force usage of workspace methods for switching - env[workspaceEnvVar] = "" + delete(env, workspaceEnvVar) if tf.disablePluginTLS { env[disablePluginTLSEnvVar] = "1" diff --git a/tfexec/cmd_test.go b/tfexec/cmd_test.go index 5aa6fae6..c86dae30 100644 --- a/tfexec/cmd_test.go +++ b/tfexec/cmd_test.go @@ -46,7 +46,6 @@ func defaultEnv() []string { "TF_LOG_CORE=", "TF_LOG_PATH=", "TF_LOG_PROVIDER=", - "TF_WORKSPACE=", } }