From 705865fa70a789eeb3e19ea5b7214596e63da4a4 Mon Sep 17 00:00:00 2001 From: John Sirois Date: Tue, 29 Mar 2016 11:36:28 -0600 Subject: [PATCH] Fixup create command flag application. Previously StringSlice flag defaults were not respected. These use special handling and that handling did not take account of default values, always over-writing them. Expand the CommandLine interface to take advantage of the underlying codegansta/cli.Context IsSet method and guard default string slice overwrites with an IsSet test. Signed-off-by: John Sirois --- commands/commands.go | 2 ++ commands/commandstest/fake_command_line.go | 5 +++++ commands/create.go | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-) 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) + } } }