diff --git a/kyaml/kio/filters/container.go b/kyaml/kio/filters/container.go index a45e96a89..792800de0 100644 --- a/kyaml/kio/filters/container.go +++ b/kyaml/kio/filters/container.go @@ -130,7 +130,11 @@ func (c *ContainerFilter) getArgs() []string { // export the local environment vars to the container for _, pair := range os.Environ() { - args = append(args, "-e", strings.Split(pair, "=")[0]) + tokens := strings.Split(pair, "=") + if tokens[0] == "" { + continue + } + args = append(args, "-e", tokens[0]) } return append(args, c.Image) } diff --git a/kyaml/kio/filters/container_test.go b/kyaml/kio/filters/container_test.go index b17769f6f..7ca7de951 100644 --- a/kyaml/kio/filters/container_test.go +++ b/kyaml/kio/filters/container_test.go @@ -131,7 +131,11 @@ metadata: } for _, e := range os.Environ() { // the process env - expected = append(expected, "-e", strings.Split(e, "=")[0]) + tokens := strings.Split(e, "=") + if tokens[0] == "" { + continue + } + expected = append(expected, "-e", tokens[0]) } expected = append(expected, "example.com:version") assert.Equal(t, expected, cmd.Args)