From 375b7aafd2634854c59b21b12dbd75a11c473dad Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Thu, 15 Dec 2016 06:12:33 -0800 Subject: [PATCH] Fix misleading default for `--replicas` This fix tries to address the issue raised in 29291 where the output of `--replicas` in `service create/update`: ``` --replicas uint Number of tasks (default none) ``` is misleading. User might incorrectly assume the number of replicas would be `0` (`none`) by default, while the actual default is `1`. The issue comes from the fact that some of the default values are from daemon and it is not possible for client to find out the default value. In this case, it might be better to just simply not displaying `(default none)`. This fix returns "" for `Uint64Opt` so that `(default none)` is hidden. In addition to `--replicas`, this fix also changes `--restart-delay`, `--restart-max-attempts`, `--stop-grace-period`, `--health-interval`, `--health-timeout`, and `--restart-window` in a similiar fashion. New Output: ``` --health-interval duration Time between running the check (ns|us|ms|s|m|h) --health-timeout duration Maximum time to allow one check to run (ns|us|ms|s|m|h) ... --replicas uint Number of tasks ... --restart-delay duration Delay between restart attempts (ns|us|ms|s|m|h) --restart-max-attempts uint Maximum number of restarts before giving up --restart-window duration Window used to evaluate the restart policy (ns|us|ms|s|m|h) ... --stop-grace-period duration Time to wait before force killing a container (ns|us|ms|s|m|h) ``` The docs has been updated. Note the docs for help output of `service create/update` is out of sync with the current master. This fix replace with the update-to-date help output. This fix fixes 29291. Signed-off-by: Yong Tang Upstream-commit: 23ab849f06f07c7efae6dd8c169070a81b9e40f0 Component: cli --- components/cli/command/service/opts.go | 4 ++-- components/cli/command/service/opts_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/cli/command/service/opts.go b/components/cli/command/service/opts.go index c7518e5976..cbe544aacc 100644 --- a/components/cli/command/service/opts.go +++ b/components/cli/command/service/opts.go @@ -84,7 +84,7 @@ func (d *DurationOpt) String() string { if d.value != nil { return d.value.String() } - return "none" + return "" } // Value returns the time.Duration @@ -114,7 +114,7 @@ func (i *Uint64Opt) String() string { if i.value != nil { return fmt.Sprintf("%v", *i.value) } - return "none" + return "" } // Value returns the uint64 diff --git a/components/cli/command/service/opts_test.go b/components/cli/command/service/opts_test.go index aa2d999dcf..78b956ad67 100644 --- a/components/cli/command/service/opts_test.go +++ b/components/cli/command/service/opts_test.go @@ -59,7 +59,7 @@ func TestUint64OptString(t *testing.T) { assert.Equal(t, opt.String(), "2345678") opt = Uint64Opt{} - assert.Equal(t, opt.String(), "none") + assert.Equal(t, opt.String(), "") } func TestUint64OptSetAndValue(t *testing.T) {