Skip to content

Commit 3f3ff40

Browse files
committed
Add error handling
Signed-off-by: Harald Albers <github@albersweb.de>
1 parent c17b87a commit 3f3ff40

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

cli/command/system/completion.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,16 @@ var (
5252
"untag",
5353
"update",
5454
}
55+
eventTypes = []string{"config", "container", "daemon", "image", "network", "node", "plugin", "secret", "service", "volume"}
5556
)
56-
var eventTypes = []string{"config", "container", "daemon", "image", "network", "node", "plugin", "secret", "service", "volume"}
5757

5858
func completeFilters(dockerCLI completion.APIClientProvider) completion.ValidArgsFn {
5959
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
6060
if strings.HasPrefix(toComplete, "container=") {
61-
// the pure container name list should be pulled out from ContainerNames.
6261
names, _ := completion.ContainerNames(dockerCLI, true)(cmd, args, toComplete)
62+
if names == nil {
63+
return nil, cobra.ShellCompDirectiveNoFileComp
64+
}
6365
return prefixWith("container=", names), cobra.ShellCompDirectiveDefault
6466
}
6567
if strings.HasPrefix(toComplete, "event=") {
@@ -69,8 +71,10 @@ func completeFilters(dockerCLI completion.APIClientProvider) completion.ValidArg
6971
return nil, cobra.ShellCompDirectiveNoFileComp
7072
}
7173
if strings.HasPrefix(toComplete, "network=") {
72-
// the pure network name list should be pulled out from NetworkNames.
7374
names, _ := completion.NetworkNames(dockerCLI)(cmd, args, toComplete)
75+
if names == nil {
76+
return nil, cobra.ShellCompDirectiveNoFileComp
77+
}
7478
return prefixWith("network=", names), cobra.ShellCompDirectiveDefault
7579
}
7680
if strings.HasPrefix(toComplete, "type=") {

0 commit comments

Comments
 (0)