0
0
mirror of https://github.com/thegeeklab/wp-opentofu.git synced 2024-11-22 00:30:40 +00:00

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.
This commit is contained in:
Caio Quirino da Silva 2019-07-22 15:16:20 +02:00 committed by GitHub
parent eb0aab1bbc
commit 13a6625b51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -382,7 +382,10 @@ func createEnvironmentVariables(config Config) []string {
func createTerraformCommand(config Config, args ...string) *exec.Cmd {
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
}
func getTfoutPath(config Config) string {