Merge pull request #5573 from thaJeztah/inspect_add_configs

docker inspect: add support for swarm configs
This commit is contained in:
Sebastiaan van Stijn 2024-10-25 17:38:47 +02:00 committed by GitHub
commit 32ff200fe6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 2 deletions

View File

@ -51,7 +51,7 @@ func NewInspectCommand(dockerCli command.Cli) *cobra.Command {
func runInspect(ctx context.Context, dockerCli command.Cli, opts inspectOptions) error {
var elementSearcher inspect.GetRefFunc
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)
default:
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 {
inspectAutodetect := []struct {
objectType string
@ -162,6 +168,11 @@ func inspectAll(ctx context.Context, dockerCli command.Cli, getSize bool, typeCo
isSwarmObject: true,
objectInspector: inspectSecret(ctx, dockerCli),
},
{
objectType: "config",
isSwarmObject: true,
objectInspector: inspectConfig(ctx, dockerCli),
},
}
// isSwarmManager does an Info API call to verify that the daemon is

View File

@ -29,7 +29,7 @@ all the details of the format.
### <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
some cases multiple type of objects (for example, a container and a volume)