Skip to content

Commit

Permalink
remove workspace env var and not set it to an empty string. (#388)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bjhaid authored May 13, 2023
1 parent 1b77141 commit 8d60e83
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 1 addition & 1 deletion tfexec/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion tfexec/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func defaultEnv() []string {
"TF_LOG_CORE=",
"TF_LOG_PATH=",
"TF_LOG_PROVIDER=",
"TF_WORKSPACE=",
}
}

Expand Down

0 comments on commit 8d60e83

Please sign in to comment.