mirror of https://github.com/docker/cli.git
cli/command/network: use strings.Cut
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
424401233f
commit
f29992c0f1
|
@ -81,13 +81,13 @@ func runConnect(dockerCli command.Cli, options connectOptions) error {
|
||||||
func convertDriverOpt(opts []string) (map[string]string, error) {
|
func convertDriverOpt(opts []string) (map[string]string, error) {
|
||||||
driverOpt := make(map[string]string)
|
driverOpt := make(map[string]string)
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
parts := strings.SplitN(opt, "=", 2)
|
k, v, ok := strings.Cut(opt, "=")
|
||||||
if len(parts) != 2 {
|
// TODO(thaJeztah): we should probably not accept whitespace here (both for key and value).
|
||||||
|
k = strings.TrimSpace(k)
|
||||||
|
if !ok || k == "" {
|
||||||
return nil, fmt.Errorf("invalid key/value pair format in driver options")
|
return nil, fmt.Errorf("invalid key/value pair format in driver options")
|
||||||
}
|
}
|
||||||
key := strings.TrimSpace(parts[0])
|
driverOpt[k] = strings.TrimSpace(v)
|
||||||
value := strings.TrimSpace(parts[1])
|
|
||||||
driverOpt[key] = value
|
|
||||||
}
|
}
|
||||||
return driverOpt, nil
|
return driverOpt, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue