mirror of https://github.com/docker/cli.git
cli/command/stack: use strings.Cut
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
2b06c0c42c
commit
b3557b2840
|
@ -104,12 +104,12 @@ func GetConfigDetails(composefiles []string, stdin io.Reader) (composetypes.Conf
|
||||||
func buildEnvironment(env []string) (map[string]string, error) {
|
func buildEnvironment(env []string) (map[string]string, error) {
|
||||||
result := make(map[string]string, len(env))
|
result := make(map[string]string, len(env))
|
||||||
for _, s := range env {
|
for _, s := range env {
|
||||||
// if value is empty, s is like "K=", not "K".
|
k, v, ok := strings.Cut(s, "=")
|
||||||
if !strings.Contains(s, "=") {
|
if !ok || k == "" {
|
||||||
return result, errors.Errorf("unexpected environment %q", s)
|
return result, errors.Errorf("unexpected environment %q", s)
|
||||||
}
|
}
|
||||||
kv := strings.SplitN(s, "=", 2)
|
// value may be set, but empty if "s" is like "K=", not "K".
|
||||||
result[kv[0]] = kv[1]
|
result[k] = v
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue