github.com/itscaro/cli@v0.0.0-20190705081621-c9db0fe93829/cli/command/plugin/inspect.go (about) 1 package plugin 2 3 import ( 4 "context" 5 6 "github.com/docker/cli/cli" 7 "github.com/docker/cli/cli/command" 8 "github.com/docker/cli/cli/command/inspect" 9 "github.com/spf13/cobra" 10 ) 11 12 type inspectOptions struct { 13 pluginNames []string 14 format string 15 } 16 17 func newInspectCommand(dockerCli command.Cli) *cobra.Command { 18 var opts inspectOptions 19 20 cmd := &cobra.Command{ 21 Use: "inspect [OPTIONS] PLUGIN [PLUGIN...]", 22 Short: "Display detailed information on one or more plugins", 23 Args: cli.RequiresMinArgs(1), 24 RunE: func(cmd *cobra.Command, args []string) error { 25 opts.pluginNames = args 26 return runInspect(dockerCli, opts) 27 }, 28 } 29 30 flags := cmd.Flags() 31 flags.StringVarP(&opts.format, "format", "f", "", "Format the output using the given Go template") 32 return cmd 33 } 34 35 func runInspect(dockerCli command.Cli, opts inspectOptions) error { 36 client := dockerCli.Client() 37 ctx := context.Background() 38 getRef := func(ref string) (interface{}, []byte, error) { 39 return client.PluginInspectWithRaw(ctx, ref) 40 } 41 42 return inspect.Inspect(dockerCli.Out(), opts.pluginNames, opts.format, getRef) 43 }