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

Function completeNames

cli/command/plugin/completion.go:23–47  ·  view source on GitHub ↗

completeNames offers completion for plugin names in the given state. The state argument can be one of: - "all": all plugins - "enabled": all enabled plugins - "disabled": all disabled plugins

(dockerCLI completion.APIClientProvider, state pluginState)

Source from the content-addressed store, hash-verified

21// - "enabled": all enabled plugins
22// - "disabled": all disabled plugins
23func completeNames(dockerCLI completion.APIClientProvider, state pluginState) cobra.CompletionFunc {
24 return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
25 f := make(client.Filters)
26 switch state {
27 case stateEnabled:
28 f.Add("enabled", "true")
29 case stateDisabled:
30 f.Add("enabled", "false")
31 case stateAny:
32 // no filter
33 }
34
35 res, err := dockerCLI.Client().PluginList(cmd.Context(), client.PluginListOptions{
36 Filters: f,
37 })
38 if err != nil {
39 return nil, cobra.ShellCompDirectiveError
40 }
41 var names []string
42 for _, v := range res.Items {
43 names = append(names, v.Name)
44 }
45 return names, cobra.ShellCompDirectiveNoFileComp
46 }
47}

Callers 7

newPushCommandFunction · 0.70
newSetCommandFunction · 0.70
newInspectCommandFunction · 0.70
newEnableCommandFunction · 0.70
newRemoveCommandFunction · 0.70
newDisableCommandFunction · 0.70
newUpgradeCommandFunction · 0.70

Calls 2

PluginListMethod · 0.80
ClientMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…