Skip to content

Commit 705865f

Browse files
committed
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 <john.sirois@gmail.com>
1 parent 0d58079 commit 705865f

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

commands/commands.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ type CommandLine interface {
4242

4343
Args() cli.Args
4444

45+
IsSet(name string) bool
46+
4547
Bool(name string) bool
4648

4749
Int(name string) int

commands/commandstest/fake_command_line.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ func (ff FakeFlagger) Bool(key string) bool {
4242
return false
4343
}
4444

45+
func (fcli *FakeCommandLine) IsSet(key string) bool {
46+
_, ok := fcli.LocalFlags.Data[key]
47+
return ok
48+
}
49+
4550
func (fcli *FakeCommandLine) String(key string) string {
4651
return fcli.LocalFlags.String(key)
4752
}

commands/create.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,9 @@ func getDriverOpts(c CommandLine, mcnflags []mcnflag.Flag) drivers.DriverOptions
364364
// TODO: This is pretty hacky. StringSlice is the only
365365
// type so far we have to worry about which is not a
366366
// Getter, though.
367-
driverOpts.Values[name] = c.StringSlice(name)
367+
if c.IsSet(name) {
368+
driverOpts.Values[name] = c.StringSlice(name)
369+
}
368370
}
369371
}
370372

0 commit comments

Comments
 (0)