mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-14 10:30:59 +00:00
explicitly specify envs to be exported in function
This commit is contained in:
@@ -5,8 +5,6 @@ package container
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
runtimeexec "sigs.k8s.io/kustomize/kyaml/fn/runtime/exec"
|
||||
"sigs.k8s.io/kustomize/kyaml/fn/runtime/runtimeutil"
|
||||
@@ -177,19 +175,7 @@ func (c *Filter) getCommand() (string, []string) {
|
||||
args = append(args, "--mount", storageMount.String())
|
||||
}
|
||||
|
||||
// TODO: put these env processes into a separate function and call it in the outside of
|
||||
// getCommand
|
||||
os.Setenv("LOG_TO_STDERR", "true")
|
||||
os.Setenv("STRUCTURED_RESULTS", "true")
|
||||
|
||||
// export the local environment vars to the container
|
||||
for _, pair := range os.Environ() {
|
||||
items := strings.Split(pair, "=")
|
||||
if items[0] == "" || items[1] == "" || items[0] == tmpDirEnvKey {
|
||||
continue
|
||||
}
|
||||
args = append(args, "-e", items[0])
|
||||
}
|
||||
args = append(args, c.Envs.GetDockerFlags()...)
|
||||
a := append(args, c.Image)
|
||||
return "docker", a
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -137,20 +136,13 @@ metadata:
|
||||
}
|
||||
tt.instance.Exec.FunctionConfig = cfg
|
||||
|
||||
os.Setenv("KYAML_TEST", "FOO")
|
||||
tt.instance.setupExec()
|
||||
tt.instance.Envs.AddKeyValue("KYAML_TEST", "FOO")
|
||||
tt.expectedArgs = append(tt.expectedArgs, tt.instance.Envs.GetDockerFlags()...)
|
||||
|
||||
// configure expected env
|
||||
for _, e := range os.Environ() {
|
||||
// the process env
|
||||
parts := strings.Split(e, "=")
|
||||
if parts[0] == "" || parts[1] == "" || parts[0] == tmpDirEnvKey {
|
||||
continue
|
||||
}
|
||||
tt.expectedArgs = append(tt.expectedArgs, "-e", parts[0])
|
||||
}
|
||||
tt.expectedArgs = append(tt.expectedArgs, tt.instance.Image)
|
||||
|
||||
tt.instance.setupExec()
|
||||
|
||||
if !assert.Equal(t, "docker", tt.instance.Exec.Path) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user