2016-09-08 13:11:39 -04:00
|
|
|
package plugin
|
|
|
|
|
|
|
|
import (
|
2017-04-17 18:07:56 -04:00
|
|
|
"github.com/docker/cli/cli"
|
|
|
|
"github.com/docker/cli/cli/command"
|
|
|
|
"github.com/docker/cli/cli/command/inspect"
|
2016-09-08 13:11:39 -04:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
|
|
|
type inspectOptions struct {
|
|
|
|
pluginNames []string
|
|
|
|
format string
|
|
|
|
}
|
|
|
|
|
2016-09-08 14:54:01 -04:00
|
|
|
func newInspectCommand(dockerCli *command.DockerCli) *cobra.Command {
|
2016-09-08 13:11:39 -04:00
|
|
|
var opts inspectOptions
|
|
|
|
|
|
|
|
cmd := &cobra.Command{
|
2016-12-31 12:55:04 -05:00
|
|
|
Use: "inspect [OPTIONS] PLUGIN [PLUGIN...]",
|
2016-09-08 13:11:39 -04:00
|
|
|
Short: "Display detailed information on one or more plugins",
|
|
|
|
Args: cli.RequiresMinArgs(1),
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
opts.pluginNames = args
|
|
|
|
return runInspect(dockerCli, opts)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
flags := cmd.Flags()
|
2016-10-18 06:50:11 -04:00
|
|
|
flags.StringVarP(&opts.format, "format", "f", "", "Format the output using the given Go template")
|
2016-09-08 13:11:39 -04:00
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
2016-09-08 14:54:01 -04:00
|
|
|
func runInspect(dockerCli *command.DockerCli, opts inspectOptions) error {
|
2016-09-08 13:11:39 -04:00
|
|
|
client := dockerCli.Client()
|
|
|
|
ctx := context.Background()
|
2016-11-23 23:04:44 -05:00
|
|
|
getRef := func(ref string) (interface{}, []byte, error) {
|
|
|
|
return client.PluginInspectWithRaw(ctx, ref)
|
2016-09-08 13:11:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return inspect.Inspect(dockerCli.Out(), opts.pluginNames, opts.format, getRef)
|
|
|
|
}
|