mirror of https://github.com/docker/cli.git
docker inspect: add support for swarm configs
The docker inspect command did not inspect configs. This patch adds support for it, and while at it, also sorts the list of objects in runInspect. Before this patch: docker config create myconfig ./codecov.yml danpeyh8qzb30vgdj9fr665l1 docker inspect --format='{{.ID}}' myconfig [] Error: No such object: myconfig docker inspect --format='{{.ID}}' --type=config myconfig "config" is not a valid value for --type With this patch: docker inspect --format='{{.ID}}' myconfig danpeyh8qzb30vgdj9fr665l1 docker inspect --format='{{.ID}}' --type=config myconfig danpeyh8qzb30vgdj9fr665l1 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
61baf2a3d9
commit
e9ae9f788b
|
@ -51,7 +51,7 @@ func NewInspectCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
func runInspect(ctx context.Context, dockerCli command.Cli, opts inspectOptions) error {
|
func runInspect(ctx context.Context, dockerCli command.Cli, 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", "plugin", "secret":
|
case "", "config", "container", "image", "network", "node", "plugin", "secret", "service", "task", "volume":
|
||||||
elementSearcher = inspectAll(ctx, dockerCli, opts.size, opts.inspectType)
|
elementSearcher = inspectAll(ctx, dockerCli, opts.size, opts.inspectType)
|
||||||
default:
|
default:
|
||||||
return errors.Errorf("%q is not a valid value for --type", opts.inspectType)
|
return errors.Errorf("%q is not a valid value for --type", opts.inspectType)
|
||||||
|
@ -114,6 +114,12 @@ func inspectSecret(ctx context.Context, dockerCli command.Cli) inspect.GetRefFun
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func inspectConfig(ctx context.Context, dockerCLI command.Cli) inspect.GetRefFunc {
|
||||||
|
return func(ref string) (any, []byte, error) {
|
||||||
|
return dockerCLI.Client().ConfigInspectWithRaw(ctx, ref)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func inspectAll(ctx context.Context, dockerCli command.Cli, getSize bool, typeConstraint string) inspect.GetRefFunc {
|
func inspectAll(ctx context.Context, dockerCli command.Cli, getSize bool, typeConstraint string) inspect.GetRefFunc {
|
||||||
inspectAutodetect := []struct {
|
inspectAutodetect := []struct {
|
||||||
objectType string
|
objectType string
|
||||||
|
@ -162,6 +168,11 @@ func inspectAll(ctx context.Context, dockerCli command.Cli, getSize bool, typeCo
|
||||||
isSwarmObject: true,
|
isSwarmObject: true,
|
||||||
objectInspector: inspectSecret(ctx, dockerCli),
|
objectInspector: inspectSecret(ctx, dockerCli),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
objectType: "config",
|
||||||
|
isSwarmObject: true,
|
||||||
|
objectInspector: inspectConfig(ctx, dockerCli),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// isSwarmManager does an Info API call to verify that the daemon is
|
// isSwarmManager does an Info API call to verify that the daemon is
|
||||||
|
|
|
@ -29,7 +29,7 @@ all the details of the format.
|
||||||
|
|
||||||
### <a name="type"></a> Specify target type (--type)
|
### <a name="type"></a> Specify target type (--type)
|
||||||
|
|
||||||
`--type container|image|node|network|secret|service|volume|task|plugin`
|
`--type config|container|image|node|network|secret|service|volume|task|plugin`
|
||||||
|
|
||||||
The `docker inspect` command matches any type of object by either ID or name. In
|
The `docker inspect` command matches any type of object by either ID or name. In
|
||||||
some cases multiple type of objects (for example, a container and a volume)
|
some cases multiple type of objects (for example, a container and a volume)
|
||||||
|
|
Loading…
Reference in New Issue