mirror of
https://github.com/docker/cli.git
synced 2026-09-26 01:10:35 -04:00
Support plugins in docker inspect
This fix tries to address the proposal raised in 28946
to support plugins in `docker inspect`.
The command `docker inspect` already supports
"container", "image", "node", "network", "service", "volume", "task".
However, `--type plugin` is not supported yet at the moment.
This fix address this issue by adding the support of `--type plugin`
for `docker inspect`.
An additional integration test has been added to cover the changes.
This fix fixes 28946.
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: 492c2c8da8
Component: cli
This commit is contained in:
@@ -45,7 +45,7 @@ func NewInspectCommand(dockerCli *command.DockerCli) *cobra.Command {
|
||||
func runInspect(dockerCli *command.DockerCli, opts inspectOptions) error {
|
||||
var elementSearcher inspect.GetRefFunc
|
||||
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)
|
||||
default:
|
||||
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 {
|
||||
var inspectAutodetect = []struct {
|
||||
ObjectType string
|
||||
@@ -108,6 +114,7 @@ func inspectAll(ctx context.Context, dockerCli *command.DockerCli, getSize bool,
|
||||
{"service", false, inspectService(ctx, dockerCli)},
|
||||
{"task", false, inspectTasks(ctx, dockerCli)},
|
||||
{"node", false, inspectNode(ctx, dockerCli)},
|
||||
{"plugin", false, inspectPlugin(ctx, dockerCli)},
|
||||
}
|
||||
|
||||
isErrNotSwarmManager := func(err error) bool {
|
||||
|
||||
Reference in New Issue
Block a user