MCPcopy Index your code
hub / github.com/docker/cli / completeEventFilters

Function completeEventFilters

cli/command/system/completion.go:88–119  ·  view source on GitHub ↗

completeEventFilters provides completion for the filters that can be used with `--filter`.

(dockerCLI completion.APIClientProvider)

Source from the content-addressed store, hash-verified

86
87// completeEventFilters provides completion for the filters that can be used with `--filter`.
88func completeEventFilters(dockerCLI completion.APIClientProvider) cobra.CompletionFunc {
89 return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
90 key, _, ok := strings.Cut(toComplete, "=")
91 if !ok {
92 return postfixWith("=", eventFilters), cobra.ShellCompDirectiveNoSpace
93 }
94 switch key {
95 case "container":
96 return prefixWith("container=", containerNames(dockerCLI, cmd, args, toComplete)), cobra.ShellCompDirectiveNoFileComp
97 case "daemon":
98 return prefixWith("daemon=", daemonNames(dockerCLI, cmd)), cobra.ShellCompDirectiveNoFileComp
99 case "event":
100 return prefixWith("event=", validEventNames()), cobra.ShellCompDirectiveNoFileComp
101 case "image":
102 return prefixWith("image=", imageNames(dockerCLI, cmd)), cobra.ShellCompDirectiveNoFileComp
103 case "label":
104 return nil, cobra.ShellCompDirectiveNoFileComp
105 case "network":
106 return prefixWith("network=", networkNames(dockerCLI, cmd)), cobra.ShellCompDirectiveNoFileComp
107 case "node":
108 return prefixWith("node=", nodeNames(dockerCLI, cmd)), cobra.ShellCompDirectiveNoFileComp
109 case "scope":
110 return prefixWith("scope=", []string{"local", "swarm"}), cobra.ShellCompDirectiveNoFileComp
111 case "type":
112 return prefixWith("type=", eventTypeNames()), cobra.ShellCompDirectiveNoFileComp
113 case "volume":
114 return prefixWith("volume=", volumeNames(dockerCLI, cmd)), cobra.ShellCompDirectiveNoFileComp
115 default:
116 return postfixWith("=", eventFilters), cobra.ShellCompDirectiveNoSpace | cobra.ShellCompDirectiveNoFileComp
117 }
118 }
119}
120
121// prefixWith prefixes every element in the slice with the given prefix.
122func prefixWith(prefix string, values []string) []string {

Callers 2

TestCompleteEventFilterFunction · 0.85
newEventsCommandFunction · 0.85

Calls 10

daemonNamesFunction · 0.85
validEventNamesFunction · 0.85
imageNamesFunction · 0.85
networkNamesFunction · 0.85
nodeNamesFunction · 0.85
eventTypeNamesFunction · 0.85
volumeNamesFunction · 0.85
postfixWithFunction · 0.70
prefixWithFunction · 0.70
containerNamesFunction · 0.70

Tested by 1

TestCompleteEventFilterFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…