From 2827d037baee02889bc9a926755ddc6e39c00935 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 30 Aug 2025 11:57:03 +0200 Subject: [PATCH] cli/command/completion: deprecate NoComplete This function was an exact duplicate of [cobra.NoFileCompletions], so deprecating it in favor of that. [cobra.NoFileCompletions]: https://pkg.go.dev/github.com/spf13/cobra@v1.9.1#NoFileCompletions Signed-off-by: Sebastiaan van Stijn --- cli/command/builder/prune.go | 3 +-- cli/command/checkpoint/create.go | 3 +-- cli/command/completion/functions.go | 4 +++- cli/command/completion/functions_test.go | 6 ------ cli/command/config/create.go | 3 +-- cli/command/config/ls.go | 3 +-- cli/command/container/create.go | 2 +- cli/command/container/list.go | 3 +-- cli/command/container/prune.go | 3 +-- cli/command/container/run.go | 2 +- cli/command/context/create.go | 3 +-- cli/command/context/list.go | 3 +-- cli/command/context/show.go | 3 +-- cli/command/image/load.go | 2 +- cli/command/image/prune.go | 3 +-- cli/command/image/pull.go | 2 +- cli/command/network/create.go | 3 +-- cli/command/network/list.go | 3 +-- cli/command/node/list.go | 5 ++--- cli/command/node/ps.go | 3 +-- cli/command/node/update.go | 2 +- cli/command/plugin/create.go | 3 +-- cli/command/plugin/list.go | 3 +-- cli/command/registry/login.go | 3 +-- cli/command/service/create.go | 4 ++-- cli/command/service/inspect.go | 3 +-- cli/command/service/list.go | 5 ++--- cli/command/service/logs.go | 3 +-- cli/command/service/ps.go | 3 +-- cli/command/service/rollback.go | 3 +-- cli/command/service/update.go | 2 +- cli/command/stack/config.go | 3 +-- cli/command/stack/list.go | 3 +-- cli/command/swarm/ca.go | 3 +-- cli/command/swarm/init.go | 3 +-- cli/command/swarm/leave.go | 3 +-- cli/command/swarm/unlock.go | 3 +-- cli/command/swarm/unlock_key.go | 3 +-- cli/command/swarm/update.go | 3 +-- cli/command/system/df.go | 3 +-- cli/command/system/dial_stdio.go | 3 +-- cli/command/system/events.go | 3 +-- cli/command/system/info.go | 3 +-- cli/command/system/inspect.go | 4 ++-- cli/command/system/prune.go | 3 +-- cli/command/system/version.go | 3 +-- cli/command/volume/create.go | 3 +-- cli/command/volume/list.go | 3 +-- cli/command/volume/prune.go | 3 +-- 49 files changed, 54 insertions(+), 97 deletions(-) diff --git a/cli/command/builder/prune.go b/cli/command/builder/prune.go index 1e9e423139..495a2cb95e 100644 --- a/cli/command/builder/prune.go +++ b/cli/command/builder/prune.go @@ -8,7 +8,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/system/pruner" "github.com/docker/cli/internal/prompt" "github.com/docker/cli/opts" @@ -52,7 +51,7 @@ func newPruneCommand(dockerCLI command.Cli) *cobra.Command { return nil }, Annotations: map[string]string{"version": "1.39"}, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() diff --git a/cli/command/checkpoint/create.go b/cli/command/checkpoint/create.go index d87f79b553..cd9e663b59 100644 --- a/cli/command/checkpoint/create.go +++ b/cli/command/checkpoint/create.go @@ -6,7 +6,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/moby/moby/api/types/checkpoint" "github.com/spf13/cobra" ) @@ -30,7 +29,7 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command { opts.checkpoint = args[1] return runCreate(cmd.Context(), dockerCli, opts) }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() diff --git a/cli/command/completion/functions.go b/cli/command/completion/functions.go index 8b12d37f88..3da2bc7c96 100644 --- a/cli/command/completion/functions.go +++ b/cli/command/completion/functions.go @@ -138,7 +138,9 @@ func FileNames(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCom return nil, cobra.ShellCompDirectiveDefault } -// NoComplete is used for commands where there's no relevant completion +// NoComplete is used for commands where there's no relevant completion. +// +// Deprecated: use [cobra.NoFileCompletions]. This function will be removed in the next release. func NoComplete(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) { return nil, cobra.ShellCompDirectiveNoFileComp } diff --git a/cli/command/completion/functions_test.go b/cli/command/completion/functions_test.go index ead28c6173..5c3fbffa39 100644 --- a/cli/command/completion/functions_test.go +++ b/cli/command/completion/functions_test.go @@ -288,12 +288,6 @@ func TestCompleteNetworkNames(t *testing.T) { } } -func TestCompleteNoComplete(t *testing.T) { - values, directives := NoComplete(nil, nil, "") - assert.Check(t, is.Equal(directives, cobra.ShellCompDirectiveNoFileComp)) - assert.Check(t, is.Len(values, 0)) -} - func TestCompletePlatforms(t *testing.T) { values, directives := Platforms(nil, nil, "") assert.Check(t, is.Equal(directives&cobra.ShellCompDirectiveNoFileComp, cobra.ShellCompDirectiveNoFileComp), "Should not perform file completion") diff --git a/cli/command/config/create.go b/cli/command/config/create.go index c6f66a30f6..4b2eaafbfe 100644 --- a/cli/command/config/create.go +++ b/cli/command/config/create.go @@ -8,7 +8,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/opts" "github.com/moby/moby/api/types/swarm" "github.com/moby/sys/sequential" @@ -37,7 +36,7 @@ func newConfigCreateCommand(dockerCLI command.Cli) *cobra.Command { createOpts.file = args[1] return runCreate(cmd.Context(), dockerCLI, createOpts) }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() flags.VarP(&createOpts.labels, "label", "l", "Config labels") diff --git a/cli/command/config/ls.go b/cli/command/config/ls.go index 1547389498..82d7b519fe 100644 --- a/cli/command/config/ls.go +++ b/cli/command/config/ls.go @@ -6,7 +6,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/formatter" flagsHelper "github.com/docker/cli/cli/flags" "github.com/docker/cli/opts" @@ -33,7 +32,7 @@ func newConfigListCommand(dockerCLI command.Cli) *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { return runList(cmd.Context(), dockerCLI, listOpts) }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() diff --git a/cli/command/container/create.go b/cli/command/container/create.go index 2e5361423e..dbf5bdc16e 100644 --- a/cli/command/container/create.go +++ b/cli/command/container/create.go @@ -98,7 +98,7 @@ func newCreateCommand(dockerCLI command.Cli) *cobra.Command { // Set a default completion function if none was set. We don't look // up if it does already have one set, because Cobra does this for // us, and returns an error (which we ignore for this reason). - _ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete) + _ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions) }) return cmd diff --git a/cli/command/container/list.go b/cli/command/container/list.go index 077116dac5..f57d25adf9 100644 --- a/cli/command/container/list.go +++ b/cli/command/container/list.go @@ -6,7 +6,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/formatter" flagsHelper "github.com/docker/cli/cli/flags" "github.com/docker/cli/opts" @@ -44,7 +43,7 @@ func newPsCommand(dockerCLI command.Cli) *cobra.Command { "category-top": "3", "aliases": "docker container ls, docker container list, docker container ps, docker ps", }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() diff --git a/cli/command/container/prune.go b/cli/command/container/prune.go index 546b5eb0a1..1162ac1749 100644 --- a/cli/command/container/prune.go +++ b/cli/command/container/prune.go @@ -6,7 +6,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/system/pruner" "github.com/docker/cli/internal/prompt" "github.com/docker/cli/opts" @@ -47,7 +46,7 @@ func newPruneCommand(dockerCLI command.Cli) *cobra.Command { return nil }, Annotations: map[string]string{"version": "1.25"}, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() diff --git a/cli/command/container/run.go b/cli/command/container/run.go index a12a01b0fe..a2211450ab 100644 --- a/cli/command/container/run.go +++ b/cli/command/container/run.go @@ -78,7 +78,7 @@ func newRunCommand(dockerCLI command.Cli) *cobra.Command { // Set a default completion function if none was set. We don't look // up if it does already have one set, because Cobra does this for // us, and returns an error (which we ignore for this reason). - _ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete) + _ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions) }) return cmd diff --git a/cli/command/context/create.go b/cli/command/context/create.go index 308aa87200..0e1c649c4a 100644 --- a/cli/command/context/create.go +++ b/cli/command/context/create.go @@ -11,7 +11,6 @@ import ( "github.com/containerd/errdefs" "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/formatter/tabwriter" "github.com/docker/cli/cli/context/docker" "github.com/docker/cli/cli/context/store" @@ -54,7 +53,7 @@ func newCreateCommand(dockerCLI command.Cli) *cobra.Command { return RunCreate(dockerCLI, opts) }, Long: longCreateDescription(), - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() flags.StringVar(&opts.Description, "description", "", "Description of the context") diff --git a/cli/command/context/list.go b/cli/command/context/list.go index 450b318f1d..dbfe93bf3c 100644 --- a/cli/command/context/list.go +++ b/cli/command/context/list.go @@ -10,7 +10,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/formatter" "github.com/docker/cli/cli/context/docker" flagsHelper "github.com/docker/cli/cli/flags" @@ -34,7 +33,7 @@ func newListCommand(dockerCli command.Cli) *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { return runList(dockerCli, opts) }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() diff --git a/cli/command/context/show.go b/cli/command/context/show.go index dd33f9e02a..d5e4a828e3 100644 --- a/cli/command/context/show.go +++ b/cli/command/context/show.go @@ -5,7 +5,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/spf13/cobra" ) @@ -19,7 +18,7 @@ func newShowCommand(dockerCli command.Cli) *cobra.Command { runShow(dockerCli) return nil }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } return cmd } diff --git a/cli/command/image/load.go b/cli/command/image/load.go index bc8a8b0ee2..572f335a63 100644 --- a/cli/command/image/load.go +++ b/cli/command/image/load.go @@ -36,7 +36,7 @@ func newLoadCommand(dockerCLI command.Cli) *cobra.Command { Annotations: map[string]string{ "aliases": "docker image load, docker load", }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() diff --git a/cli/command/image/prune.go b/cli/command/image/prune.go index 7a3a6523cd..790abefa13 100644 --- a/cli/command/image/prune.go +++ b/cli/command/image/prune.go @@ -8,7 +8,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/system/pruner" "github.com/docker/cli/internal/prompt" "github.com/docker/cli/opts" @@ -50,7 +49,7 @@ func newPruneCommand(dockerCLI command.Cli) *cobra.Command { return nil }, Annotations: map[string]string{"version": "1.25"}, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() diff --git a/cli/command/image/pull.go b/cli/command/image/pull.go index e30a5f9482..ce441ba235 100644 --- a/cli/command/image/pull.go +++ b/cli/command/image/pull.go @@ -38,7 +38,7 @@ func newPullCommand(dockerCLI command.Cli) *cobra.Command { "category-top": "5", "aliases": "docker image pull, docker pull", }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() diff --git a/cli/command/network/create.go b/cli/command/network/create.go index e822e74177..26988ab13e 100644 --- a/cli/command/network/create.go +++ b/cli/command/network/create.go @@ -10,7 +10,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/opts" "github.com/moby/moby/api/types/network" "github.com/moby/moby/client" @@ -69,7 +68,7 @@ func newCreateCommand(dockerCLI command.Cli) *cobra.Command { return runCreate(cmd.Context(), dockerCLI.Client(), dockerCLI.Out(), options) }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() diff --git a/cli/command/network/list.go b/cli/command/network/list.go index 6ebd6e21b6..eb412d83e5 100644 --- a/cli/command/network/list.go +++ b/cli/command/network/list.go @@ -6,7 +6,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/formatter" flagsHelper "github.com/docker/cli/cli/flags" "github.com/docker/cli/opts" @@ -33,7 +32,7 @@ func newListCommand(dockerCli command.Cli) *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { return runList(cmd.Context(), dockerCli, options) }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() diff --git a/cli/command/node/list.go b/cli/command/node/list.go index 4acbb21588..b5737cfad0 100644 --- a/cli/command/node/list.go +++ b/cli/command/node/list.go @@ -6,7 +6,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/formatter" flagsHelper "github.com/docker/cli/cli/flags" "github.com/docker/cli/opts" @@ -34,7 +33,7 @@ func newListCommand(dockerCli command.Cli) *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { return runList(cmd.Context(), dockerCli, options) }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() flags.BoolVarP(&options.quiet, "quiet", "q", false, "Only display IDs") @@ -45,7 +44,7 @@ func newListCommand(dockerCli command.Cli) *cobra.Command { // Set a default completion function if none was set. We don't look // up if it does already have one set, because Cobra does this for // us, and returns an error (which we ignore for this reason). - _ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete) + _ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions) }) return cmd } diff --git a/cli/command/node/ps.go b/cli/command/node/ps.go index 52ebc586f3..85a286c985 100644 --- a/cli/command/node/ps.go +++ b/cli/command/node/ps.go @@ -6,7 +6,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/idresolver" "github.com/docker/cli/cli/command/task" "github.com/docker/cli/opts" @@ -55,7 +54,7 @@ func newPsCommand(dockerCli command.Cli) *cobra.Command { // Set a default completion function if none was set. We don't look // up if it does already have one set, because Cobra does this for // us, and returns an error (which we ignore for this reason). - _ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete) + _ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions) }) return cmd } diff --git a/cli/command/node/update.go b/cli/command/node/update.go index 19af5458aa..fadae9cd89 100644 --- a/cli/command/node/update.go +++ b/cli/command/node/update.go @@ -43,7 +43,7 @@ func newUpdateCommand(dockerCli command.Cli) *cobra.Command { // Set a default completion function if none was set. We don't look // up if it does already have one set, because Cobra does this for // us, and returns an error (which we ignore for this reason). - _ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete) + _ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions) }) return cmd } diff --git a/cli/command/plugin/create.go b/cli/command/plugin/create.go index 1b3807ba16..96e62ae036 100644 --- a/cli/command/plugin/create.go +++ b/cli/command/plugin/create.go @@ -10,7 +10,6 @@ import ( "github.com/distribution/reference" "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/moby/go-archive" "github.com/moby/go-archive/compression" "github.com/moby/moby/api/types/plugin" @@ -77,7 +76,7 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command { options.context = args[1] return runCreate(cmd.Context(), dockerCli, options) }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() diff --git a/cli/command/plugin/list.go b/cli/command/plugin/list.go index da08a06f95..8552167146 100644 --- a/cli/command/plugin/list.go +++ b/cli/command/plugin/list.go @@ -6,7 +6,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/formatter" flagsHelper "github.com/docker/cli/cli/flags" "github.com/docker/cli/opts" @@ -32,7 +31,7 @@ func newListCommand(dockerCli command.Cli) *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { return runList(cmd.Context(), dockerCli, options) }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() diff --git a/cli/command/registry/login.go b/cli/command/registry/login.go index a507a4dd2d..be07683308 100644 --- a/cli/command/registry/login.go +++ b/cli/command/registry/login.go @@ -12,7 +12,6 @@ import ( "github.com/containerd/errdefs" "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/config/configfile" configtypes "github.com/docker/cli/cli/config/types" "github.com/docker/cli/internal/commands" @@ -57,7 +56,7 @@ func newLoginCommand(dockerCLI command.Cli) *cobra.Command { Annotations: map[string]string{ "category-top": "8", }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() diff --git a/cli/command/service/create.go b/cli/command/service/create.go index 3f54193d5e..05e81f16ee 100644 --- a/cli/command/service/create.go +++ b/cli/command/service/create.go @@ -29,7 +29,7 @@ func newCreateCommand(dockerCLI command.Cli) *cobra.Command { } return runCreate(cmd.Context(), dockerCLI, cmd.Flags(), opts) }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() flags.StringVar(&opts.mode, flagMode, "replicated", `Service mode ("replicated", "global", "replicated-job", "global-job")`) @@ -94,7 +94,7 @@ func newCreateCommand(dockerCLI command.Cli) *cobra.Command { // Set a default completion function if none was set. We don't look // up if it does already have one set, because Cobra does this for // us, and returns an error (which we ignore for this reason). - _ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete) + _ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions) }) return cmd } diff --git a/cli/command/service/inspect.go b/cli/command/service/inspect.go index f144fe9de2..224d94c245 100644 --- a/cli/command/service/inspect.go +++ b/cli/command/service/inspect.go @@ -10,7 +10,6 @@ import ( "github.com/containerd/errdefs" "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/formatter" flagsHelper "github.com/docker/cli/cli/flags" "github.com/moby/moby/client" @@ -51,7 +50,7 @@ func newInspectCommand(dockerCli command.Cli) *cobra.Command { // Set a default completion function if none was set. We don't look // up if it does already have one set, because Cobra does this for // us, and returns an error (which we ignore for this reason). - _ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete) + _ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions) }) return cmd } diff --git a/cli/command/service/list.go b/cli/command/service/list.go index 479dbb1259..8db8fbaff3 100644 --- a/cli/command/service/list.go +++ b/cli/command/service/list.go @@ -5,7 +5,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/formatter" flagsHelper "github.com/docker/cli/cli/flags" "github.com/docker/cli/opts" @@ -33,7 +32,7 @@ func newListCommand(dockerCLI command.Cli) *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { return runList(cmd.Context(), dockerCLI, options) }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() @@ -45,7 +44,7 @@ func newListCommand(dockerCLI command.Cli) *cobra.Command { // Set a default completion function if none was set. We don't look // up if it does already have one set, because Cobra does this for // us, and returns an error (which we ignore for this reason). - _ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete) + _ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions) }) return cmd } diff --git a/cli/command/service/logs.go b/cli/command/service/logs.go index ef9916a154..a9b3c2323e 100644 --- a/cli/command/service/logs.go +++ b/cli/command/service/logs.go @@ -12,7 +12,6 @@ import ( "github.com/containerd/errdefs" "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/formatter" "github.com/docker/cli/cli/command/idresolver" "github.com/docker/cli/internal/logdetails" @@ -73,7 +72,7 @@ func newLogsCommand(dockerCli command.Cli) *cobra.Command { // Set a default completion function if none was set. We don't look // up if it does already have one set, because Cobra does this for // us, and returns an error (which we ignore for this reason). - _ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete) + _ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions) }) return cmd } diff --git a/cli/command/service/ps.go b/cli/command/service/ps.go index cbde36e06a..b7e4fdd4cf 100644 --- a/cli/command/service/ps.go +++ b/cli/command/service/ps.go @@ -6,7 +6,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/idresolver" "github.com/docker/cli/cli/command/node" "github.com/docker/cli/cli/command/task" @@ -51,7 +50,7 @@ func newPsCommand(dockerCli command.Cli) *cobra.Command { // Set a default completion function if none was set. We don't look // up if it does already have one set, because Cobra does this for // us, and returns an error (which we ignore for this reason). - _ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete) + _ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions) }) return cmd } diff --git a/cli/command/service/rollback.go b/cli/command/service/rollback.go index 37d544f5ed..935ca632b3 100644 --- a/cli/command/service/rollback.go +++ b/cli/command/service/rollback.go @@ -6,7 +6,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/moby/moby/api/types/versions" "github.com/moby/moby/client" "github.com/spf13/cobra" @@ -35,7 +34,7 @@ func newRollbackCommand(dockerCli command.Cli) *cobra.Command { // Set a default completion function if none was set. We don't look // up if it does already have one set, because Cobra does this for // us, and returns an error (which we ignore for this reason). - _ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete) + _ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions) }) return cmd } diff --git a/cli/command/service/update.go b/cli/command/service/update.go index c084204c00..54f6a7f381 100644 --- a/cli/command/service/update.go +++ b/cli/command/service/update.go @@ -136,7 +136,7 @@ func newUpdateCommand(dockerCLI command.Cli) *cobra.Command { // Set a default completion function if none was set. We don't look // up if it does already have one set, because Cobra does this for // us, and returns an error (which we ignore for this reason). - _ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete) + _ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions) }) return cmd diff --git a/cli/command/stack/config.go b/cli/command/stack/config.go index 045db77b5f..9af8acf103 100644 --- a/cli/command/stack/config.go +++ b/cli/command/stack/config.go @@ -6,7 +6,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/stack/loader" "github.com/docker/cli/cli/command/stack/options" composeLoader "github.com/docker/cli/cli/compose/loader" @@ -36,7 +35,7 @@ func newConfigCommand(dockerCli command.Cli) *cobra.Command { _, err = fmt.Fprintf(dockerCli.Out(), "%s", cfg) return err }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() diff --git a/cli/command/stack/list.go b/cli/command/stack/list.go index 3306a51b80..084b6aab3c 100644 --- a/cli/command/stack/list.go +++ b/cli/command/stack/list.go @@ -7,7 +7,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/stack/formatter" "github.com/docker/cli/cli/command/stack/swarm" flagsHelper "github.com/docker/cli/cli/flags" @@ -31,7 +30,7 @@ func newListCommand(dockerCLI command.Cli) *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { return runList(cmd.Context(), dockerCLI, opts) }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() diff --git a/cli/command/swarm/ca.go b/cli/command/swarm/ca.go index 64e8fc36d7..8cc9e7b612 100644 --- a/cli/command/swarm/ca.go +++ b/cli/command/swarm/ca.go @@ -8,7 +8,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/swarm/progress" "github.com/docker/cli/internal/jsonstream" "github.com/moby/moby/api/types/swarm" @@ -41,7 +40,7 @@ func newCACommand(dockerCli command.Cli) *cobra.Command { "version": "1.30", "swarm": "manager", }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() diff --git a/cli/command/swarm/init.go b/cli/command/swarm/init.go index 9334fda3db..0ef00d9454 100644 --- a/cli/command/swarm/init.go +++ b/cli/command/swarm/init.go @@ -8,7 +8,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/moby/moby/api/types/swarm" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -44,7 +43,7 @@ func newInitCommand(dockerCli command.Cli) *cobra.Command { "version": "1.24", "swarm": "", // swarm init does not require swarm to be active, and is always available on API 1.24 and up }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() diff --git a/cli/command/swarm/leave.go b/cli/command/swarm/leave.go index 28c8d603aa..335dbb0042 100644 --- a/cli/command/swarm/leave.go +++ b/cli/command/swarm/leave.go @@ -6,7 +6,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/spf13/cobra" ) @@ -28,7 +27,7 @@ func newLeaveCommand(dockerCli command.Cli) *cobra.Command { "version": "1.24", "swarm": "active", }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() diff --git a/cli/command/swarm/unlock.go b/cli/command/swarm/unlock.go index ba60f641e4..370384da97 100644 --- a/cli/command/swarm/unlock.go +++ b/cli/command/swarm/unlock.go @@ -9,7 +9,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/streams" "github.com/moby/moby/api/types/swarm" "github.com/pkg/errors" @@ -29,7 +28,7 @@ func newUnlockCommand(dockerCli command.Cli) *cobra.Command { "version": "1.24", "swarm": "manager", }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } return cmd diff --git a/cli/command/swarm/unlock_key.go b/cli/command/swarm/unlock_key.go index c60ebe0ad6..ea7505e0bd 100644 --- a/cli/command/swarm/unlock_key.go +++ b/cli/command/swarm/unlock_key.go @@ -7,7 +7,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/moby/moby/client" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -32,7 +31,7 @@ func newUnlockKeyCommand(dockerCli command.Cli) *cobra.Command { "version": "1.24", "swarm": "manager", }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() diff --git a/cli/command/swarm/update.go b/cli/command/swarm/update.go index a1ab47209a..2940227701 100644 --- a/cli/command/swarm/update.go +++ b/cli/command/swarm/update.go @@ -6,7 +6,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/moby/moby/client" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -33,7 +32,7 @@ func newUpdateCommand(dockerCli command.Cli) *cobra.Command { "version": "1.24", "swarm": "manager", }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } cmd.Flags().BoolVar(&opts.autolock, flagAutolock, false, "Change manager autolocking setting (true|false)") diff --git a/cli/command/system/df.go b/cli/command/system/df.go index e0e7da959c..0e8b133cd1 100644 --- a/cli/command/system/df.go +++ b/cli/command/system/df.go @@ -5,7 +5,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/formatter" flagsHelper "github.com/docker/cli/cli/flags" "github.com/moby/moby/client" @@ -29,7 +28,7 @@ func newDiskUsageCommand(dockerCli command.Cli) *cobra.Command { return runDiskUsage(cmd.Context(), dockerCli, opts) }, Annotations: map[string]string{"version": "1.25"}, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() diff --git a/cli/command/system/dial_stdio.go b/cli/command/system/dial_stdio.go index c8ccd181c7..fc1cbee27a 100644 --- a/cli/command/system/dial_stdio.go +++ b/cli/command/system/dial_stdio.go @@ -7,7 +7,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -23,7 +22,7 @@ func newDialStdioCommand(dockerCli command.Cli) *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { return runDialStdio(cmd.Context(), dockerCli) }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } return cmd } diff --git a/cli/command/system/events.go b/cli/command/system/events.go index ebd0e7f9a3..9b7b0cd3a8 100644 --- a/cli/command/system/events.go +++ b/cli/command/system/events.go @@ -11,7 +11,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/formatter" flagsHelper "github.com/docker/cli/cli/flags" "github.com/docker/cli/opts" @@ -42,7 +41,7 @@ func newEventsCommand(dockerCLI command.Cli) *cobra.Command { Annotations: map[string]string{ "aliases": "docker system events, docker events", }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() diff --git a/cli/command/system/info.go b/cli/command/system/info.go index 884643dd3c..6b04c5bf94 100644 --- a/cli/command/system/info.go +++ b/cli/command/system/info.go @@ -14,7 +14,6 @@ import ( "github.com/docker/cli/cli" pluginmanager "github.com/docker/cli/cli-plugins/manager" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/formatter" "github.com/docker/cli/cli/debug" flagsHelper "github.com/docker/cli/cli/flags" @@ -74,7 +73,7 @@ func newInfoCommand(dockerCLI command.Cli) *cobra.Command { "category-top": "12", "aliases": "docker system info, docker info", }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } cmd.Flags().StringVarP(&opts.format, "format", "f", "", flagsHelper.InspectFormatHelp) diff --git a/cli/command/system/inspect.go b/cli/command/system/inspect.go index 64d47b9168..4a54f78a1a 100644 --- a/cli/command/system/inspect.go +++ b/cli/command/system/inspect.go @@ -73,7 +73,7 @@ func newInspectCommand(dockerCLI command.Cli) *cobra.Command { return runInspect(cmd.Context(), dockerCLI, opts) }, // TODO(thaJeztah): should we consider adding completion for common object-types? (images, containers?) - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() @@ -86,7 +86,7 @@ func newInspectCommand(dockerCLI command.Cli) *cobra.Command { // Set a default completion function if none was set. We don't look // up if it does already have one set, because Cobra does this for // us, and returns an error (which we ignore for this reason). - _ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete) + _ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions) }) return cmd } diff --git a/cli/command/system/prune.go b/cli/command/system/prune.go index c6e77f41e6..30451e0a1d 100644 --- a/cli/command/system/prune.go +++ b/cli/command/system/prune.go @@ -11,7 +11,6 @@ import ( "github.com/containerd/errdefs" "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/system/pruner" "github.com/docker/cli/internal/prompt" "github.com/docker/cli/opts" @@ -39,7 +38,7 @@ func newPruneCommand(dockerCli command.Cli) *cobra.Command { return runPrune(cmd.Context(), dockerCli, options) }, Annotations: map[string]string{"version": "1.25"}, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() diff --git a/cli/command/system/version.go b/cli/command/system/version.go index 81753dcba1..b883f358dc 100644 --- a/cli/command/system/version.go +++ b/cli/command/system/version.go @@ -11,7 +11,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/formatter" "github.com/docker/cli/cli/command/formatter/tabwriter" flagsHelper "github.com/docker/cli/cli/flags" @@ -123,7 +122,7 @@ func newVersionCommand(dockerCLI command.Cli) *cobra.Command { Annotations: map[string]string{ "category-top": "10", }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } cmd.Flags().StringVarP(&opts.format, "format", "f", "", flagsHelper.InspectFormatHelp) diff --git a/cli/command/volume/create.go b/cli/command/volume/create.go index 44e52eec16..a1ca9b3392 100644 --- a/cli/command/volume/create.go +++ b/cli/command/volume/create.go @@ -9,7 +9,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/opts" "github.com/moby/moby/api/types/volume" "github.com/spf13/cobra" @@ -59,7 +58,7 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command { options.cluster = hasClusterVolumeOptionSet(cmd.Flags()) return runCreate(cmd.Context(), dockerCli, options) }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() flags.StringVarP(&options.driver, "driver", "d", "local", "Specify volume driver name") diff --git a/cli/command/volume/list.go b/cli/command/volume/list.go index 3580dad85f..d8ff3ac820 100644 --- a/cli/command/volume/list.go +++ b/cli/command/volume/list.go @@ -6,7 +6,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/formatter" flagsHelper "github.com/docker/cli/cli/flags" "github.com/docker/cli/opts" @@ -37,7 +36,7 @@ func newListCommand(dockerCli command.Cli) *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { return runList(cmd.Context(), dockerCli, options) }, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags() diff --git a/cli/command/volume/prune.go b/cli/command/volume/prune.go index 8d5965ef2a..d3d1c6b1c7 100644 --- a/cli/command/volume/prune.go +++ b/cli/command/volume/prune.go @@ -7,7 +7,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" - "github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/system/pruner" "github.com/docker/cli/internal/prompt" "github.com/docker/cli/opts" @@ -49,7 +48,7 @@ func newPruneCommand(dockerCLI command.Cli) *cobra.Command { return nil }, Annotations: map[string]string{"version": "1.25"}, - ValidArgsFunction: completion.NoComplete, + ValidArgsFunction: cobra.NoFileCompletions, } flags := cmd.Flags()