Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
45 lines (40 loc) · 1.13 KB

File metadata and controls

45 lines (40 loc) · 1.13 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package plugin
import (
"github.com/docker/cli/cli/command/completion"
"github.com/moby/moby/api/types/filters"
"github.com/spf13/cobra"
)
type pluginState string
const (
stateAny pluginState = ""
stateEnabled pluginState = "enabled"
stateDisabled pluginState = "disabled"
)
// 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
func completeNames(dockerCLI completion.APIClientProvider, state pluginState) cobra.CompletionFunc {
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
f := filters.NewArgs()
switch state {
case stateEnabled:
f.Add("enabled", "true")
case stateDisabled:
f.Add("enabled", "false")
case stateAny:
// no filter
}
list, err := dockerCLI.Client().PluginList(cmd.Context(), f)
if err != nil {
return nil, cobra.ShellCompDirectiveError
}
var names []string
for _, v := range list {
names = append(names, v.Name)
}
return names, cobra.ShellCompDirectiveNoFileComp
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.