summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2018-10-23 06:39:21 -0700
committerGitHub <noreply@github.com>2018-10-23 06:39:21 -0700
commit9a6a64f78ca3837a0e02373b2ae7f3769fbde568 (patch)
treebbbd72757177bcf844e14421a89ee741fbf20f33 /cmd
parent95c93577cd3c96b5b2d2e7945723bda218073d8f (diff)
parent125202923f00f43fd102760b3340b86dd72a4c7d (diff)
downloadpodman-9a6a64f78ca3837a0e02373b2ae7f3769fbde568.tar.gz
podman-9a6a64f78ca3837a0e02373b2ae7f3769fbde568.tar.bz2
podman-9a6a64f78ca3837a0e02373b2ae7f3769fbde568.zip
Merge pull request #1665 from vrothberg/ignore-env-vars
fix environment variable parsing
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/create_cli_test.go2
-rw-r--r--cmd/podman/parse.go10
2 files changed, 7 insertions, 5 deletions
diff --git a/cmd/podman/create_cli_test.go b/cmd/podman/create_cli_test.go
index fa128c8e6..9db007ff3 100644
--- a/cmd/podman/create_cli_test.go
+++ b/cmd/podman/create_cli_test.go
@@ -47,7 +47,7 @@ func TestGetAllLabels(t *testing.T) {
}
func TestGetAllLabelsBadKeyValue(t *testing.T) {
- inLabels := []string{"ONE1", "TWO=2"}
+ inLabels := []string{"=badValue", "="}
fileLabels := []string{}
_, err := getAllLabels(fileLabels, inLabels)
assert.Error(t, err, assert.AnError)
diff --git a/cmd/podman/parse.go b/cmd/podman/parse.go
index ade592ddf..2e4959656 100644
--- a/cmd/podman/parse.go
+++ b/cmd/podman/parse.go
@@ -198,6 +198,11 @@ func readKVStrings(env map[string]string, files []string, override []string) err
func parseEnv(env map[string]string, line string) error {
data := strings.SplitN(line, "=", 2)
+ // catch invalid variables such as "=" or "=A"
+ if data[0] == "" {
+ return errors.Errorf("invalid environment variable: %q", line)
+ }
+
// trim the front of a variable, but nothing else
name := strings.TrimLeft(data[0], whiteSpaces)
if strings.ContainsAny(name, whiteSpaces) {
@@ -208,10 +213,7 @@ func parseEnv(env map[string]string, line string) error {
env[name] = data[1]
} else {
// if only a pass-through variable is given, clean it up.
- val, exists := os.LookupEnv(name)
- if !exists {
- return errors.Errorf("environment variable %q does not exist", name)
- }
+ val, _ := os.LookupEnv(name)
env[name] = val
}
return nil