Skip to content

Commit 497d9f4

Browse files
authored
Merge pull request #110 from cloudfoundry/remove-use-isolated-env
Remove `UseIsolatedEnv` from `system.Command`
2 parents 82e8451 + 4adbdc9 commit 497d9f4

File tree

3 files changed

+4
-33
lines changed

3 files changed

+4
-33
lines changed

system/cmd_runner_interface.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ import (
66
)
77

88
type Command struct {
9-
Name string
10-
Args []string
11-
Env map[string]string
12-
UseIsolatedEnv bool
9+
Name string
10+
Args []string
11+
Env map[string]string
1312

1413
WorkingDir string
1514

system/exec_cmd_runner.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package system
33
import (
44
"os"
55
"os/exec"
6-
"runtime"
76
"strings"
87

98
boshlog "github.com/cloudfoundry/bosh-utils/logger"
@@ -80,15 +79,7 @@ func (r execCmdRunner) buildComplexCommand(cmd Command) *exec.Cmd {
8079

8180
execCmd.Dir = cmd.WorkingDir
8281

83-
var env []string
84-
if !cmd.UseIsolatedEnv {
85-
env = os.Environ()
86-
}
87-
if cmd.UseIsolatedEnv && runtime.GOOS == "windows" {
88-
panic("UseIsolatedEnv is not supported on Windows")
89-
}
90-
91-
execCmd.Env = mergeEnv(env, cmd.Env)
82+
execCmd.Env = mergeEnv(os.Environ(), cmd.Env)
9283

9384
return execCmd
9485
}

system/exec_cmd_runner_test.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ var _ = Describe("execCmdRunner", func() {
130130

131131
It("run complex command with env", func() {
132132
cmd := osSpecificCommand("env")
133-
cmd.UseIsolatedEnv = false
134133
stdout, stderr, status, err := runner.RunComplexCommand(cmd)
135134
Expect(err).ToNot(HaveOccurred())
136135

@@ -141,23 +140,6 @@ var _ = Describe("execCmdRunner", func() {
141140
Expect(status).To(Equal(0))
142141
})
143142

144-
It("runs complex command with specific env", func() {
145-
cmd := osSpecificCommand("env")
146-
cmd.UseIsolatedEnv = true
147-
if runtime.GOOS == "windows" {
148-
Expect(func() { runner.RunComplexCommand(cmd) }).To(Panic()) //nolint:errcheck
149-
} else {
150-
stdout, stderr, status, err := runner.RunComplexCommand(cmd)
151-
Expect(err).ToNot(HaveOccurred())
152-
153-
envVars := parseEnvFields(stdout, true)
154-
Expect(envVars).To(HaveKeyWithValue("FOO", "BAR"))
155-
Expect(envVars).ToNot(HaveKey("PATH"))
156-
Expect(stderr).To(BeEmpty())
157-
Expect(status).To(Equal(0))
158-
}
159-
})
160-
161143
It("uses the env vars specified in the Command", func() {
162144
GinkgoT().Setenv("_FOO", "BAR")
163145

@@ -351,7 +333,6 @@ var _ = Describe("execCmdRunner", func() {
351333

352334
It("allows setting custom env variable in addition to inheriting process env variables", func() {
353335
cmd := osSpecificCommand("env")
354-
cmd.UseIsolatedEnv = false
355336

356337
process, err := runner.RunComplexCommandAsync(cmd)
357338
Expect(err).ToNot(HaveOccurred())

0 commit comments

Comments
 (0)