github.com/kunnos/engine@v1.13.1/cli/command/plugin/disable.go (about) 1 package plugin 2 3 import ( 4 "fmt" 5 6 "github.com/docker/docker/api/types" 7 "github.com/docker/docker/cli" 8 "github.com/docker/docker/cli/command" 9 "github.com/spf13/cobra" 10 "golang.org/x/net/context" 11 ) 12 13 func newDisableCommand(dockerCli *command.DockerCli) *cobra.Command { 14 var force bool 15 16 cmd := &cobra.Command{ 17 Use: "disable [OPTIONS] PLUGIN", 18 Short: "Disable a plugin", 19 Args: cli.ExactArgs(1), 20 RunE: func(cmd *cobra.Command, args []string) error { 21 return runDisable(dockerCli, args[0], force) 22 }, 23 } 24 25 flags := cmd.Flags() 26 flags.BoolVarP(&force, "force", "f", false, "Force the disable of an active plugin") 27 return cmd 28 } 29 30 func runDisable(dockerCli *command.DockerCli, name string, force bool) error { 31 if err := dockerCli.Client().PluginDisable(context.Background(), name, types.PluginDisableOptions{Force: force}); err != nil { 32 return err 33 } 34 fmt.Fprintln(dockerCli.Out(), name) 35 return nil 36 }