Skip to content

Commit 32ff200

Browse files
authored
Merge pull request #5573 from thaJeztah/inspect_add_configs
docker inspect: add support for swarm configs
2 parents 61baf2a + e9ae9f7 commit 32ff200

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

cli/command/system/inspect.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func NewInspectCommand(dockerCli command.Cli) *cobra.Command {
5151
func runInspect(ctx context.Context, dockerCli command.Cli, opts inspectOptions) error {
5252
var elementSearcher inspect.GetRefFunc
5353
switch opts.inspectType {
54-
case "", "container", "image", "node", "network", "service", "volume", "task", "plugin", "secret":
54+
case "", "config", "container", "image", "network", "node", "plugin", "secret", "service", "task", "volume":
5555
elementSearcher = inspectAll(ctx, dockerCli, opts.size, opts.inspectType)
5656
default:
5757
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
114114
}
115115
}
116116

117+
func inspectConfig(ctx context.Context, dockerCLI command.Cli) inspect.GetRefFunc {
118+
return func(ref string) (any, []byte, error) {
119+
return dockerCLI.Client().ConfigInspectWithRaw(ctx, ref)
120+
}
121+
}
122+
117123
func inspectAll(ctx context.Context, dockerCli command.Cli, getSize bool, typeConstraint string) inspect.GetRefFunc {
118124
inspectAutodetect := []struct {
119125
objectType string
@@ -162,6 +168,11 @@ func inspectAll(ctx context.Context, dockerCli command.Cli, getSize bool, typeCo
162168
isSwarmObject: true,
163169
objectInspector: inspectSecret(ctx, dockerCli),
164170
},
171+
{
172+
objectType: "config",
173+
isSwarmObject: true,
174+
objectInspector: inspectConfig(ctx, dockerCli),
175+
},
165176
}
166177

167178
// isSwarmManager does an Info API call to verify that the daemon is

docs/reference/commandline/inspect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ all the details of the format.
2929

3030
### <a name="type"></a> Specify target type (--type)
3131

32-
`--type container|image|node|network|secret|service|volume|task|plugin`
32+
`--type config|container|image|node|network|secret|service|volume|task|plugin`
3333

3434
The `docker inspect` command matches any type of object by either ID or name. In
3535
some cases multiple type of objects (for example, a container and a volume)

0 commit comments

Comments
 (0)