Browse code

Fixes #24083 : Improving cli help for flags with duration option

Signed-off-by: milindchawre <milindchawre@gmail.com>

milindchawre authored on 2016/10/25 21:22:07
Showing 9 changed files
... ...
@@ -446,8 +446,8 @@ func addServiceFlags(cmd *cobra.Command, opts *serviceOptions) {
446 446
 	flags.Var(&opts.restartPolicy.window, flagRestartWindow, "Window used to evaluate the restart policy")
447 447
 
448 448
 	flags.Uint64Var(&opts.update.parallelism, flagUpdateParallelism, 1, "Maximum number of tasks updated simultaneously (0 to update all at once)")
449
-	flags.DurationVar(&opts.update.delay, flagUpdateDelay, time.Duration(0), "Delay between updates")
450
-	flags.DurationVar(&opts.update.monitor, flagUpdateMonitor, time.Duration(0), "Duration after each task update to monitor for failure")
449
+	flags.DurationVar(&opts.update.delay, flagUpdateDelay, time.Duration(0), "Delay between updates (ns|us|ms|s|m|h) (default 0s)")
450
+	flags.DurationVar(&opts.update.monitor, flagUpdateMonitor, time.Duration(0), "Duration after each task update to monitor for failure (ns|us|ms|s|m|h) (default 0s)")
451 451
 	flags.StringVar(&opts.update.onFailure, flagUpdateFailureAction, "pause", "Action on update failure (pause|continue)")
452 452
 	flags.Float32Var(&opts.update.maxFailureRatio, flagUpdateMaxFailureRatio, 0, "Failure rate to tolerate during an update")
453 453
 
... ...
@@ -168,8 +168,8 @@ func parseExternalCA(caSpec string) (*swarm.ExternalCA, error) {
168 168
 
169 169
 func addSwarmFlags(flags *pflag.FlagSet, opts *swarmOptions) {
170 170
 	flags.Int64Var(&opts.taskHistoryLimit, flagTaskHistoryLimit, 5, "Task history retention limit")
171
-	flags.DurationVar(&opts.dispatcherHeartbeat, flagDispatcherHeartbeat, time.Duration(5*time.Second), "Dispatcher heartbeat period")
172
-	flags.DurationVar(&opts.nodeCertExpiry, flagCertExpiry, time.Duration(90*24*time.Hour), "Validity period for node certificates")
171
+	flags.DurationVar(&opts.dispatcherHeartbeat, flagDispatcherHeartbeat, time.Duration(5*time.Second), "Dispatcher heartbeat period (ns|us|ms|s|m|h) (default 5s)")
172
+	flags.DurationVar(&opts.nodeCertExpiry, flagCertExpiry, time.Duration(90*24*time.Hour), "Validity period for node certificates (ns|us|ms|s|m|h) (default 2160h0m0s)")
173 173
 	flags.Var(&opts.externalCA, flagExternalCA, "Specifications of one or more certificate signing endpoints")
174 174
 	flags.Uint64Var(&opts.maxSnapshots, flagMaxSnapshots, 0, "Number of additional Raft snapshots to retain")
175 175
 	flags.Uint64Var(&opts.snapshotInterval, flagSnapshotInterval, 10000, "Number of log entries between Raft snapshots")
... ...
@@ -58,9 +58,9 @@ Options:
58 58
       --expose value                Expose a port or a range of ports (default [])
59 59
       --group-add value             Add additional groups to join (default [])
60 60
       --health-cmd string           Command to run to check health
61
-      --health-interval duration    Time between running the check
61
+      --health-interval duration    Time between running the check (ns|us|ms|s|m|h) (default 0s)
62 62
       --health-retries int          Consecutive failures needed to report unhealthy
63
-      --health-timeout duration     Maximum time to allow one check to run
63
+      --health-timeout duration     Maximum time to allow one check to run (ns|us|ms|s|m|h) (default 0s)
64 64
       --help                        Print usage
65 65
   -h, --hostname string             Container host name
66 66
   -i, --interactive                 Keep STDIN open even if not attached
... ...
@@ -62,9 +62,9 @@ Options:
62 62
       --expose value                Expose a port or a range of ports (default [])
63 63
       --group-add value             Add additional groups to join (default [])
64 64
       --health-cmd string           Command to run to check health
65
-      --health-interval duration    Time between running the check
65
+      --health-interval duration    Time between running the check (ns|us|ms|s|m|h) (default 0s)
66 66
       --health-retries int          Consecutive failures needed to report unhealthy
67
-      --health-timeout duration     Maximum time to allow one check to run
67
+      --health-timeout duration     Maximum time to allow one check to run (ns|us|ms|s|m|h) (default 0s)
68 68
       --help                        Print usage
69 69
   -h, --hostname string             Container host name
70 70
   -i, --interactive                 Keep STDIN open even if not attached
... ...
@@ -31,9 +31,9 @@ Options:
31 31
       --env-file value                   Read in a file of environment variables (default [])
32 32
       --group value                      Set one or more supplementary user groups for the container (default [])
33 33
       --health-cmd string                Command to run to check health
34
-      --health-interval duration         Time between running the check
34
+      --health-interval duration         Time between running the check (ns|us|ms|s|m|h) (default 0s)
35 35
       --health-retries int               Consecutive failures needed to report unhealthy
36
-      --health-timeout duration          Maximum time to allow one check to run
36
+      --health-timeout duration          Maximum time to allow one check to run (ns|us|ms|s|m|h) (default 0s)
37 37
       --help                             Print usage
38 38
       --hostname                         Service containers hostname
39 39
   -l, --label value                      Service labels (default [])
... ...
@@ -56,10 +56,10 @@ Options:
56 56
       --restart-window value             Window used to evaluate the restart policy (default none)
57 57
       --stop-grace-period value          Time to wait before force killing a container (default none)
58 58
   -t, --tty                              Allocate a pseudo-TTY
59
-      --update-delay duration            Delay between updates
59
+      --update-delay duration            Delay between updates (ns|us|ms|s|m|h) (default 0s)
60 60
       --update-failure-action string     Action on update failure (pause|continue) (default "pause")
61 61
       --update-max-failure-ratio value   Failure rate to tolerate during an update
62
-      --update-monitor duration          Duration after each task update to monitor for failure (default 0s)
62
+      --update-monitor duration          Duration after each task update to monitor for failure (ns|us|ms|s|m|h) (default 0s)
63 63
       --update-parallelism uint          Maximum number of tasks updated simultaneously (0 to update all at once) (default 1)
64 64
   -u, --user string                      Username or UID (format: <name|uid>[:<group|gid>])
65 65
       --with-registry-auth               Send registry authentication details to Swarm agents
... ...
@@ -39,9 +39,9 @@ Options:
39 39
       --group-add stringSlice              Add an additional supplementary user group to the container
40 40
       --group-rm list                      Remove a previously added supplementary user group from the container (default [])
41 41
       --health-cmd string                  Command to run to check health
42
-      --health-interval duration-ptr       Time between running the check (default none)
42
+      --health-interval duration           Time between running the check (ns|us|ms|s|m|h) (default 0s)
43 43
       --health-retries int                 Consecutive failures needed to report unhealthy
44
-      --health-timeout duration-ptr        Maximum time to allow one check to run (default none)
44
+      --health-timeout duration            Maximum time to allow one check to run (ns|us|ms|s|m|h) (default 0s)
45 45
       --help                               Print usage
46 46
       --image string                       Service image tag
47 47
       --label-add list                     Add or update a service label (default [])
... ...
@@ -65,10 +65,10 @@ Options:
65 65
       --rollback                           Rollback to previous specification
66 66
       --stop-grace-period duration-ptr     Time to wait before force killing a container (default none)
67 67
   -t, --tty                                Allocate a pseudo-TTY
68
-      --update-delay duration              Delay between updates
68
+      --update-delay duration              Delay between updates (ns|us|ms|s|m|h) (default 0s)
69 69
       --update-failure-action string       Action on update failure (pause|continue) (default "pause")
70 70
       --update-max-failure-ratio float32   Failure rate to tolerate during an update
71
-      --update-monitor duration            Duration after each task update to monitor for failure
71
+      --update-monitor duration            Duration after each task update to monitor for failure (ns|us|ms|s|m|h) (default 0s)
72 72
       --update-parallelism uint            Maximum number of tasks updated simultaneously (0 to update all at once) (default 1)
73 73
   -u, --user string                        Username or UID (format: <name|uid>[:<group|gid>])
74 74
       --with-registry-auth                 Send registry authentication details to swarm agents
... ...
@@ -22,8 +22,8 @@ Initialize a swarm
22 22
 
23 23
 Options:
24 24
       --advertise-addr value            Advertised address (format: <ip|interface>[:port])
25
-      --cert-expiry duration            Validity period for node certificates (default 2160h0m0s)
26
-      --dispatcher-heartbeat duration   Dispatcher heartbeat period (default 5s)
25
+      --cert-expiry duration            Validity period for node certificates (ns|us|ms|s|m|h) (default 2160h0m0s)
26
+      --dispatcher-heartbeat duration   Dispatcher heartbeat period (ns|us|ms|s|m|h) (default 5s)
27 27
       --external-ca value               Specifications of one or more certificate signing endpoints
28 28
       --force-new-cluster               Force create a new cluster from current state
29 29
       --help                            Print usage
... ...
@@ -21,8 +21,8 @@ Usage:  docker swarm update [OPTIONS]
21 21
 Update the swarm
22 22
 
23 23
 Options:
24
-      --cert-expiry duration            Validity period for node certificates (default 2160h0m0s)
25
-      --dispatcher-heartbeat duration   Dispatcher heartbeat period (default 5s)
24
+      --cert-expiry duration            Validity period for node certificates (ns|us|ms|s|m|h) (default 2160h0m0s)
25
+      --dispatcher-heartbeat duration   Dispatcher heartbeat period (ns|us|ms|s|m|h) (default 5s)
26 26
       --external-ca value               Specifications of one or more certificate signing endpoints
27 27
       --help                            Print usage
28 28
       --max-snapshots int               Number of additional Raft snapshots to retain
... ...
@@ -218,9 +218,9 @@ func AddFlags(flags *pflag.FlagSet) *ContainerOptions {
218 218
 
219 219
 	// Health-checking
220 220
 	flags.StringVar(&copts.healthCmd, "health-cmd", "", "Command to run to check health")
221
-	flags.DurationVar(&copts.healthInterval, "health-interval", 0, "Time between running the check")
221
+	flags.DurationVar(&copts.healthInterval, "health-interval", 0, "Time between running the check (ns|us|ms|s|m|h) (default 0s)")
222 222
 	flags.IntVar(&copts.healthRetries, "health-retries", 0, "Consecutive failures needed to report unhealthy")
223
-	flags.DurationVar(&copts.healthTimeout, "health-timeout", 0, "Maximum time to allow one check to run")
223
+	flags.DurationVar(&copts.healthTimeout, "health-timeout", 0, "Maximum time to allow one check to run (ns|us|ms|s|m|h) (default 0s)")
224 224
 	flags.BoolVar(&copts.noHealthcheck, "no-healthcheck", false, "Disable any container-specified HEALTHCHECK")
225 225
 
226 226
 	// Resource management