Skip to content

Commit ba21666

Browse files
authored
Merge pull request #6404 from thaJeztah/deprecate_nocomplete
cli/command/completion: deprecate NoComplete
2 parents 321100e + 2827d03 commit ba21666

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+54
-97
lines changed

cli/command/builder/prune.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88

99
"github.com/docker/cli/cli"
1010
"github.com/docker/cli/cli/command"
11-
"github.com/docker/cli/cli/command/completion"
1211
"github.com/docker/cli/cli/command/system/pruner"
1312
"github.com/docker/cli/internal/prompt"
1413
"github.com/docker/cli/opts"
@@ -52,7 +51,7 @@ func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
5251
return nil
5352
},
5453
Annotations: map[string]string{"version": "1.39"},
55-
ValidArgsFunction: completion.NoComplete,
54+
ValidArgsFunction: cobra.NoFileCompletions,
5655
}
5756

5857
flags := cmd.Flags()

cli/command/checkpoint/create.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66

77
"github.com/docker/cli/cli"
88
"github.com/docker/cli/cli/command"
9-
"github.com/docker/cli/cli/command/completion"
109
"github.com/moby/moby/api/types/checkpoint"
1110
"github.com/spf13/cobra"
1211
)
@@ -30,7 +29,7 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command {
3029
opts.checkpoint = args[1]
3130
return runCreate(cmd.Context(), dockerCli, opts)
3231
},
33-
ValidArgsFunction: completion.NoComplete,
32+
ValidArgsFunction: cobra.NoFileCompletions,
3433
}
3534

3635
flags := cmd.Flags()

cli/command/completion/functions.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ func FileNames(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCom
138138
return nil, cobra.ShellCompDirectiveDefault
139139
}
140140

141-
// NoComplete is used for commands where there's no relevant completion
141+
// NoComplete is used for commands where there's no relevant completion.
142+
//
143+
// Deprecated: use [cobra.NoFileCompletions]. This function will be removed in the next release.
142144
func NoComplete(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
143145
return nil, cobra.ShellCompDirectiveNoFileComp
144146
}

cli/command/completion/functions_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,6 @@ func TestCompleteNetworkNames(t *testing.T) {
288288
}
289289
}
290290

291-
func TestCompleteNoComplete(t *testing.T) {
292-
values, directives := NoComplete(nil, nil, "")
293-
assert.Check(t, is.Equal(directives, cobra.ShellCompDirectiveNoFileComp))
294-
assert.Check(t, is.Len(values, 0))
295-
}
296-
297291
func TestCompletePlatforms(t *testing.T) {
298292
values, directives := Platforms(nil, nil, "")
299293
assert.Check(t, is.Equal(directives&cobra.ShellCompDirectiveNoFileComp, cobra.ShellCompDirectiveNoFileComp), "Should not perform file completion")

cli/command/config/create.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88

99
"github.com/docker/cli/cli"
1010
"github.com/docker/cli/cli/command"
11-
"github.com/docker/cli/cli/command/completion"
1211
"github.com/docker/cli/opts"
1312
"github.com/moby/moby/api/types/swarm"
1413
"github.com/moby/sys/sequential"
@@ -37,7 +36,7 @@ func newConfigCreateCommand(dockerCLI command.Cli) *cobra.Command {
3736
createOpts.file = args[1]
3837
return runCreate(cmd.Context(), dockerCLI, createOpts)
3938
},
40-
ValidArgsFunction: completion.NoComplete,
39+
ValidArgsFunction: cobra.NoFileCompletions,
4140
}
4241
flags := cmd.Flags()
4342
flags.VarP(&createOpts.labels, "label", "l", "Config labels")

cli/command/config/ls.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66

77
"github.com/docker/cli/cli"
88
"github.com/docker/cli/cli/command"
9-
"github.com/docker/cli/cli/command/completion"
109
"github.com/docker/cli/cli/command/formatter"
1110
flagsHelper "github.com/docker/cli/cli/flags"
1211
"github.com/docker/cli/opts"
@@ -33,7 +32,7 @@ func newConfigListCommand(dockerCLI command.Cli) *cobra.Command {
3332
RunE: func(cmd *cobra.Command, args []string) error {
3433
return runList(cmd.Context(), dockerCLI, listOpts)
3534
},
36-
ValidArgsFunction: completion.NoComplete,
35+
ValidArgsFunction: cobra.NoFileCompletions,
3736
}
3837

3938
flags := cmd.Flags()

cli/command/container/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func newCreateCommand(dockerCLI command.Cli) *cobra.Command {
9898
// Set a default completion function if none was set. We don't look
9999
// up if it does already have one set, because Cobra does this for
100100
// us, and returns an error (which we ignore for this reason).
101-
_ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete)
101+
_ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions)
102102
})
103103

104104
return cmd

cli/command/container/list.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66

77
"github.com/docker/cli/cli"
88
"github.com/docker/cli/cli/command"
9-
"github.com/docker/cli/cli/command/completion"
109
"github.com/docker/cli/cli/command/formatter"
1110
flagsHelper "github.com/docker/cli/cli/flags"
1211
"github.com/docker/cli/opts"
@@ -44,7 +43,7 @@ func newPsCommand(dockerCLI command.Cli) *cobra.Command {
4443
"category-top": "3",
4544
"aliases": "docker container ls, docker container list, docker container ps, docker ps",
4645
},
47-
ValidArgsFunction: completion.NoComplete,
46+
ValidArgsFunction: cobra.NoFileCompletions,
4847
}
4948

5049
flags := cmd.Flags()

cli/command/container/prune.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66

77
"github.com/docker/cli/cli"
88
"github.com/docker/cli/cli/command"
9-
"github.com/docker/cli/cli/command/completion"
109
"github.com/docker/cli/cli/command/system/pruner"
1110
"github.com/docker/cli/internal/prompt"
1211
"github.com/docker/cli/opts"
@@ -47,7 +46,7 @@ func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
4746
return nil
4847
},
4948
Annotations: map[string]string{"version": "1.25"},
50-
ValidArgsFunction: completion.NoComplete,
49+
ValidArgsFunction: cobra.NoFileCompletions,
5150
}
5251

5352
flags := cmd.Flags()

cli/command/container/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func newRunCommand(dockerCLI command.Cli) *cobra.Command {
7878
// Set a default completion function if none was set. We don't look
7979
// up if it does already have one set, because Cobra does this for
8080
// us, and returns an error (which we ignore for this reason).
81-
_ = cmd.RegisterFlagCompletionFunc(flag.Name, completion.NoComplete)
81+
_ = cmd.RegisterFlagCompletionFunc(flag.Name, cobra.NoFileCompletions)
8282
})
8383

8484
return cmd

0 commit comments

Comments
 (0)