Hide legacy top-level "deploy" command with DOCKER_HIDE_LEGACY_COMMANDS=1

The `DOCKER_HIDE_LEGACY_COMMANDS` environment variable allows hiding legacy
top-level commands that are now available under `docker <object> <verb>`. The
`docker deploy` top-level command is experimental, and replaced by
`docker stack deploy`.

This patch hides the top-level `docker deploy` if the `DOCKER_HIDE_LEGACY_COMMANDS`
environment variable is set.

Before this change:

    DOCKER_HIDE_LEGACY_COMMANDS=1 docker --help

    ...

    Commands:
      build       Build an image from a Dockerfile
      deploy      Deploy a new stack or update an existing stack
      login       Log in to a Docker registry
      logout      Log out from a Docker registry
      run         Run a command in a new container
      search      Search the Docker Hub for images
      version     Show the Docker version information
    ...

With this patch applied:

    DOCKER_HIDE_LEGACY_COMMANDS=1 docker --help

    ...

    Commands:
      build       Build an image from a Dockerfile
      login       Log in to a Docker registry
      logout      Log out from a Docker registry
      run         Run a command in a new container
      search      Search the Docker Hub for images
      version     Show the Docker version information
    ...

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2019-01-07 17:24:35 +01:00
parent 143028e074
commit 4c0aa94698
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 1 additions and 1 deletions

View File

@ -75,7 +75,6 @@ func AddCommands(cmd *cobra.Command, dockerCli command.Cli) {
// stack
stack.NewStackCommand(dockerCli),
stack.NewTopLevelDeployCommand(dockerCli),
// swarm
swarm.NewSwarmCommand(dockerCli),
@ -87,6 +86,7 @@ func AddCommands(cmd *cobra.Command, dockerCli command.Cli) {
volume.NewVolumeCommand(dockerCli),
// legacy commands may be hidden
hide(stack.NewTopLevelDeployCommand(dockerCli)),
hide(system.NewEventsCommand(dockerCli)),
hide(system.NewInfoCommand(dockerCli)),
hide(system.NewInspectCommand(dockerCli)),