Skip to content

Commit

Permalink
Add error handling
Browse files Browse the repository at this point in the history
Signed-off-by: Harald Albers <[email protected]>
  • Loading branch information
albers committed Oct 17, 2024
1 parent 96ad9a4 commit 3306b98
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cli/command/system/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ var (
"untag",
"update",
}
eventTypes = []string{"config", "container", "daemon", "image", "network", "node", "plugin", "secret", "service", "volume"}
)
var eventTypes = []string{"config", "container", "daemon", "image", "network", "node", "plugin", "secret", "service", "volume"}

func completeFilters(dockerCLI completion.APIClientProvider) completion.ValidArgsFn {
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if strings.HasPrefix(toComplete, "container=") {
// the pure container name list should be pulled out from ContainerNames.
names, _ := completion.ContainerNames(dockerCLI, true)(cmd, args, toComplete)
if names == nil {
return nil, cobra.ShellCompDirectiveNoFileComp
}
return prefixWith("container=", names), cobra.ShellCompDirectiveDefault
}
if strings.HasPrefix(toComplete, "event=") {
Expand All @@ -69,8 +71,10 @@ func completeFilters(dockerCLI completion.APIClientProvider) completion.ValidArg
return nil, cobra.ShellCompDirectiveNoFileComp
}
if strings.HasPrefix(toComplete, "network=") {
// the pure network name list should be pulled out from NetworkNames.
names, _ := completion.NetworkNames(dockerCLI)(cmd, args, toComplete)
if names == nil {
return nil, cobra.ShellCompDirectiveNoFileComp
}
return prefixWith("network=", names), cobra.ShellCompDirectiveDefault
}
if strings.HasPrefix(toComplete, "type=") {
Expand Down

0 comments on commit 3306b98

Please sign in to comment.