Skip to content

Commit 3d85a2a

Browse files
committed
Rmove UseIsolatedEnv from system.Command
This struct attribute is only ever set to `true` by the bosh-cli, and the value if this use case is in question, see: - cloudfoundry/bosh-cli#660 - cloudfoundry/bosh-cli#663 - cloudfoundry/bosh-cli#673 In addition the `UseIsolatedEnv` capability can be wholely handled within the `bosh-cli` codebase itself without the need for this featuer in `bosh-utils`.
1 parent 35bcb02 commit 3d85a2a

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
@@ -126,7 +126,6 @@ var _ = Describe("execCmdRunner", func() {
126126

127127
It("run complex command with env", func() {
128128
cmd := GetPlatformCommand("env")
129-
cmd.UseIsolatedEnv = false
130129
stdout, stderr, status, err := runner.RunComplexCommand(cmd)
131130
Expect(err).ToNot(HaveOccurred())
132131

@@ -137,23 +136,6 @@ var _ = Describe("execCmdRunner", func() {
137136
Expect(status).To(Equal(0))
138137
})
139138

140-
It("runs complex command with specific env", func() {
141-
cmd := GetPlatformCommand("env")
142-
cmd.UseIsolatedEnv = true
143-
if runtime.GOOS == "windows" {
144-
Expect(func() { runner.RunComplexCommand(cmd) }).To(Panic()) //nolint:errcheck
145-
} else {
146-
stdout, stderr, status, err := runner.RunComplexCommand(cmd)
147-
Expect(err).ToNot(HaveOccurred())
148-
149-
envVars := parseEnvFields(stdout, true)
150-
Expect(envVars).To(HaveKeyWithValue("FOO", "BAR"))
151-
Expect(envVars).ToNot(HaveKey("PATH"))
152-
Expect(stderr).To(BeEmpty())
153-
Expect(status).To(Equal(0))
154-
}
155-
})
156-
157139
setupWindowsEnvTest := func(cmdVars map[string]string) (map[string]string, error) {
158140
os.Setenv("_FOO", "BAR") //nolint:errcheck
159141
defer os.Unsetenv("_FOO")
@@ -319,7 +301,6 @@ var _ = Describe("execCmdRunner", func() {
319301

320302
It("allows setting custom env variable in addition to inheriting process env variables", func() {
321303
cmd := GetPlatformCommand("env")
322-
cmd.UseIsolatedEnv = false
323304

324305
process, err := runner.RunComplexCommandAsync(cmd)
325306
Expect(err).ToNot(HaveOccurred())

0 commit comments

Comments
 (0)