2016-05-16 11:50:55 -04:00
|
|
|
package plugin
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/docker/docker/cli"
|
2016-09-08 14:54:01 -04:00
|
|
|
"github.com/docker/docker/cli/command"
|
|
|
|
"github.com/docker/docker/cli/command/inspect"
|
2016-05-16 11:50:55 -04:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
2016-08-17 07:52:27 -04:00
|
|
|
type inspectOptions struct {
|
|
|
|
pluginNames []string
|
|
|
|
format string
|
|
|
|
}
|
|
|
|
|
2016-09-08 14:54:01 -04:00
|
|
|
func newInspectCommand(dockerCli *command.DockerCli) *cobra.Command {
|
2016-08-17 07:52:27 -04:00
|
|
|
var opts inspectOptions
|
|
|
|
|
2016-05-16 11:50:55 -04:00
|
|
|
cmd := &cobra.Command{
|
2016-12-31 12:55:04 -05:00
|
|
|
Use: "inspect [OPTIONS] PLUGIN [PLUGIN...]",
|
2016-08-30 11:07:42 -04:00
|
|
|
Short: "Display detailed information on one or more plugins",
|
2016-08-17 07:52:27 -04:00
|
|
|
Args: cli.RequiresMinArgs(1),
|
2016-05-16 11:50:55 -04:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
2016-08-17 07:52:27 -04:00
|
|
|
opts.pluginNames = args
|
|
|
|
return runInspect(dockerCli, opts)
|
2016-05-16 11:50:55 -04:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2016-08-17 07:52:27 -04:00
|
|
|
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-05-16 11:50:55 -04:00
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
2016-09-08 14:54:01 -04:00
|
|
|
func runInspect(dockerCli *command.DockerCli, opts inspectOptions) error {
|
2016-08-17 07:52:27 -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-05-16 11:50:55 -04:00
|
|
|
}
|
2016-08-17 07:52:27 -04:00
|
|
|
|
|
|
|
return inspect.Inspect(dockerCli.Out(), opts.pluginNames, opts.format, getRef)
|
2016-05-16 11:50:55 -04:00
|
|
|
}
|