mirror of https://github.com/databricks/cli.git
Include $PATH in set of environment variables to pass along. (#736)
## Changes This is necessary to ensure that our Terraform provider can use the same auxiliary programs (e.g. `az`, or `gcloud`) as the CLI. ## Tests Unit test and manual verification.
This commit is contained in:
parent
9194418ac1
commit
fabe8e88b8
|
@ -78,6 +78,14 @@ func inheritEnvVars(env map[string]string) error {
|
||||||
env["HOME"] = home
|
env["HOME"] = home
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Include $PATH in set of environment variables to pass along.
|
||||||
|
// This is necessary to ensure that our Terraform provider can use the
|
||||||
|
// same auxiliary programs (e.g. `az`, or `gcloud`) as the CLI.
|
||||||
|
path, ok := os.LookupEnv("PATH")
|
||||||
|
if ok {
|
||||||
|
env["PATH"] = path
|
||||||
|
}
|
||||||
|
|
||||||
// Include $TF_CLI_CONFIG_FILE to override terraform provider in development.
|
// Include $TF_CLI_CONFIG_FILE to override terraform provider in development.
|
||||||
configFile, ok := os.LookupEnv("TF_CLI_CONFIG_FILE")
|
configFile, ok := os.LookupEnv("TF_CLI_CONFIG_FILE")
|
||||||
if ok {
|
if ok {
|
||||||
|
|
|
@ -277,6 +277,7 @@ func TestInheritEnvVars(t *testing.T) {
|
||||||
env := map[string]string{}
|
env := map[string]string{}
|
||||||
|
|
||||||
t.Setenv("HOME", "/home/testuser")
|
t.Setenv("HOME", "/home/testuser")
|
||||||
|
t.Setenv("PATH", "/foo:/bar")
|
||||||
t.Setenv("TF_CLI_CONFIG_FILE", "/tmp/config.tfrc")
|
t.Setenv("TF_CLI_CONFIG_FILE", "/tmp/config.tfrc")
|
||||||
|
|
||||||
err := inheritEnvVars(env)
|
err := inheritEnvVars(env)
|
||||||
|
@ -285,6 +286,7 @@ func TestInheritEnvVars(t *testing.T) {
|
||||||
|
|
||||||
require.Equal(t, map[string]string{
|
require.Equal(t, map[string]string{
|
||||||
"HOME": "/home/testuser",
|
"HOME": "/home/testuser",
|
||||||
|
"PATH": "/foo:/bar",
|
||||||
"TF_CLI_CONFIG_FILE": "/tmp/config.tfrc",
|
"TF_CLI_CONFIG_FILE": "/tmp/config.tfrc",
|
||||||
}, env)
|
}, env)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue