Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helper/resource: Set CHECKPOINT_DISABLE environment variable outside terraform-exec #937

Merged
merged 1 commit into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .changelog/pending.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
helper/resource: Prevented regression since 2.13.0 with the removal of environment variables, including `TF_VAR_*`, when calling Terraform CLI commands
```
8 changes: 8 additions & 0 deletions helper/resource/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ func runProviderCommand(ctx context.Context, t testing.T, f func() error, wd *pl
// plugins.
os.Setenv("PLUGIN_PROTOCOL_VERSIONS", "5")

// Acceptance testing does not need to call checkpoint as the output
// is not accessible, nor desirable if explicitly using
// TF_ACC_TERRAFORM_PATH or TF_ACC_TERRAFORM_VERSION environment variables.
//
// Avoid calling (tfexec.Terraform).SetEnv() as it will stop copying
// os.Environ() and prevents TF_VAR_ environment variable usage.
os.Setenv("CHECKPOINT_DISABLE", "1")

// Terraform 0.12.X and 0.13.X+ treat namespaceless providers
// differently in terms of what namespace they default to. So we're
// going to set both variations, as we don't know which version of
Expand Down
3 changes: 0 additions & 3 deletions internal/plugintest/environment_variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ package plugintest

// Environment variables
const (
// Disables checkpoint.hashicorp.com calls in Terraform CLI.
EnvCheckpointDisable = "CHECKPOINT_DISABLE"

// Environment variable with acceptance testing temporary directory for
// testing files and Terraform CLI installation, if installation is
// required. By default, the operating system temporary directory is used.
Expand Down
8 changes: 0 additions & 8 deletions internal/plugintest/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,6 @@ func (h *Helper) NewWorkingDir(ctx context.Context) (*WorkingDir, error) {
return nil, fmt.Errorf("unable to create terraform-exec instance: %w", err)
}

err = tf.SetEnv(map[string]string{
EnvCheckpointDisable: "1",
})

if err != nil {
return nil, fmt.Errorf("unable to set terraform-exec environment variables: %w", err)
}

return &WorkingDir{
h: h,
tf: tf,
Expand Down