rename convert
to config
to align with compose v1 UX
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
a54d488303
commit
41e056341b
@ -53,9 +53,9 @@ func convertCommand(p *ProjectOptions, streams api.Streams, backend api.Service)
|
|||||||
ProjectOptions: p,
|
ProjectOptions: p,
|
||||||
}
|
}
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Aliases: []string{"config"},
|
Aliases: []string{"convert"}, // for backward compatibility with Cloud integrations
|
||||||
Use: "convert [OPTIONS] [SERVICE...]",
|
Use: "config [OPTIONS] [SERVICE...]",
|
||||||
Short: "Converts the compose file to platform's canonical format",
|
Short: "Parse, resolve and render compose file in canonical format",
|
||||||
PreRunE: Adapt(func(ctx context.Context, args []string) error {
|
PreRunE: Adapt(func(ctx context.Context, args []string) error {
|
||||||
if opts.quiet {
|
if opts.quiet {
|
||||||
devnull, err := os.Open(os.DevNull)
|
devnull, err := os.Open(os.DevNull)
|
||||||
@ -86,7 +86,7 @@ func convertCommand(p *ProjectOptions, streams api.Streams, backend api.Service)
|
|||||||
return runConfigImages(streams, opts, args)
|
return runConfigImages(streams, opts, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
return runConvert(ctx, streams, backend, opts, args)
|
return runConfig(ctx, streams, backend, opts, args)
|
||||||
}),
|
}),
|
||||||
ValidArgsFunction: completeServiceNames(p),
|
ValidArgsFunction: completeServiceNames(p),
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ func convertCommand(p *ProjectOptions, streams api.Streams, backend api.Service)
|
|||||||
return cmd
|
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
|
var content []byte
|
||||||
project, err := opts.ToProject(services,
|
project, err := opts.ToProject(services,
|
||||||
cli.WithInterpolation(!opts.noInterpolate),
|
cli.WithInterpolation(!opts.noInterpolate),
|
||||||
@ -120,7 +120,7 @@ func runConvert(ctx context.Context, streams api.Streams, backend api.Service, o
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
content, err = backend.Convert(ctx, project, api.ConvertOptions{
|
content, err = backend.Config(ctx, project, api.ConfigOptions{
|
||||||
Format: opts.Format,
|
Format: opts.Format,
|
||||||
Output: opts.Output,
|
Output: opts.Output,
|
||||||
ResolveImageDigests: opts.resolveImageDigests,
|
ResolveImageDigests: opts.resolveImageDigests,
|
@ -9,7 +9,7 @@ Docker Compose
|
|||||||
|:--------------------------------|:------------------------------------------------------------------------|
|
|:--------------------------------|:------------------------------------------------------------------------|
|
||||||
| [`alpha`](compose_alpha.md) | Experimental commands |
|
| [`alpha`](compose_alpha.md) | Experimental commands |
|
||||||
| [`build`](compose_build.md) | Build or rebuild services |
|
| [`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 |
|
| [`cp`](compose_cp.md) | Copy files/folders between a service container and the local filesystem |
|
||||||
| [`create`](compose_create.md) | Creates containers for a service. |
|
| [`create`](compose_create.md) | Creates containers for a service. |
|
||||||
| [`down`](compose_down.md) | Stop and remove containers, networks |
|
| [`down`](compose_down.md) | Stop and remove containers, networks |
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
# docker compose convert
|
# docker compose convert
|
||||||
|
|
||||||
<!---MARKER_GEN_START-->
|
<!---MARKER_GEN_START-->
|
||||||
Converts the compose file to platform's canonical format
|
Parse, resolve and render compose file in canonical format
|
||||||
|
|
||||||
### Aliases
|
### Aliases
|
||||||
|
|
||||||
`docker compose convert`, `docker compose config`
|
`docker compose config`, `docker compose convert`
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
@ -29,8 +29,6 @@ Converts the compose file to platform's canonical format
|
|||||||
|
|
||||||
## Description
|
## 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
|
it merges the Compose files set by `-f` flags, resolves variables in the Compose file, and expands short-notation into
|
||||||
the canonical format.
|
the canonical format.
|
||||||
|
|
||||||
To allow smooth migration from docker-compose, this subcommand declares alias `docker compose config`
|
|
@ -115,7 +115,7 @@ pname: docker
|
|||||||
plink: docker.yaml
|
plink: docker.yaml
|
||||||
cname:
|
cname:
|
||||||
- docker compose build
|
- docker compose build
|
||||||
- docker compose convert
|
- docker compose config
|
||||||
- docker compose cp
|
- docker compose cp
|
||||||
- docker compose create
|
- docker compose create
|
||||||
- docker compose down
|
- docker compose down
|
||||||
@ -141,7 +141,7 @@ cname:
|
|||||||
- docker compose version
|
- docker compose version
|
||||||
clink:
|
clink:
|
||||||
- docker_compose_build.yaml
|
- docker_compose_build.yaml
|
||||||
- docker_compose_convert.yaml
|
- docker_compose_config.yaml
|
||||||
- docker_compose_cp.yaml
|
- docker_compose_cp.yaml
|
||||||
- docker_compose_create.yaml
|
- docker_compose_create.yaml
|
||||||
- docker_compose_down.yaml
|
- docker_compose_down.yaml
|
||||||
|
138
docs/reference/docker_compose_config.yaml
Normal file
138
docs/reference/docker_compose_config.yaml
Normal file
@ -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
|
||||||
|
|
@ -52,7 +52,7 @@ type Service interface {
|
|||||||
// List executes the equivalent to a `docker stack ls`
|
// List executes the equivalent to a `docker stack ls`
|
||||||
List(ctx context.Context, options ListOptions) ([]Stack, error)
|
List(ctx context.Context, options ListOptions) ([]Stack, error)
|
||||||
// Convert translate compose model into backend's native format
|
// 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 executes the equivalent to a `compose kill`
|
||||||
Kill(ctx context.Context, projectName string, options KillOptions) error
|
Kill(ctx context.Context, projectName string, options KillOptions) error
|
||||||
// RunOneOffContainer creates a service oneoff container and starts its dependencies
|
// RunOneOffContainer creates a service oneoff container and starts its dependencies
|
||||||
@ -185,8 +185,8 @@ type DownOptions struct {
|
|||||||
Volumes bool
|
Volumes bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConvertOptions group options of the Convert API
|
// ConfigOptions group options of the Config API
|
||||||
type ConvertOptions struct {
|
type ConfigOptions struct {
|
||||||
// Format define the output format used to dump converted application model (json|yaml)
|
// Format define the output format used to dump converted application model (json|yaml)
|
||||||
Format string
|
Format string
|
||||||
// Output defines the path to save the application model
|
// Output defines the path to save the application model
|
||||||
|
@ -38,7 +38,7 @@ type ServiceProxy struct {
|
|||||||
LogsFn func(ctx context.Context, projectName string, consumer LogConsumer, options LogOptions) error
|
LogsFn func(ctx context.Context, projectName string, consumer LogConsumer, options LogOptions) error
|
||||||
PsFn func(ctx context.Context, projectName string, options PsOptions) ([]ContainerSummary, error)
|
PsFn func(ctx context.Context, projectName string, options PsOptions) ([]ContainerSummary, error)
|
||||||
ListFn func(ctx context.Context, options ListOptions) ([]Stack, 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
|
KillFn func(ctx context.Context, project string, options KillOptions) error
|
||||||
RunOneOffContainerFn func(ctx context.Context, project *types.Project, opts RunOptions) (int, error)
|
RunOneOffContainerFn func(ctx context.Context, project *types.Project, opts RunOptions) (int, error)
|
||||||
RemoveFn func(ctx context.Context, project string, options RemoveOptions) error
|
RemoveFn func(ctx context.Context, project string, options RemoveOptions) error
|
||||||
@ -78,7 +78,7 @@ func (s *ServiceProxy) WithService(service Service) *ServiceProxy {
|
|||||||
s.LogsFn = service.Logs
|
s.LogsFn = service.Logs
|
||||||
s.PsFn = service.Ps
|
s.PsFn = service.Ps
|
||||||
s.ListFn = service.List
|
s.ListFn = service.List
|
||||||
s.ConvertFn = service.Convert
|
s.ConfigFn = service.Config
|
||||||
s.KillFn = service.Kill
|
s.KillFn = service.Kill
|
||||||
s.RunOneOffContainerFn = service.RunOneOffContainer
|
s.RunOneOffContainerFn = service.RunOneOffContainer
|
||||||
s.RemoveFn = service.Remove
|
s.RemoveFn = service.Remove
|
||||||
@ -214,14 +214,14 @@ func (s *ServiceProxy) List(ctx context.Context, options ListOptions) ([]Stack,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert implements Service interface
|
// Convert implements Service interface
|
||||||
func (s *ServiceProxy) Convert(ctx context.Context, project *types.Project, options ConvertOptions) ([]byte, error) {
|
func (s *ServiceProxy) Config(ctx context.Context, project *types.Project, options ConfigOptions) ([]byte, error) {
|
||||||
if s.ConvertFn == nil {
|
if s.ConfigFn == nil {
|
||||||
return nil, ErrNotImplemented
|
return nil, ErrNotImplemented
|
||||||
}
|
}
|
||||||
for _, i := range s.interceptors {
|
for _, i := range s.interceptors {
|
||||||
i(ctx, project)
|
i(ctx, project)
|
||||||
}
|
}
|
||||||
return s.ConvertFn(ctx, project, options)
|
return s.ConfigFn(ctx, project, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kill implements Service interface
|
// Kill implements Service interface
|
||||||
|
@ -120,7 +120,7 @@ func getContainerNameWithoutProject(c moby.Container) string {
|
|||||||
return name
|
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 {
|
if options.ResolveImageDigests {
|
||||||
info, err := s.apiClient().Info(ctx)
|
info, err := s.apiClient().Info(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -50,19 +50,19 @@ func (mr *MockServiceMockRecorder) Build(ctx, project, options interface{}) *gom
|
|||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Build", reflect.TypeOf((*MockService)(nil).Build), ctx, project, options)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Build", reflect.TypeOf((*MockService)(nil).Build), ctx, project, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert mocks base method.
|
// Config mocks base method.
|
||||||
func (m *MockService) Convert(ctx context.Context, project *types.Project, options api.ConvertOptions) ([]byte, error) {
|
func (m *MockService) Config(ctx context.Context, project *types.Project, options api.ConfigOptions) ([]byte, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "Convert", ctx, project, options)
|
ret := m.ctrl.Call(m, "Config", ctx, project, options)
|
||||||
ret0, _ := ret[0].([]byte)
|
ret0, _ := ret[0].([]byte)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert indicates an expected call of Convert.
|
// Config indicates an expected call of Config.
|
||||||
func (mr *MockServiceMockRecorder) Convert(ctx, project, options interface{}) *gomock.Call {
|
func (mr *MockServiceMockRecorder) Config(ctx, project, options interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Convert", reflect.TypeOf((*MockService)(nil).Convert), ctx, project, options)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Config", reflect.TypeOf((*MockService)(nil).Config), ctx, project, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy mocks base method.
|
// Copy mocks base method.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user