fix: avoid passing empty variable names

This commit is contained in:
Ace Eldeib
2019-12-29 16:07:12 -08:00
parent 697a6e9759
commit e0f62c67f6
2 changed files with 10 additions and 2 deletions

View File

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

View File

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