Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions cmd/compose/convert.go → cmd/compose/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ func convertCommand(p *ProjectOptions, streams api.Streams, backend api.Service)
ProjectOptions: p,
}
cmd := &cobra.Command{
Aliases: []string{"config"},
Use: "convert [OPTIONS] [SERVICE...]",
Short: "Converts the compose file to platform's canonical format",
Aliases: []string{"convert"}, // for backward compatibility with Cloud integrations
Use: "config [OPTIONS] [SERVICE...]",
Short: "Parse, resolve and render compose file in canonical format",
PreRunE: Adapt(func(ctx context.Context, args []string) error {
if opts.quiet {
devnull, err := os.Open(os.DevNull)
Expand Down Expand Up @@ -86,7 +86,7 @@ func convertCommand(p *ProjectOptions, streams api.Streams, backend api.Service)
return runConfigImages(streams, opts, args)
}

return runConvert(ctx, streams, backend, opts, args)
return runConfig(ctx, streams, backend, opts, args)
}),
ValidArgsFunction: completeServiceNames(p),
}
Expand All @@ -108,7 +108,7 @@ func convertCommand(p *ProjectOptions, streams api.Streams, backend api.Service)
return cmd
}

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

content, err = backend.Convert(ctx, project, api.ConvertOptions{
content, err = backend.Config(ctx, project, api.ConfigOptions{
Format: opts.Format,
Output: opts.Output,
ResolveImageDigests: opts.resolveImageDigests,
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/compose.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Docker Compose
|:--------------------------------|:------------------------------------------------------------------------|
| [`alpha`](compose_alpha.md) | Experimental commands |
| [`build`](compose_build.md) | Build or rebuild services |
| [`convert`](compose_convert.md) | Converts the compose file to platform's canonical format |
| [`config`](compose_config.md) | Parse, resolve and render compose file in canonical format |
| [`cp`](compose_cp.md) | Copy files/folders between a service container and the local filesystem |
| [`create`](compose_create.md) | Creates containers for a service. |
| [`down`](compose_down.md) | Stop and remove containers, networks |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# docker compose convert

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

### Aliases

`docker compose convert`, `docker compose config`
`docker compose config`, `docker compose convert`

### Options

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

## Description

`docker compose convert` renders the actual data model to be applied on the target platform. When used with the Docker engine,
`docker compose config` renders the actual data model to be applied on the Docker engine.
it merges the Compose files set by `-f` flags, resolves variables in the Compose file, and expands short-notation into
the canonical format.

To allow smooth migration from docker-compose, this subcommand declares alias `docker compose config`
4 changes: 2 additions & 2 deletions docs/reference/docker_compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pname: docker
plink: docker.yaml
cname:
- docker compose build
- docker compose convert
- docker compose config
- docker compose cp
- docker compose create
- docker compose down
Expand All @@ -141,7 +141,7 @@ cname:
- docker compose version
clink:
- docker_compose_build.yaml
- docker_compose_convert.yaml
- docker_compose_config.yaml
- docker_compose_cp.yaml
- docker_compose_create.yaml
- docker_compose_down.yaml
Expand Down
138 changes: 138 additions & 0 deletions docs/reference/docker_compose_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
command: docker compose config
aliases: docker compose config, docker compose convert
short: Parse, resolve and render compose file in canonical format
long: |-
`docker compose config` renders the actual data model to be applied on the Docker engine.
it merges the Compose files set by `-f` flags, resolves variables in the Compose file, and expands short-notation into
the canonical format.
usage: docker compose config [OPTIONS] [SERVICE...]
pname: docker compose
plink: docker_compose.yaml
options:
- option: format
value_type: string
default_value: yaml
description: 'Format the output. Values: [yaml | json]'
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: hash
value_type: string
description: Print the service config hash, one per line.
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: images
value_type: bool
default_value: "false"
description: Print the image names, one per line.
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: no-consistency
value_type: bool
default_value: "false"
description: |
Don't check model consistency - warning: may produce invalid Compose output
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: no-interpolate
value_type: bool
default_value: "false"
description: Don't interpolate environment variables.
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: no-normalize
value_type: bool
default_value: "false"
description: Don't normalize compose model.
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: output
shorthand: o
value_type: string
description: Save to file (default to stdout)
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: profiles
value_type: bool
default_value: "false"
description: Print the profile names, one per line.
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: quiet
shorthand: q
value_type: bool
default_value: "false"
description: Only validate the configuration, don't print anything.
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: resolve-image-digests
value_type: bool
default_value: "false"
description: Pin image tags to digests.
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: services
value_type: bool
default_value: "false"
description: Print the service names, one per line.
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: volumes
value_type: bool
default_value: "false"
description: Print the volume names, one per line.
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
deprecated: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false

6 changes: 3 additions & 3 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type Service interface {
// List executes the equivalent to a `docker stack ls`
List(ctx context.Context, options ListOptions) ([]Stack, error)
// Convert translate compose model into backend's native format
Convert(ctx context.Context, project *types.Project, options ConvertOptions) ([]byte, error)
Config(ctx context.Context, project *types.Project, options ConfigOptions) ([]byte, error)
// Kill executes the equivalent to a `compose kill`
Kill(ctx context.Context, projectName string, options KillOptions) error
// RunOneOffContainer creates a service oneoff container and starts its dependencies
Expand Down Expand Up @@ -185,8 +185,8 @@ type DownOptions struct {
Volumes bool
}

// ConvertOptions group options of the Convert API
type ConvertOptions struct {
// ConfigOptions group options of the Config API
type ConfigOptions struct {
// Format define the output format used to dump converted application model (json|yaml)
Format string
// Output defines the path to save the application model
Expand Down
10 changes: 5 additions & 5 deletions pkg/api/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type ServiceProxy struct {
LogsFn func(ctx context.Context, projectName string, consumer LogConsumer, options LogOptions) error
PsFn func(ctx context.Context, projectName string, options PsOptions) ([]ContainerSummary, error)
ListFn func(ctx context.Context, options ListOptions) ([]Stack, error)
ConvertFn func(ctx context.Context, project *types.Project, options ConvertOptions) ([]byte, error)
ConfigFn func(ctx context.Context, project *types.Project, options ConfigOptions) ([]byte, error)
KillFn func(ctx context.Context, project string, options KillOptions) error
RunOneOffContainerFn func(ctx context.Context, project *types.Project, opts RunOptions) (int, error)
RemoveFn func(ctx context.Context, project string, options RemoveOptions) error
Expand Down Expand Up @@ -78,7 +78,7 @@ func (s *ServiceProxy) WithService(service Service) *ServiceProxy {
s.LogsFn = service.Logs
s.PsFn = service.Ps
s.ListFn = service.List
s.ConvertFn = service.Convert
s.ConfigFn = service.Config
s.KillFn = service.Kill
s.RunOneOffContainerFn = service.RunOneOffContainer
s.RemoveFn = service.Remove
Expand Down Expand Up @@ -214,14 +214,14 @@ func (s *ServiceProxy) List(ctx context.Context, options ListOptions) ([]Stack,
}

// Convert implements Service interface
func (s *ServiceProxy) Convert(ctx context.Context, project *types.Project, options ConvertOptions) ([]byte, error) {
if s.ConvertFn == nil {
func (s *ServiceProxy) Config(ctx context.Context, project *types.Project, options ConfigOptions) ([]byte, error) {
if s.ConfigFn == nil {
return nil, ErrNotImplemented
}
for _, i := range s.interceptors {
i(ctx, project)
}
return s.ConvertFn(ctx, project, options)
return s.ConfigFn(ctx, project, options)
}

// Kill implements Service interface
Expand Down
2 changes: 1 addition & 1 deletion pkg/compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func getContainerNameWithoutProject(c moby.Container) string {
return name
}

func (s *composeService) Convert(ctx context.Context, project *types.Project, options api.ConvertOptions) ([]byte, error) {
func (s *composeService) Config(ctx context.Context, project *types.Project, options api.ConfigOptions) ([]byte, error) {
if options.ResolveImageDigests {
info, err := s.apiClient().Info(ctx)
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions pkg/mocks/mock_docker_compose_api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.