From e4ab455ea105145661c84e492535ccfd4b5a53eb Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Fri, 26 May 2023 11:05:30 +0000 Subject: [PATCH] Don't pass synthesized TMPDIR if not already set (#409) ## Changes On Unix systems, the default of `/tmp` always works. No need to synthesize a path for it. The custom TMPDIR was causing issues when used from GitHub Actions runners. ## Tests Confirmed manually this fixes the issue on GitHub Actions runners. --- bundle/deploy/terraform/init.go | 7 +------ bundle/deploy/terraform/init_test.go | 10 +++------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/bundle/deploy/terraform/init.go b/bundle/deploy/terraform/init.go index 18a8de22..14a5d2c0 100644 --- a/bundle/deploy/terraform/init.go +++ b/bundle/deploy/terraform/init.go @@ -95,14 +95,9 @@ func setTempDirEnvVars(env map[string]string, b *bundle.Bundle) error { env["TMP"] = tmpDir } default: + // If TMPDIR is not set, we let the process fall back to its default value. if v, ok := os.LookupEnv("TMPDIR"); ok { env["TMPDIR"] = v - } else { - tmpDir, err := b.CacheDir("tmp") - if err != nil { - return err - } - env["TMPDIR"] = tmpDir } } return nil diff --git a/bundle/deploy/terraform/init_test.go b/bundle/deploy/terraform/init_test.go index fdc6c893..872d55c7 100644 --- a/bundle/deploy/terraform/init_test.go +++ b/bundle/deploy/terraform/init_test.go @@ -69,7 +69,7 @@ func TestSetTempDirEnvVarsForUnixWithTmpDirSet(t *testing.T) { err := setTempDirEnvVars(env, b) require.NoError(t, err) - // assert that we pass through env var value + // Assert that we pass through TMPDIR. assert.Equal(t, map[string]string{ "TMPDIR": "/foo/bar", }, env) @@ -97,12 +97,8 @@ func TestSetTempDirEnvVarsForUnixWithTmpDirNotSet(t *testing.T) { err := setTempDirEnvVars(env, b) require.NoError(t, err) - // assert tmp dir is set to b.CacheDir("tmp") - tmpDir, err := b.CacheDir("tmp") - require.NoError(t, err) - assert.Equal(t, map[string]string{ - "TMPDIR": tmpDir, - }, env) + // Assert that we don't pass through TMPDIR. + assert.Equal(t, map[string]string{}, env) } func TestSetTempDirEnvVarsForWindowWithAllTmpDirEnvVarsSet(t *testing.T) {