Skip to content

Commit

Permalink
Prevent unintended usage of TF_WORKSPACE
Browse files Browse the repository at this point in the history
  • Loading branch information
paultyng committed Sep 4, 2020
1 parent 01a7e95 commit 7253a2d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tfexec/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const (
logPathEnvVar = "TF_LOG_PATH"
reattachEnvVar = "TF_REATTACH_PROVIDERS"
appendUserAgentEnvVar = "TF_APPEND_USER_AGENT"
workspaceEnvVar = "TF_WORKSPACE"

varEnvVarPrefix = "TF_VAR_"
)
Expand All @@ -33,6 +34,7 @@ var prohibitedEnvVars = []string{
logEnvVar,
reattachEnvVar,
appendUserAgentEnvVar,
workspaceEnvVar,
}

func envMap(environ []string) map[string]string {
Expand Down Expand Up @@ -105,6 +107,9 @@ func (tf *Terraform) buildEnv(mergeEnv map[string]string) []string {
// constant automation override env vars
env[automationEnvVar] = "1"

// force usage of workspace methods for switching
env[workspaceEnvVar] = ""

return envSlice(env)
}

Expand Down

0 comments on commit 7253a2d

Please sign in to comment.