Skip to content

Commit 41e0563

Browse files
committed
rename convert to config to align with compose v1 UX
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent a54d488 commit 41e0563

File tree

9 files changed

+165
-29
lines changed

9 files changed

+165
-29
lines changed

cmd/compose/convert.go renamed to cmd/compose/config.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ func convertCommand(p *ProjectOptions, streams api.Streams, backend api.Service)
5353
ProjectOptions: p,
5454
}
5555
cmd := &cobra.Command{
56-
Aliases: []string{"config"},
57-
Use: "convert [OPTIONS] [SERVICE...]",
58-
Short: "Converts the compose file to platform's canonical format",
56+
Aliases: []string{"convert"}, // for backward compatibility with Cloud integrations
57+
Use: "config [OPTIONS] [SERVICE...]",
58+
Short: "Parse, resolve and render compose file in canonical format",
5959
PreRunE: Adapt(func(ctx context.Context, args []string) error {
6060
if opts.quiet {
6161
devnull, err := os.Open(os.DevNull)
@@ -86,7 +86,7 @@ func convertCommand(p *ProjectOptions, streams api.Streams, backend api.Service)
8686
return runConfigImages(streams, opts, args)
8787
}
8888

89-
return runConvert(ctx, streams, backend, opts, args)
89+
return runConfig(ctx, streams, backend, opts, args)
9090
}),
9191
ValidArgsFunction: completeServiceNames(p),
9292
}
@@ -108,7 +108,7 @@ func convertCommand(p *ProjectOptions, streams api.Streams, backend api.Service)
108108
return cmd
109109
}
110110

111-
func runConvert(ctx context.Context, streams api.Streams, backend api.Service, opts convertOptions, services []string) error {
111+
func runConfig(ctx context.Context, streams api.Streams, backend api.Service, opts convertOptions, services []string) error {
112112
var content []byte
113113
project, err := opts.ToProject(services,
114114
cli.WithInterpolation(!opts.noInterpolate),
@@ -120,7 +120,7 @@ func runConvert(ctx context.Context, streams api.Streams, backend api.Service, o
120120
return err
121121
}
122122

123-
content, err = backend.Convert(ctx, project, api.ConvertOptions{
123+
content, err = backend.Config(ctx, project, api.ConfigOptions{
124124
Format: opts.Format,
125125
Output: opts.Output,
126126
ResolveImageDigests: opts.resolveImageDigests,

docs/reference/compose.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Docker Compose
99
|:--------------------------------|:------------------------------------------------------------------------|
1010
| [`alpha`](compose_alpha.md) | Experimental commands |
1111
| [`build`](compose_build.md) | Build or rebuild services |
12-
| [`convert`](compose_convert.md) | Converts the compose file to platform's canonical format |
12+
| [`config`](compose_config.md) | Parse, resolve and render compose file in canonical format |
1313
| [`cp`](compose_cp.md) | Copy files/folders between a service container and the local filesystem |
1414
| [`create`](compose_create.md) | Creates containers for a service. |
1515
| [`down`](compose_down.md) | Stop and remove containers, networks |

docs/reference/compose_convert.md renamed to docs/reference/compose_config.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# docker compose convert
22

33
<!---MARKER_GEN_START-->
4-
Converts the compose file to platform's canonical format
4+
Parse, resolve and render compose file in canonical format
55

66
### Aliases
77

8-
`docker compose convert`, `docker compose config`
8+
`docker compose config`, `docker compose convert`
99

1010
### Options
1111

@@ -29,8 +29,6 @@ Converts the compose file to platform's canonical format
2929

3030
## Description
3131

32-
`docker compose convert` renders the actual data model to be applied on the target platform. When used with the Docker engine,
32+
`docker compose config` renders the actual data model to be applied on the Docker engine.
3333
it merges the Compose files set by `-f` flags, resolves variables in the Compose file, and expands short-notation into
3434
the canonical format.
35-
36-
To allow smooth migration from docker-compose, this subcommand declares alias `docker compose config`

docs/reference/docker_compose.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ pname: docker
115115
plink: docker.yaml
116116
cname:
117117
- docker compose build
118-
- docker compose convert
118+
- docker compose config
119119
- docker compose cp
120120
- docker compose create
121121
- docker compose down
@@ -141,7 +141,7 @@ cname:
141141
- docker compose version
142142
clink:
143143
- docker_compose_build.yaml
144-
- docker_compose_convert.yaml
144+
- docker_compose_config.yaml
145145
- docker_compose_cp.yaml
146146
- docker_compose_create.yaml
147147
- docker_compose_down.yaml
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
command: docker compose config
2+
aliases: docker compose config, docker compose convert
3+
short: Parse, resolve and render compose file in canonical format
4+
long: |-
5+
`docker compose config` renders the actual data model to be applied on the Docker engine.
6+
it merges the Compose files set by `-f` flags, resolves variables in the Compose file, and expands short-notation into
7+
the canonical format.
8+
usage: docker compose config [OPTIONS] [SERVICE...]
9+
pname: docker compose
10+
plink: docker_compose.yaml
11+
options:
12+
- option: format
13+
value_type: string
14+
default_value: yaml
15+
description: 'Format the output. Values: [yaml | json]'
16+
deprecated: false
17+
hidden: false
18+
experimental: false
19+
experimentalcli: false
20+
kubernetes: false
21+
swarm: false
22+
- option: hash
23+
value_type: string
24+
description: Print the service config hash, one per line.
25+
deprecated: false
26+
hidden: false
27+
experimental: false
28+
experimentalcli: false
29+
kubernetes: false
30+
swarm: false
31+
- option: images
32+
value_type: bool
33+
default_value: "false"
34+
description: Print the image names, one per line.
35+
deprecated: false
36+
hidden: false
37+
experimental: false
38+
experimentalcli: false
39+
kubernetes: false
40+
swarm: false
41+
- option: no-consistency
42+
value_type: bool
43+
default_value: "false"
44+
description: |
45+
Don't check model consistency - warning: may produce invalid Compose output
46+
deprecated: false
47+
hidden: false
48+
experimental: false
49+
experimentalcli: false
50+
kubernetes: false
51+
swarm: false
52+
- option: no-interpolate
53+
value_type: bool
54+
default_value: "false"
55+
description: Don't interpolate environment variables.
56+
deprecated: false
57+
hidden: false
58+
experimental: false
59+
experimentalcli: false
60+
kubernetes: false
61+
swarm: false
62+
- option: no-normalize
63+
value_type: bool
64+
default_value: "false"
65+
description: Don't normalize compose model.
66+
deprecated: false
67+
hidden: false
68+
experimental: false
69+
experimentalcli: false
70+
kubernetes: false
71+
swarm: false
72+
- option: output
73+
shorthand: o
74+
value_type: string
75+
description: Save to file (default to stdout)
76+
deprecated: false
77+
hidden: false
78+
experimental: false
79+
experimentalcli: false
80+
kubernetes: false
81+
swarm: false
82+
- option: profiles
83+
value_type: bool
84+
default_value: "false"
85+
description: Print the profile names, one per line.
86+
deprecated: false
87+
hidden: false
88+
experimental: false
89+
experimentalcli: false
90+
kubernetes: false
91+
swarm: false
92+
- option: quiet
93+
shorthand: q
94+
value_type: bool
95+
default_value: "false"
96+
description: Only validate the configuration, don't print anything.
97+
deprecated: false
98+
hidden: false
99+
experimental: false
100+
experimentalcli: false
101+
kubernetes: false
102+
swarm: false
103+
- option: resolve-image-digests
104+
value_type: bool
105+
default_value: "false"
106+
description: Pin image tags to digests.
107+
deprecated: false
108+
hidden: false
109+
experimental: false
110+
experimentalcli: false
111+
kubernetes: false
112+
swarm: false
113+
- option: services
114+
value_type: bool
115+
default_value: "false"
116+
description: Print the service names, one per line.
117+
deprecated: false
118+
hidden: false
119+
experimental: false
120+
experimentalcli: false
121+
kubernetes: false
122+
swarm: false
123+
- option: volumes
124+
value_type: bool
125+
default_value: "false"
126+
description: Print the volume names, one per line.
127+
deprecated: false
128+
hidden: false
129+
experimental: false
130+
experimentalcli: false
131+
kubernetes: false
132+
swarm: false
133+
deprecated: false
134+
experimental: false
135+
experimentalcli: false
136+
kubernetes: false
137+
swarm: false
138+

pkg/api/api.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ type Service interface {
5252
// List executes the equivalent to a `docker stack ls`
5353
List(ctx context.Context, options ListOptions) ([]Stack, error)
5454
// Convert translate compose model into backend's native format
55-
Convert(ctx context.Context, project *types.Project, options ConvertOptions) ([]byte, error)
55+
Config(ctx context.Context, project *types.Project, options ConfigOptions) ([]byte, error)
5656
// Kill executes the equivalent to a `compose kill`
5757
Kill(ctx context.Context, projectName string, options KillOptions) error
5858
// RunOneOffContainer creates a service oneoff container and starts its dependencies
@@ -185,8 +185,8 @@ type DownOptions struct {
185185
Volumes bool
186186
}
187187

188-
// ConvertOptions group options of the Convert API
189-
type ConvertOptions struct {
188+
// ConfigOptions group options of the Config API
189+
type ConfigOptions struct {
190190
// Format define the output format used to dump converted application model (json|yaml)
191191
Format string
192192
// Output defines the path to save the application model

pkg/api/proxy.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type ServiceProxy struct {
3838
LogsFn func(ctx context.Context, projectName string, consumer LogConsumer, options LogOptions) error
3939
PsFn func(ctx context.Context, projectName string, options PsOptions) ([]ContainerSummary, error)
4040
ListFn func(ctx context.Context, options ListOptions) ([]Stack, error)
41-
ConvertFn func(ctx context.Context, project *types.Project, options ConvertOptions) ([]byte, error)
41+
ConfigFn func(ctx context.Context, project *types.Project, options ConfigOptions) ([]byte, error)
4242
KillFn func(ctx context.Context, project string, options KillOptions) error
4343
RunOneOffContainerFn func(ctx context.Context, project *types.Project, opts RunOptions) (int, error)
4444
RemoveFn func(ctx context.Context, project string, options RemoveOptions) error
@@ -78,7 +78,7 @@ func (s *ServiceProxy) WithService(service Service) *ServiceProxy {
7878
s.LogsFn = service.Logs
7979
s.PsFn = service.Ps
8080
s.ListFn = service.List
81-
s.ConvertFn = service.Convert
81+
s.ConfigFn = service.Config
8282
s.KillFn = service.Kill
8383
s.RunOneOffContainerFn = service.RunOneOffContainer
8484
s.RemoveFn = service.Remove
@@ -214,14 +214,14 @@ func (s *ServiceProxy) List(ctx context.Context, options ListOptions) ([]Stack,
214214
}
215215

216216
// Convert implements Service interface
217-
func (s *ServiceProxy) Convert(ctx context.Context, project *types.Project, options ConvertOptions) ([]byte, error) {
218-
if s.ConvertFn == nil {
217+
func (s *ServiceProxy) Config(ctx context.Context, project *types.Project, options ConfigOptions) ([]byte, error) {
218+
if s.ConfigFn == nil {
219219
return nil, ErrNotImplemented
220220
}
221221
for _, i := range s.interceptors {
222222
i(ctx, project)
223223
}
224-
return s.ConvertFn(ctx, project, options)
224+
return s.ConfigFn(ctx, project, options)
225225
}
226226

227227
// Kill implements Service interface

pkg/compose/compose.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func getContainerNameWithoutProject(c moby.Container) string {
120120
return name
121121
}
122122

123-
func (s *composeService) Convert(ctx context.Context, project *types.Project, options api.ConvertOptions) ([]byte, error) {
123+
func (s *composeService) Config(ctx context.Context, project *types.Project, options api.ConfigOptions) ([]byte, error) {
124124
if options.ResolveImageDigests {
125125
info, err := s.apiClient().Info(ctx)
126126
if err != nil {

pkg/mocks/mock_docker_compose_api.go

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)