explicitly specify envs to be exported in function

This commit is contained in:
Donny Xia
2020-08-24 13:35:18 -07:00
parent 30b58e90a3
commit 904a9dea08
6 changed files with 242 additions and 29 deletions

View File

@@ -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
}