Skip to content

Commit fbeae85

Browse files
authored
Merge pull request #6405 from thaJeztah/28.x_backport_deprecate_nocomplete
[28.x backport] cli/command/completion: deprecate NoComplete
2 parents d593e61 + 139968d commit fbeae85

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/internal/prompt"
1312
"github.com/docker/cli/opts"
1413
"github.com/docker/docker/api/types/build"
@@ -50,7 +49,7 @@ func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
5049
return nil
5150
},
5251
Annotations: map[string]string{"version": "1.39"},
53-
ValidArgsFunction: completion.NoComplete,
52+
ValidArgsFunction: cobra.NoFileCompletions,
5453
}
5554

5655
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/docker/docker/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
@@ -141,7 +141,9 @@ func FileNames(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCom
141141
return nil, cobra.ShellCompDirectiveDefault
142142
}
143143

144-
// NoComplete is used for commands where there's no relevant completion
144+
// NoComplete is used for commands where there's no relevant completion.
145+
//
146+
// Deprecated: use [cobra.NoFileCompletions]. This function will be removed in the next release.
145147
func NoComplete(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
146148
return nil, cobra.ShellCompDirectiveNoFileComp
147149
}

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
@@ -7,7 +7,6 @@ import (
77

88
"github.com/docker/cli/cli"
99
"github.com/docker/cli/cli/command"
10-
"github.com/docker/cli/cli/command/completion"
1110
"github.com/docker/cli/opts"
1211
"github.com/docker/docker/api/types/swarm"
1312
"github.com/moby/sys/sequential"
@@ -47,7 +46,7 @@ func newConfigCreateCommand(dockerCLI command.Cli) *cobra.Command {
4746
createOpts.file = args[1]
4847
return runCreate(cmd.Context(), dockerCLI, createOpts)
4948
},
50-
ValidArgsFunction: completion.NoComplete,
49+
ValidArgsFunction: cobra.NoFileCompletions,
5150
}
5251
flags := cmd.Flags()
5352
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"
@@ -42,7 +41,7 @@ func newConfigListCommand(dockerCLI command.Cli) *cobra.Command {
4241
RunE: func(cmd *cobra.Command, args []string) error {
4342
return runList(cmd.Context(), dockerCLI, listOpts)
4443
},
45-
ValidArgsFunction: completion.NoComplete,
44+
ValidArgsFunction: cobra.NoFileCompletions,
4645
}
4746

4847
flags := cmd.Flags()

cli/command/container/create.go

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

111111
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"
@@ -50,7 +49,7 @@ func newPsCommand(dockerCLI command.Cli) *cobra.Command {
5049
"category-top": "3",
5150
"aliases": "docker container ls, docker container list, docker container ps, docker ps",
5251
},
53-
ValidArgsFunction: completion.NoComplete,
52+
ValidArgsFunction: cobra.NoFileCompletions,
5453
}
5554

5655
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/internal/prompt"
1110
"github.com/docker/cli/opts"
1211
"github.com/docker/go-units"
@@ -45,7 +44,7 @@ func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
4544
return nil
4645
},
4746
Annotations: map[string]string{"version": "1.25"},
48-
ValidArgsFunction: completion.NoComplete,
47+
ValidArgsFunction: cobra.NoFileCompletions,
4948
}
5049

5150
flags := cmd.Flags()

cli/command/container/run.go

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

9090
return cmd

0 commit comments

Comments
 (0)