Skip to content

Commit f42226e

Browse files
jarqviglours
authored andcommitted
feat: add --models flag to config command
Signed-off-by: MohammadHasan Akbari <[email protected]>
1 parent 0cc3c7a commit f42226e

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

cmd/compose/config.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ type configOptions struct {
5151
services bool
5252
volumes bool
5353
networks bool
54+
models bool
5455
profiles bool
5556
images bool
5657
hash string
@@ -115,6 +116,9 @@ func configCommand(p *ProjectOptions, dockerCli command.Cli) *cobra.Command {
115116
if opts.networks {
116117
return runNetworks(ctx, dockerCli, opts)
117118
}
119+
if opts.models {
120+
return runModels(ctx, dockerCli, opts)
121+
}
118122
if opts.hash != "" {
119123
return runHash(ctx, dockerCli, opts)
120124
}
@@ -152,6 +156,7 @@ func configCommand(p *ProjectOptions, dockerCli command.Cli) *cobra.Command {
152156
flags.BoolVar(&opts.services, "services", false, "Print the service names, one per line.")
153157
flags.BoolVar(&opts.volumes, "volumes", false, "Print the volume names, one per line.")
154158
flags.BoolVar(&opts.networks, "networks", false, "Print the network names, one per line.")
159+
flags.BoolVar(&opts.models, "models", false, "Print the model names, one per line.")
155160
flags.BoolVar(&opts.profiles, "profiles", false, "Print the profile names, one per line.")
156161
flags.BoolVar(&opts.images, "images", false, "Print the image names, one per line.")
157162
flags.StringVar(&opts.hash, "hash", "", "Print the service config hash, one per line.")
@@ -383,6 +388,17 @@ func runNetworks(ctx context.Context, dockerCli command.Cli, opts configOptions)
383388
return nil
384389
}
385390

391+
func runModels(ctx context.Context, dockerCli command.Cli, opts configOptions) error {
392+
project, err := opts.ToProject(ctx, dockerCli, nil, cli.WithoutEnvironmentResolution)
393+
if err != nil {
394+
return err
395+
}
396+
for n := range project.Models {
397+
_, _ = fmt.Fprintln(dockerCli.Out(), n)
398+
}
399+
return nil
400+
}
401+
386402
func runHash(ctx context.Context, dockerCli command.Cli, opts configOptions) error {
387403
var services []string
388404
if opts.hash != "*" {

docs/reference/compose_config.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ the canonical format.
1515
| `--hash` | `string` | | Print the service config hash, one per line. |
1616
| `--images` | `bool` | | Print the image names, one per line. |
1717
| `--lock-image-digests` | `bool` | | Produces an override file with image digests |
18+
| `--models` | `bool` | | Print the model names, one per line. |
1819
| `--networks` | `bool` | | Print the network names, one per line. |
1920
| `--no-consistency` | `bool` | | Don't check model consistency - warning: may produce invalid Compose output |
2021
| `--no-env-resolution` | `bool` | | Don't resolve service env files |

docs/reference/docker_compose_config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ options:
5656
experimentalcli: false
5757
kubernetes: false
5858
swarm: false
59+
- option: models
60+
value_type: bool
61+
default_value: "false"
62+
description: Print the model names, one per line.
63+
deprecated: false
64+
hidden: false
65+
experimental: false
66+
experimentalcli: false
67+
kubernetes: false
68+
swarm: false
5969
- option: networks
6070
value_type: bool
6171
default_value: "false"

0 commit comments

Comments
 (0)