8000 docker inspect: add support for swarm configs · docker/cli@e9ae9f7 · GitHub
[go: up one dir, main page]

Skip to content

Commit e9ae9f7

Browse files
committed
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>
1 parent 61baf2a commit e9ae9f7

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)
0