From e0f62c67f6400749fc903f956e379d566f28cd77 Mon Sep 17 00:00:00 2001 From: Ace Eldeib Date: Sun, 29 Dec 2019 16:07:12 -0800 Subject: [PATCH] fix: avoid passing empty variable names --- kyaml/kio/filters/container.go | 6 +++++- kyaml/kio/filters/container_test.go | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) 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)