-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
disable.go
36 lines (30 loc) · 896 Bytes
/
disable.go
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
package plugin
import (
"context"
"fmt"
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/docker/docker/api/types"
"github.com/spf13/cobra"
)
func newDisableCommand(dockerCli command.Cli) *cobra.Command {
var force bool
cmd := &cobra.Command{
Use: "disable [OPTIONS] PLUGIN",
Short: "Disable a plugin",
Args: cli.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
return runDisable(cmd.Context(), dockerCli, args[0], force)
},
}
flags := cmd.Flags()
flags.BoolVarP(&force, "force", "f", false, "Force the disable of an active plugin")
return cmd
}
func runDisable(ctx context.Context, dockerCli command.Cli, name string, force bool) error {
if err := dockerCli.Client().PluginDisable(ctx, name, types.PluginDisableOptions{Force: force}); err != nil {
return err
}
fmt.Fprintln(dockerCli.Out(), name)
return nil
}