completion: add completion for node names

Change completion for nodes to use names by default, and bring back
support for the `DOCKER_COMPLETION_SHOW_NODE_IDS` env-var
f9ced58158/contrib/completion/bash/docker (L38)

With this patch:

    docker node ps <tab>
    docker-desktop            self

    export DOCKER_COMPLETION_SHOW_NODE_IDS=yes
    docker node ps <TAB>
    docker-desktop             qyeriqk20al6hy4y869d08ff5  self

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-02-20 12:31:03 +01:00
parent 762d59359e
commit d5e6e2ec6e
7 changed files with 43 additions and 2 deletions

View File

@ -26,6 +26,7 @@ func newRemoveCommand(dockerCli command.Cli) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
return runRemove(cmd.Context(), dockerCli, args, opts)
},
ValidArgsFunction: completeNodeNames(dockerCli),
}
flags := cmd.Flags()
flags.BoolVarP(&opts.force, "force", "f", false, "Force remove a node from the swarm")