Browse Source

Override environment variables only when changed

When using Command.Env, if you send nil as a value, it will use all of the environment variables from os.Environ() when executing the command.
In order to not break the current tests and be coherent with the current relationship, we are appending the created environment variables with os.Environ() only when we have at least 1 environment variable to override.
pull/94/head
Caio Quirino da Silva 6 years ago
committed by GitHub
parent
commit
13a6625b51
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      plugin.go

5
plugin.go

@ -382,7 +382,10 @@ func createEnvironmentVariables(config Config) []string {
func createTerraformCommand(config Config, args ...string) *exec.Cmd { func createTerraformCommand(config Config, args ...string) *exec.Cmd {
command := exec.Command("terraform", args...) command := exec.Command("terraform", args...)
command.Env = append(command.Env, createEnvironmentVariables(config)...) environmentVariables := createEnvironmentVariables(config)
if len(environmentVariables) > 0 {
command.Env = append(os.Environ(), environmentVariables...)
}
return command return command
} }
func getTfoutPath(config Config) string { func getTfoutPath(config Config) string {

Loading…
Cancel
Save