From 5e4444823cc90553642300bc1d6cc7eb7654d9c9 Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Mon, 6 Jan 2020 12:02:06 -0800 Subject: [PATCH] build: only use env for args if set When following this pattern: buildx build --arg FOO Where we want to pull `FOO` from env, currently we always set `FOO` regardless if the `FOO` env var is even set. This change makes it so that `FOO` would only be set if it has been set in the env (even if it is set to empty). Signed-off-by: Brian Goff --- commands/build.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/commands/build.go b/commands/build.go index af8e2ff2..1e865de3 100644 --- a/commands/build.go +++ b/commands/build.go @@ -305,7 +305,10 @@ func listToMap(values []string, defaultEnv bool) map[string]string { kv := strings.SplitN(value, "=", 2) if len(kv) == 1 { if defaultEnv { - result[kv[0]] = os.Getenv(kv[0]) + v, ok := os.LookupEnv(kv[0]) + if ok { + result[kv[0]] = v + } } else { result[kv[0]] = "" }