mirror of
https://github.com/docker/cli.git
synced 2026-01-18 08:21:31 +03:00
compose: fix environment interpolation from the client
For an environment variable defined in the yaml without value, the value needs to be propagated from the client, as in Docker Compose. Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
This commit is contained in:
committed by
Daniel Nephin
parent
5ce6afc459
commit
b7ffa960bf
@@ -115,6 +115,16 @@ func getConfigDetails(opts deployOptions) (composetypes.ConfigDetails, error) {
|
||||
}
|
||||
// TODO: support multiple files
|
||||
details.ConfigFiles = []composetypes.ConfigFile{*configFile}
|
||||
env := os.Environ()
|
||||
details.Environment = make(map[string]string, len(env))
|
||||
for _, s := range env {
|
||||
// if value is empty, s is like "K=", not "K".
|
||||
if !strings.Contains(s, "=") {
|
||||
return details, fmt.Errorf("unexpected environment %q", s)
|
||||
}
|
||||
kv := strings.SplitN(s, "=", 2)
|
||||
details.Environment[kv[0]] = kv[1]
|
||||
}
|
||||
return details, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user