diff --git a/commands/commands.go b/commands/commands.go index 5452de24f1..2fbb8d152c 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -42,6 +42,8 @@ type CommandLine interface { Args() cli.Args + IsSet(name string) bool + Bool(name string) bool Int(name string) int diff --git a/commands/commandstest/fake_command_line.go b/commands/commandstest/fake_command_line.go index 4a070b5a19..be9368e38e 100644 --- a/commands/commandstest/fake_command_line.go +++ b/commands/commandstest/fake_command_line.go @@ -42,6 +42,11 @@ func (ff FakeFlagger) Bool(key string) bool { return false } +func (fcli *FakeCommandLine) IsSet(key string) bool { + _, ok := fcli.LocalFlags.Data[key] + return ok +} + func (fcli *FakeCommandLine) String(key string) string { return fcli.LocalFlags.String(key) } diff --git a/commands/create.go b/commands/create.go index bdb3da6594..e15aa6e374 100644 --- a/commands/create.go +++ b/commands/create.go @@ -364,7 +364,9 @@ func getDriverOpts(c CommandLine, mcnflags []mcnflag.Flag) drivers.DriverOptions // TODO: This is pretty hacky. StringSlice is the only // type so far we have to worry about which is not a // Getter, though. - driverOpts.Values[name] = c.StringSlice(name) + if c.IsSet(name) { + driverOpts.Values[name] = c.StringSlice(name) + } } }