mirror of https://github.com/docker/compose.git
introduce --resolve-paths and restore compose v1 behavior
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
1a73d1412d
commit
010776f6db
|
@ -21,6 +21,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/compose-spec/compose-go/cli"
|
||||
"github.com/compose-spec/compose-go/types"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
|
@ -83,7 +84,7 @@ func buildCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
|||
}
|
||||
|
||||
func runBuild(ctx context.Context, backend api.Service, opts buildOptions, services []string) error {
|
||||
project, err := opts.toProject(services)
|
||||
project, err := opts.toProject(services, cli.WithResolvedPaths(true))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ func (o *projectOptions) WithProject(fn ProjectFunc) func(cmd *cobra.Command, ar
|
|||
// WithServices creates a cobra run command from a ProjectFunc based on configured project options and selected services
|
||||
func (o *projectOptions) WithServices(fn ProjectServicesFunc) func(cmd *cobra.Command, args []string) error {
|
||||
return Adapt(func(ctx context.Context, args []string) error {
|
||||
project, err := o.toProject(args)
|
||||
project, err := o.toProject(args, cli.WithResolvedPaths(true))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -39,15 +39,15 @@ import (
|
|||
|
||||
type convertOptions struct {
|
||||
*projectOptions
|
||||
Format string
|
||||
Output string
|
||||
quiet bool
|
||||
resolve bool
|
||||
noInterpolate bool
|
||||
services bool
|
||||
volumes bool
|
||||
profiles bool
|
||||
hash string
|
||||
Format string
|
||||
Output string
|
||||
quiet bool
|
||||
resolveImageDigests bool
|
||||
noInterpolate bool
|
||||
services bool
|
||||
volumes bool
|
||||
profiles bool
|
||||
hash string
|
||||
}
|
||||
|
||||
var addFlagsFuncs []func(cmd *cobra.Command, opts *convertOptions)
|
||||
|
@ -90,7 +90,7 @@ func convertCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
|||
}
|
||||
flags := cmd.Flags()
|
||||
flags.StringVar(&opts.Format, "format", "yaml", "Format the output. Values: [yaml | json]")
|
||||
flags.BoolVar(&opts.resolve, "resolve-image-digests", false, "Pin image tags to digests.")
|
||||
flags.BoolVar(&opts.resolveImageDigests, "resolve-image-digests", false, "Pin image tags to digests.")
|
||||
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Only validate the configuration, don't print anything.")
|
||||
flags.BoolVar(&opts.noInterpolate, "no-interpolate", false, "Don't interpolate environment variables.")
|
||||
|
||||
|
@ -108,12 +108,12 @@ func convertCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
|||
|
||||
func runConvert(ctx context.Context, backend api.Service, opts convertOptions, services []string) error {
|
||||
var json []byte
|
||||
project, err := opts.toProject(services, cli.WithInterpolation(!opts.noInterpolate))
|
||||
project, err := opts.toProject(services, cli.WithInterpolation(!opts.noInterpolate), cli.WithResolvedPaths(false))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if opts.resolve {
|
||||
if opts.resolveImageDigests {
|
||||
configFile := cliconfig.LoadDefaultConfigFile(os.Stderr)
|
||||
|
||||
resolver := remotes.CreateResolver(configFile)
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
cgo "github.com/compose-spec/compose-go/cli"
|
||||
"github.com/containerd/console"
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -77,7 +78,7 @@ func execCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
|||
}
|
||||
|
||||
func runExec(ctx context.Context, backend api.Service, opts execOpts) error {
|
||||
project, err := opts.toProject(nil)
|
||||
project, err := opts.toProject(nil, cgo.WithResolvedPaths(true))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
|
||||
cgo "github.com/compose-spec/compose-go/cli"
|
||||
"github.com/compose-spec/compose-go/loader"
|
||||
"github.com/compose-spec/compose-go/types"
|
||||
"github.com/mattn/go-isatty"
|
||||
|
@ -120,7 +121,7 @@ func runCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
|||
return nil
|
||||
}),
|
||||
RunE: Adapt(func(ctx context.Context, args []string) error {
|
||||
project, err := p.toProject([]string{opts.Service})
|
||||
project, err := p.toProject([]string{opts.Service}, cgo.WithResolvedPaths(true))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
2
go.mod
2
go.mod
|
@ -6,7 +6,7 @@ require (
|
|||
github.com/AlecAivazis/survey/v2 v2.2.3
|
||||
github.com/buger/goterm v1.0.0
|
||||
github.com/cnabio/cnab-to-oci v0.3.1-beta1
|
||||
github.com/compose-spec/compose-go v0.0.0-20210901090333-feb401cda7f7
|
||||
github.com/compose-spec/compose-go v0.0.0-20210906143156-938b039f7805
|
||||
github.com/containerd/console v1.0.2
|
||||
github.com/containerd/containerd v1.5.4
|
||||
github.com/distribution/distribution/v3 v3.0.0-20210316161203-a01c71e2477e
|
||||
|
|
4
go.sum
4
go.sum
|
@ -192,8 +192,8 @@ github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnht
|
|||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
|
||||
github.com/codahale/hdrhistogram v0.0.0-20160425231609-f8ad88b59a58/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
|
||||
github.com/compose-spec/compose-go v0.0.0-20210901090333-feb401cda7f7 h1:wI9VC+EgX61YYB/xyQVb9BBfsFOklZ/BinipIpFcWn4=
|
||||
github.com/compose-spec/compose-go v0.0.0-20210901090333-feb401cda7f7/go.mod h1:Hnmn5ZCVA3sSBN2urjCZNNIyNqCPayRGH7PmMSaV2Q0=
|
||||
github.com/compose-spec/compose-go v0.0.0-20210906143156-938b039f7805 h1:iFShT4oPik+NnXdzksa4yLvJYDDZBPMjHPN3qtJaXPA=
|
||||
github.com/compose-spec/compose-go v0.0.0-20210906143156-938b039f7805/go.mod h1:Hnmn5ZCVA3sSBN2urjCZNNIyNqCPayRGH7PmMSaV2Q0=
|
||||
github.com/containerd/aufs v0.0.0-20200908144142-dab0cbea06f4/go.mod h1:nukgQABAEopAHvB6j7cnP5zJ+/3aVcE7hCYqvIwAHyE=
|
||||
github.com/containerd/aufs v0.0.0-20201003224125-76a6863f2989/go.mod h1:AkGGQs9NM2vtYHaUen+NljV0/baGCAPELGm2q9ZXpWU=
|
||||
github.com/containerd/aufs v0.0.0-20210316121734-20793ff83c97/go.mod h1:kL5kd6KM5TzQjR79jljyi4olc1Vrx6XBlcyj3gNv2PU=
|
||||
|
|
Loading…
Reference in New Issue