Skip to content

Commit 8d60e83

Browse files
authored
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.
1 parent 1b77141 commit 8d60e83

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

tfexec/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func (tf *Terraform) buildEnv(mergeEnv map[string]string) []string {
169169
env[automationEnvVar] = "1"
170170

171171
// force usage of workspace methods for switching
172-
env[workspaceEnvVar] = ""
172+
delete(env, workspaceEnvVar)
173173

174174
if tf.disablePluginTLS {
175175
env[disablePluginTLSEnvVar] = "1"

tfexec/cmd_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ func defaultEnv() []string {
4646
"TF_LOG_CORE=",
4747
"TF_LOG_PATH=",
4848
"TF_LOG_PROVIDER=",
49-
"TF_WORKSPACE=",
5049
}
5150
}
5251

0 commit comments

Comments
 (0)