Skip to content

Commit 8697e4e

Browse files
committed
Fix issue with overlapping envs
Fixes an issue where custom environment variable was overriden by host value causing a clash. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent 34d39bc commit 8697e4e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pkg/v1/exec.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,20 @@ func (et ExecTask) Execute() (ExecResult, error) {
7171
cmd.Dir = et.Cwd
7272

7373
if len(et.Env) > 0 {
74-
cmd.Env = os.Environ()
74+
overrides := map[string]bool{}
7575
for _, env := range et.Env {
76+
key := strings.Split(env, "=")[0]
77+
overrides[key] = true
7678
cmd.Env = append(cmd.Env, env)
7779
}
80+
81+
for _, env := range os.Environ() {
82+
key := strings.Split(env, "=")[0]
83+
84+
if _, ok := overrides[key]; !ok {
85+
cmd.Env = append(cmd.Env, env)
86+
}
87+
}
7888
}
7989

8090
stdoutBuff := bytes.Buffer{}

0 commit comments

Comments
 (0)