mirror of https://github.com/docker/compose.git
apply config options for pseudo-subcommands
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
24ff098252
commit
f3e543fd6a
|
@ -32,7 +32,7 @@ import (
|
||||||
"github.com/docker/compose/v2/pkg/compose"
|
"github.com/docker/compose/v2/pkg/compose"
|
||||||
)
|
)
|
||||||
|
|
||||||
type convertOptions struct {
|
type configOptions struct {
|
||||||
*ProjectOptions
|
*ProjectOptions
|
||||||
Format string
|
Format string
|
||||||
Output string
|
Output string
|
||||||
|
@ -48,8 +48,17 @@ type convertOptions struct {
|
||||||
noConsistency bool
|
noConsistency bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *configOptions) ToProject(services []string) (*types.Project, error) {
|
||||||
|
return o.ProjectOptions.ToProject(services,
|
||||||
|
cli.WithInterpolation(!o.noInterpolate),
|
||||||
|
cli.WithResolvedPaths(true),
|
||||||
|
cli.WithNormalization(!o.noNormalize),
|
||||||
|
cli.WithConsistency(!o.noConsistency),
|
||||||
|
cli.WithDiscardEnvFile)
|
||||||
|
}
|
||||||
|
|
||||||
func convertCommand(p *ProjectOptions, streams api.Streams, backend api.Service) *cobra.Command {
|
func convertCommand(p *ProjectOptions, streams api.Streams, backend api.Service) *cobra.Command {
|
||||||
opts := convertOptions{
|
opts := configOptions{
|
||||||
ProjectOptions: p,
|
ProjectOptions: p,
|
||||||
}
|
}
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
@ -108,14 +117,9 @@ func convertCommand(p *ProjectOptions, streams api.Streams, backend api.Service)
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func runConfig(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 configOptions, services []string) error {
|
||||||
var content []byte
|
var content []byte
|
||||||
project, err := opts.ToProject(services,
|
project, err := opts.ToProject(services)
|
||||||
cli.WithInterpolation(!opts.noInterpolate),
|
|
||||||
cli.WithResolvedPaths(true),
|
|
||||||
cli.WithNormalization(!opts.noNormalize),
|
|
||||||
cli.WithConsistency(!opts.noConsistency),
|
|
||||||
cli.WithDiscardEnvFile)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -144,7 +148,7 @@ func runConfig(ctx context.Context, streams api.Streams, backend api.Service, op
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func runServices(streams api.Streams, opts convertOptions) error {
|
func runServices(streams api.Streams, opts configOptions) error {
|
||||||
project, err := opts.ToProject(nil)
|
project, err := opts.ToProject(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -155,7 +159,7 @@ func runServices(streams api.Streams, opts convertOptions) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func runVolumes(streams api.Streams, opts convertOptions) error {
|
func runVolumes(streams api.Streams, opts configOptions) error {
|
||||||
project, err := opts.ToProject(nil)
|
project, err := opts.ToProject(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -166,7 +170,7 @@ func runVolumes(streams api.Streams, opts convertOptions) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func runHash(streams api.Streams, opts convertOptions) error {
|
func runHash(streams api.Streams, opts configOptions) error {
|
||||||
var services []string
|
var services []string
|
||||||
if opts.hash != "*" {
|
if opts.hash != "*" {
|
||||||
services = append(services, strings.Split(opts.hash, ",")...)
|
services = append(services, strings.Split(opts.hash, ",")...)
|
||||||
|
@ -198,7 +202,7 @@ func runHash(streams api.Streams, opts convertOptions) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func runProfiles(streams api.Streams, opts convertOptions, services []string) error {
|
func runProfiles(streams api.Streams, opts configOptions, services []string) error {
|
||||||
set := map[string]struct{}{}
|
set := map[string]struct{}{}
|
||||||
project, err := opts.ToProject(services)
|
project, err := opts.ToProject(services)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -220,7 +224,7 @@ func runProfiles(streams api.Streams, opts convertOptions, services []string) er
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func runConfigImages(streams api.Streams, opts convertOptions, services []string) error {
|
func runConfigImages(streams api.Streams, opts configOptions, services []string) error {
|
||||||
project, err := opts.ToProject(services)
|
project, err := opts.ToProject(services)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue