mirror of https://github.com/docker/cli.git
Merge pull request #28967 from yongtang/28946-support-plugin-docker-inspect
Support plugin type in `docker inspect`
This commit is contained in:
commit
f9f00faf63
|
@ -45,7 +45,7 @@ func NewInspectCommand(dockerCli *command.DockerCli) *cobra.Command {
|
||||||
func runInspect(dockerCli *command.DockerCli, opts inspectOptions) error {
|
func runInspect(dockerCli *command.DockerCli, opts inspectOptions) error {
|
||||||
var elementSearcher inspect.GetRefFunc
|
var elementSearcher inspect.GetRefFunc
|
||||||
switch opts.inspectType {
|
switch opts.inspectType {
|
||||||
case "", "container", "image", "node", "network", "service", "volume", "task":
|
case "", "container", "image", "node", "network", "service", "volume", "task", "plugin":
|
||||||
elementSearcher = inspectAll(context.Background(), dockerCli, opts.size, opts.inspectType)
|
elementSearcher = inspectAll(context.Background(), dockerCli, opts.size, opts.inspectType)
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("%q is not a valid value for --type", opts.inspectType)
|
return fmt.Errorf("%q is not a valid value for --type", opts.inspectType)
|
||||||
|
@ -95,6 +95,12 @@ func inspectVolume(ctx context.Context, dockerCli *command.DockerCli) inspect.Ge
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func inspectPlugin(ctx context.Context, dockerCli *command.DockerCli) inspect.GetRefFunc {
|
||||||
|
return func(ref string) (interface{}, []byte, error) {
|
||||||
|
return dockerCli.Client().PluginInspectWithRaw(ctx, ref)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func inspectAll(ctx context.Context, dockerCli *command.DockerCli, getSize bool, typeConstraint string) inspect.GetRefFunc {
|
func inspectAll(ctx context.Context, dockerCli *command.DockerCli, getSize bool, typeConstraint string) inspect.GetRefFunc {
|
||||||
var inspectAutodetect = []struct {
|
var inspectAutodetect = []struct {
|
||||||
ObjectType string
|
ObjectType string
|
||||||
|
@ -108,6 +114,7 @@ func inspectAll(ctx context.Context, dockerCli *command.DockerCli, getSize bool,
|
||||||
{"service", false, inspectService(ctx, dockerCli)},
|
{"service", false, inspectService(ctx, dockerCli)},
|
||||||
{"task", false, inspectTasks(ctx, dockerCli)},
|
{"task", false, inspectTasks(ctx, dockerCli)},
|
||||||
{"node", false, inspectNode(ctx, dockerCli)},
|
{"node", false, inspectNode(ctx, dockerCli)},
|
||||||
|
{"plugin", false, inspectPlugin(ctx, dockerCli)},
|
||||||
}
|
}
|
||||||
|
|
||||||
isErrNotSwarmManager := func(err error) bool {
|
isErrNotSwarmManager := func(err error) bool {
|
||||||
|
|
Loading…
Reference in New Issue