From 91b1ad9d2bb52efc583f40d3ab70b243df76c440 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 30 Jul 2018 10:54:05 +0200 Subject: [PATCH] Add API-version anotation for --data-path-addr This flag was added in Docker 17.06, API version 1.31 through moby@8dc8cd4719f165c01c98e7d3ce1d6cea6a8f60b8, but didn't add API-version annotations. This patch adds the missing annotations to hide this flag if the CLI is connected to an older version of the daemon that doesn't support that API. Before this patch: DOCKER_API_VERSION=1.30 docker swarm init --help | grep data-path-addr --data-path-addr string Address or interface to use for data path traffic (format: ) DOCKER_API_VERSION=1.31 docker swarm init --help | grep data-path-addr --data-path-addr string Address or interface to use for data path traffic (format: ) With this patch applied: DOCKER_API_VERSION=1.30 docker swarm init --help | grep data-path-addr # (no result) DOCKER_API_VERSION=1.31 docker swarm init --help | grep data-path-addr --data-path-addr string Address or interface to use for data path traffic (format: ) Signed-off-by: Sebastiaan van Stijn --- cli/command/swarm/init.go | 1 + cli/command/swarm/join.go | 1 + 2 files changed, 2 insertions(+) diff --git a/cli/command/swarm/init.go b/cli/command/swarm/init.go index d9dadd61af..e820380ca9 100644 --- a/cli/command/swarm/init.go +++ b/cli/command/swarm/init.go @@ -41,6 +41,7 @@ func newInitCommand(dockerCli command.Cli) *cobra.Command { flags.Var(&opts.listenAddr, flagListenAddr, "Listen address (format: [:port])") flags.StringVar(&opts.advertiseAddr, flagAdvertiseAddr, "", "Advertised address (format: [:port])") flags.StringVar(&opts.dataPathAddr, flagDataPathAddr, "", "Address or interface to use for data path traffic (format: )") + flags.SetAnnotation(flagDataPathAddr, "version", []string{"1.31"}) flags.BoolVar(&opts.forceNewCluster, "force-new-cluster", false, "Force create a new cluster from current state") flags.BoolVar(&opts.autolock, flagAutolock, false, "Enable manager autolocking (requiring an unlock key to start a stopped manager)") flags.StringVar(&opts.availability, flagAvailability, "active", `Availability of the node ("active"|"pause"|"drain")`) diff --git a/cli/command/swarm/join.go b/cli/command/swarm/join.go index d794000d95..e6c43f03de 100644 --- a/cli/command/swarm/join.go +++ b/cli/command/swarm/join.go @@ -42,6 +42,7 @@ func newJoinCommand(dockerCli command.Cli) *cobra.Command { flags.Var(&opts.listenAddr, flagListenAddr, "Listen address (format: [:port])") flags.StringVar(&opts.advertiseAddr, flagAdvertiseAddr, "", "Advertised address (format: [:port])") flags.StringVar(&opts.dataPathAddr, flagDataPathAddr, "", "Address or interface to use for data path traffic (format: )") + flags.SetAnnotation(flagDataPathAddr, "version", []string{"1.31"}) flags.StringVar(&opts.token, flagToken, "", "Token for entry into the swarm") flags.StringVar(&opts.availability, flagAvailability, "active", `Availability of the node ("active"|"pause"|"drain")`) return cmd