Browse code

Add version annotation to various flags added in 1.13

Pull request https://github.com/docker/docker/pull/27745 added support for the
client to talk to older versions of the daemon. Various flags were added to
docker 1.13 that are not compatible with older daemons.

This PR adds annotations to those flags, so that they are automatically hidden
if the daemon is older than docker 1.13 (API 1.25).

Not all new flags affect the API (some are client-side only). The following
PR's added new flags to docker 1.13 that affect the API;

- https://github.com/docker/docker/pull/23430 added `--cpu-rt-period`and `--cpu-rt-runtime`
- https://github.com/docker/docker/pull/27800 / https://github.com/docker/docker/pull/25317 added `--group` / `--group-add` / `--group-rm`
- https://github.com/docker/docker/pull/27702 added `--network` to `docker build`
- https://github.com/docker/docker/pull/25962 added `--attachable` to `docker network create`
- https://github.com/docker/docker/pull/27998 added `--compose-file` to `docker stack deploy`
- https://github.com/docker/docker/pull/22566 added `--stop-timeout` to `docker run` and `docker create`
- https://github.com/docker/docker/pull/26061 added `--init` to `docker run` and `docker create`
- https://github.com/docker/docker/pull/26941 added `--init-path` to `docker run` and `docker create`
- https://github.com/docker/docker/pull/27958 added `--cpus` on `docker run` / `docker create`
- https://github.com/docker/docker/pull/27567 added `--dns`, `--dns-opt`, and `--dns-search` to `docker service create`
- https://github.com/docker/docker/pull/27596 added `--force` to `docker service update`
- https://github.com/docker/docker/pull/27857 added `--hostname` to `docker service create`
- https://github.com/docker/docker/pull/28031 added `--hosts`, `--host-add` / `--host-rm` to `docker service create` and `docker service update`
- https://github.com/docker/docker/pull/28076 added `--tty` on `docker service create` / `docker service update`
- https://github.com/docker/docker/pull/26421 added `--update-max-failure-ratio`, `--update-monitor` and `--rollback` on `docker service update`
- https://github.com/docker/docker/pull/27369 added `--health-cmd`, `--health-interval`, `--health-retries`, `--health-timeout` and `--no-healthcheck` options to `docker service create` and `docker service update`

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2017/01/17 01:57:26
Showing 9 changed files
... ...
@@ -236,9 +236,12 @@ func addFlags(flags *pflag.FlagSet) *containerOptions {
236 236
 	flags.Int64Var(&copts.cpuPeriod, "cpu-period", 0, "Limit CPU CFS (Completely Fair Scheduler) period")
237 237
 	flags.Int64Var(&copts.cpuQuota, "cpu-quota", 0, "Limit CPU CFS (Completely Fair Scheduler) quota")
238 238
 	flags.Int64Var(&copts.cpuRealtimePeriod, "cpu-rt-period", 0, "Limit CPU real-time period in microseconds")
239
+	flags.SetAnnotation("cpu-rt-period", "version", []string{"1.25"})
239 240
 	flags.Int64Var(&copts.cpuRealtimeRuntime, "cpu-rt-runtime", 0, "Limit CPU real-time runtime in microseconds")
241
+	flags.SetAnnotation("cpu-rt-runtime", "version", []string{"1.25"})
240 242
 	flags.Int64VarP(&copts.cpuShares, "cpu-shares", "c", 0, "CPU shares (relative weight)")
241 243
 	flags.Var(&copts.cpus, "cpus", "Number of CPUs")
244
+	flags.SetAnnotation("cpus", "version", []string{"1.25"})
242 245
 	flags.Var(&copts.deviceReadBps, "device-read-bps", "Limit read rate (bytes per second) from a device")
243 246
 	flags.Var(&copts.deviceReadIOps, "device-read-iops", "Limit read rate (IO per second) from a device")
244 247
 	flags.Var(&copts.deviceWriteBps, "device-write-bps", "Limit write rate (bytes per second) to a device")
... ...
@@ -264,7 +267,9 @@ func addFlags(flags *pflag.FlagSet) *containerOptions {
264 264
 	flags.StringVar(&copts.runtime, "runtime", "", "Runtime to use for this container")
265 265
 
266 266
 	flags.BoolVar(&copts.init, "init", false, "Run an init inside the container that forwards signals and reaps processes")
267
+	flags.SetAnnotation("init", "version", []string{"1.25"})
267 268
 	flags.StringVar(&copts.initPath, "init-path", "", "Path to the docker-init binary")
269
+	flags.SetAnnotation("init-path", "version", []string{"1.25"})
268 270
 	return copts
269 271
 }
270 272
 
... ...
@@ -54,7 +54,9 @@ func NewUpdateCommand(dockerCli *command.DockerCli) *cobra.Command {
54 54
 	flags.Int64Var(&opts.cpuPeriod, "cpu-period", 0, "Limit CPU CFS (Completely Fair Scheduler) period")
55 55
 	flags.Int64Var(&opts.cpuQuota, "cpu-quota", 0, "Limit CPU CFS (Completely Fair Scheduler) quota")
56 56
 	flags.Int64Var(&opts.cpuRealtimePeriod, "cpu-rt-period", 0, "Limit the CPU real-time period in microseconds")
57
+	flags.SetAnnotation("cpu-rt-period", "version", []string{"1.25"})
57 58
 	flags.Int64Var(&opts.cpuRealtimeRuntime, "cpu-rt-runtime", 0, "Limit the CPU real-time runtime in microseconds")
59
+	flags.SetAnnotation("cpu-rt-runtime", "version", []string{"1.25"})
58 60
 	flags.StringVar(&opts.cpusetCpus, "cpuset-cpus", "", "CPUs in which to allow execution (0-3, 0,1)")
59 61
 	flags.StringVar(&opts.cpusetMems, "cpuset-mems", "", "MEMs in which to allow execution (0-3, 0,1)")
60 62
 	flags.Int64VarP(&opts.cpuShares, "cpu-shares", "c", 0, "CPU shares (relative weight)")
... ...
@@ -107,6 +107,7 @@ func NewBuildCommand(dockerCli *command.DockerCli) *cobra.Command {
107 107
 	flags.BoolVar(&options.compress, "compress", false, "Compress the build context using gzip")
108 108
 	flags.StringSliceVar(&options.securityOpt, "security-opt", []string{}, "Security options")
109 109
 	flags.StringVar(&options.networkMode, "network", "default", "Set the networking mode for the RUN instructions during build")
110
+	flags.SetAnnotation("network", "version", []string{"1.25"})
110 111
 
111 112
 	command.AddTrustedFlags(flags, true)
112 113
 
... ...
@@ -58,6 +58,7 @@ func newCreateCommand(dockerCli *command.DockerCli) *cobra.Command {
58 58
 	flags.BoolVar(&opts.internal, "internal", false, "Restrict external access to the network")
59 59
 	flags.BoolVar(&opts.ipv6, "ipv6", false, "Enable IPv6 networking")
60 60
 	flags.BoolVar(&opts.attachable, "attachable", false, "Enable manual container attachment")
61
+	flags.SetAnnotation("attachable", "version", []string{"1.25"})
61 62
 
62 63
 	flags.StringVar(&opts.ipamDriver, "ipam-driver", "default", "IP Address Management Driver")
63 64
 	flags.StringSliceVar(&opts.ipamSubnet, "subnet", []string{}, "Subnet in CIDR format that represents a network segment")
... ...
@@ -39,12 +39,18 @@ func newCreateCommand(dockerCli *command.DockerCli) *cobra.Command {
39 39
 	flags.Var(&opts.constraints, flagConstraint, "Placement constraints")
40 40
 	flags.Var(&opts.networks, flagNetwork, "Network attachments")
41 41
 	flags.Var(&opts.secrets, flagSecret, "Specify secrets to expose to the service")
42
+	flags.SetAnnotation(flagSecret, "version", []string{"1.25"})
42 43
 	flags.VarP(&opts.endpoint.publishPorts, flagPublish, "p", "Publish a port as a node port")
43 44
 	flags.Var(&opts.groups, flagGroup, "Set one or more supplementary user groups for the container")
45
+	flags.SetAnnotation(flagGroup, "version", []string{"1.25"})
44 46
 	flags.Var(&opts.dns, flagDNS, "Set custom DNS servers")
47
+	flags.SetAnnotation(flagDNS, "version", []string{"1.25"})
45 48
 	flags.Var(&opts.dnsOption, flagDNSOption, "Set DNS options")
49
+	flags.SetAnnotation(flagDNSOption, "version", []string{"1.25"})
46 50
 	flags.Var(&opts.dnsSearch, flagDNSSearch, "Set custom DNS search domains")
51
+	flags.SetAnnotation(flagDNSSearch, "version", []string{"1.25"})
47 52
 	flags.Var(&opts.hosts, flagHost, "Set one or more custom host-to-IP mappings (host:ip)")
53
+	flags.SetAnnotation(flagHost, "version", []string{"1.25"})
48 54
 
49 55
 	flags.SetInterspersed(false)
50 56
 	return cmd
... ...
@@ -445,6 +445,7 @@ func addServiceFlags(cmd *cobra.Command, opts *serviceOptions) {
445 445
 	flags.StringVarP(&opts.workdir, flagWorkdir, "w", "", "Working directory inside the container")
446 446
 	flags.StringVarP(&opts.user, flagUser, "u", "", "Username or UID (format: <name|uid>[:<group|gid>])")
447 447
 	flags.StringVar(&opts.hostname, flagHostname, "", "Container hostname")
448
+	flags.SetAnnotation(flagHostname, "version", []string{"1.25"})
448 449
 
449 450
 	flags.Var(&opts.resources.limitCPU, flagLimitCPU, "Limit CPUs")
450 451
 	flags.Var(&opts.resources.limitMemBytes, flagLimitMemory, "Limit Memory")
... ...
@@ -462,8 +463,10 @@ func addServiceFlags(cmd *cobra.Command, opts *serviceOptions) {
462 462
 	flags.Uint64Var(&opts.update.parallelism, flagUpdateParallelism, 1, "Maximum number of tasks updated simultaneously (0 to update all at once)")
463 463
 	flags.DurationVar(&opts.update.delay, flagUpdateDelay, time.Duration(0), "Delay between updates (ns|us|ms|s|m|h) (default 0s)")
464 464
 	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)")
465
+	flags.SetAnnotation(flagUpdateMonitor, "version", []string{"1.25"})
465 466
 	flags.StringVar(&opts.update.onFailure, flagUpdateFailureAction, "pause", "Action on update failure (pause|continue)")
466 467
 	flags.Var(&opts.update.maxFailureRatio, flagUpdateMaxFailureRatio, "Failure rate to tolerate during an update")
468
+	flags.SetAnnotation(flagUpdateMaxFailureRatio, "version", []string{"1.25"})
467 469
 
468 470
 	flags.StringVar(&opts.endpoint.mode, flagEndpointMode, "", "Endpoint mode (vip or dnsrr)")
469 471
 
... ...
@@ -473,12 +476,18 @@ func addServiceFlags(cmd *cobra.Command, opts *serviceOptions) {
473 473
 	flags.Var(&opts.logDriver.opts, flagLogOpt, "Logging driver options")
474 474
 
475 475
 	flags.StringVar(&opts.healthcheck.cmd, flagHealthCmd, "", "Command to run to check health")
476
+	flags.SetAnnotation(flagHealthCmd, "version", []string{"1.25"})
476 477
 	flags.Var(&opts.healthcheck.interval, flagHealthInterval, "Time between running the check (ns|us|ms|s|m|h)")
478
+	flags.SetAnnotation(flagHealthInterval, "version", []string{"1.25"})
477 479
 	flags.Var(&opts.healthcheck.timeout, flagHealthTimeout, "Maximum time to allow one check to run (ns|us|ms|s|m|h)")
480
+	flags.SetAnnotation(flagHealthTimeout, "version", []string{"1.25"})
478 481
 	flags.IntVar(&opts.healthcheck.retries, flagHealthRetries, 0, "Consecutive failures needed to report unhealthy")
482
+	flags.SetAnnotation(flagHealthRetries, "version", []string{"1.25"})
479 483
 	flags.BoolVar(&opts.healthcheck.noHealthcheck, flagNoHealthcheck, false, "Disable any container-specified HEALTHCHECK")
484
+	flags.SetAnnotation(flagNoHealthcheck, "version", []string{"1.25"})
480 485
 
481 486
 	flags.BoolVarP(&opts.tty, flagTTY, "t", false, "Allocate a pseudo-TTY")
487
+	flags.SetAnnotation(flagTTY, "version", []string{"1.25"})
482 488
 }
483 489
 
484 490
 const (
... ...
@@ -38,11 +38,14 @@ func newUpdateCommand(dockerCli *command.DockerCli) *cobra.Command {
38 38
 	flags.String("image", "", "Service image tag")
39 39
 	flags.String("args", "", "Service command args")
40 40
 	flags.Bool("rollback", false, "Rollback to previous specification")
41
+	flags.SetAnnotation("rollback", "version", []string{"1.25"})
41 42
 	flags.Bool("force", false, "Force update even if no changes require it")
43
+	flags.SetAnnotation("force", "version", []string{"1.25"})
42 44
 	addServiceFlags(cmd, serviceOpts)
43 45
 
44 46
 	flags.Var(newListOptsVar(), flagEnvRemove, "Remove an environment variable")
45 47
 	flags.Var(newListOptsVar(), flagGroupRemove, "Remove a previously added supplementary user group from the container")
48
+	flags.SetAnnotation(flagGroupRemove, "version", []string{"1.25"})
46 49
 	flags.Var(newListOptsVar(), flagLabelRemove, "Remove a label by its key")
47 50
 	flags.Var(newListOptsVar(), flagContainerLabelRemove, "Remove a container label by its key")
48 51
 	flags.Var(newListOptsVar(), flagMountRemove, "Remove a mount by its target path")
... ...
@@ -50,22 +53,33 @@ func newUpdateCommand(dockerCli *command.DockerCli) *cobra.Command {
50 50
 	flags.Var(&opts.PortOpt{}, flagPublishRemove, "Remove a published port by its target port")
51 51
 	flags.Var(newListOptsVar(), flagConstraintRemove, "Remove a constraint")
52 52
 	flags.Var(newListOptsVar(), flagDNSRemove, "Remove a custom DNS server")
53
+	flags.SetAnnotation(flagDNSRemove, "version", []string{"1.25"})
53 54
 	flags.Var(newListOptsVar(), flagDNSOptionRemove, "Remove a DNS option")
55
+	flags.SetAnnotation(flagDNSOptionRemove, "version", []string{"1.25"})
54 56
 	flags.Var(newListOptsVar(), flagDNSSearchRemove, "Remove a DNS search domain")
57
+	flags.SetAnnotation(flagDNSSearchRemove, "version", []string{"1.25"})
55 58
 	flags.Var(newListOptsVar(), flagHostRemove, "Remove a custom host-to-IP mapping (host:ip)")
59
+	flags.SetAnnotation(flagHostRemove, "version", []string{"1.25"})
56 60
 	flags.Var(&serviceOpts.labels, flagLabelAdd, "Add or update a service label")
57 61
 	flags.Var(&serviceOpts.containerLabels, flagContainerLabelAdd, "Add or update a container label")
58 62
 	flags.Var(&serviceOpts.env, flagEnvAdd, "Add or update an environment variable")
59 63
 	flags.Var(newListOptsVar(), flagSecretRemove, "Remove a secret")
64
+	flags.SetAnnotation(flagSecretRemove, "version", []string{"1.25"})
60 65
 	flags.Var(&serviceOpts.secrets, flagSecretAdd, "Add or update a secret on a service")
66
+	flags.SetAnnotation(flagSecretAdd, "version", []string{"1.25"})
61 67
 	flags.Var(&serviceOpts.mounts, flagMountAdd, "Add or update a mount on a service")
62 68
 	flags.Var(&serviceOpts.constraints, flagConstraintAdd, "Add or update a placement constraint")
63 69
 	flags.Var(&serviceOpts.endpoint.publishPorts, flagPublishAdd, "Add or update a published port")
64 70
 	flags.Var(&serviceOpts.groups, flagGroupAdd, "Add an additional supplementary user group to the container")
71
+	flags.SetAnnotation(flagGroupAdd, "version", []string{"1.25"})
65 72
 	flags.Var(&serviceOpts.dns, flagDNSAdd, "Add or update a custom DNS server")
73
+	flags.SetAnnotation(flagDNSAdd, "version", []string{"1.25"})
66 74
 	flags.Var(&serviceOpts.dnsOption, flagDNSOptionAdd, "Add or update a DNS option")
75
+	flags.SetAnnotation(flagDNSOptionAdd, "version", []string{"1.25"})
67 76
 	flags.Var(&serviceOpts.dnsSearch, flagDNSSearchAdd, "Add or update a custom DNS search domain")
77
+	flags.SetAnnotation(flagDNSSearchAdd, "version", []string{"1.25"})
68 78
 	flags.Var(&serviceOpts.hosts, flagHostAdd, "Add or update a custom host-to-IP mapping (host:ip)")
79
+	flags.SetAnnotation(flagHostAdd, "version", []string{"1.25"})
69 80
 
70 81
 	return cmd
71 82
 }
... ...
@@ -11,6 +11,7 @@ import (
11 11
 
12 12
 func addComposefileFlag(opt *string, flags *pflag.FlagSet) {
13 13
 	flags.StringVarP(opt, "compose-file", "c", "", "Path to a Compose file")
14
+	flags.SetAnnotation("compose-file", "version", []string{"1.25"})
14 15
 }
15 16
 
16 17
 func addBundlefileFlag(opt *string, flags *pflag.FlagSet) {
... ...
@@ -176,7 +176,9 @@ func addSwarmFlags(flags *pflag.FlagSet, opts *swarmOptions) {
176 176
 	flags.DurationVar(&opts.nodeCertExpiry, flagCertExpiry, time.Duration(90*24*time.Hour), "Validity period for node certificates (ns|us|ms|s|m|h)")
177 177
 	flags.Var(&opts.externalCA, flagExternalCA, "Specifications of one or more certificate signing endpoints")
178 178
 	flags.Uint64Var(&opts.maxSnapshots, flagMaxSnapshots, 0, "Number of additional Raft snapshots to retain")
179
+	flags.SetAnnotation(flagMaxSnapshots, "version", []string{"1.25"})
179 180
 	flags.Uint64Var(&opts.snapshotInterval, flagSnapshotInterval, 10000, "Number of log entries between Raft snapshots")
181
+	flags.SetAnnotation(flagSnapshotInterval, "version", []string{"1.25"})
180 182
 }
181 183
 
182 184
 func (opts *swarmOptions) mergeSwarmSpec(spec *swarm.Spec, flags *pflag.FlagSet) {