diff --git a/cli/cmd/compose/compose.go b/cli/cmd/compose/compose.go index e18c5c0b1..5eb155612 100644 --- a/cli/cmd/compose/compose.go +++ b/cli/cmd/compose/compose.go @@ -65,8 +65,8 @@ func (o *projectOptions) toProjectName() (string, error) { return project.Name, nil } -func (o *projectOptions) toProject(services []string) (*types.Project, error) { - options, err := o.toProjectOptions() +func (o *projectOptions) toProject(services []string, po ...cli.ProjectOptionsFn) (*types.Project, error) { + options, err := o.toProjectOptions(po...) if err != nil { return nil, err } @@ -90,13 +90,14 @@ func (o *projectOptions) toProject(services []string) (*types.Project, error) { return project, err } -func (o *projectOptions) toProjectOptions() (*cli.ProjectOptions, error) { +func (o *projectOptions) toProjectOptions(po ...cli.ProjectOptionsFn) (*cli.ProjectOptions, error) { return cli.NewProjectOptions(o.ConfigPaths, - cli.WithEnvFile(o.EnvFile), - cli.WithDotEnv, - cli.WithOsEnv, - cli.WithWorkingDirectory(o.ProjectDir), - cli.WithName(o.ProjectName)) + append(po, + cli.WithEnvFile(o.EnvFile), + cli.WithDotEnv, + cli.WithOsEnv, + cli.WithWorkingDirectory(o.ProjectDir), + cli.WithName(o.ProjectName))...) } // Command returns the compose command with its child commands diff --git a/cli/cmd/compose/convert.go b/cli/cmd/compose/convert.go index 5fac6ad49..e8a1298f2 100644 --- a/cli/cmd/compose/convert.go +++ b/cli/cmd/compose/convert.go @@ -25,6 +25,7 @@ import ( "strings" "github.com/cnabio/cnab-to-oci/remotes" + "github.com/compose-spec/compose-go/cli" "github.com/distribution/distribution/v3/reference" cliconfig "github.com/docker/cli/cli/config" "github.com/opencontainers/go-digest" @@ -38,13 +39,14 @@ import ( type convertOptions struct { *projectOptions - Format string - Output string - quiet bool - resolve bool - services bool - volumes bool - hash string + Format string + Output string + quiet bool + resolve bool + noInterpolate bool + services bool + volumes bool + hash string } var addFlagsFuncs []func(cmd *cobra.Command, opts *convertOptions) @@ -82,6 +84,7 @@ func convertCommand(p *projectOptions) *cobra.Command { 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.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.") flags.BoolVar(&opts.services, "services", false, "Print the service names, one per line.") flags.BoolVar(&opts.volumes, "volumes", false, "Print the volume names, one per line.") @@ -101,7 +104,7 @@ func runConvert(ctx context.Context, opts convertOptions, services []string) err return err } - project, err := opts.toProject(services) + project, err := opts.toProject(services, cli.WithInterpolation(!opts.noInterpolate)) if err != nil { return err } diff --git a/go.mod b/go.mod index 065567023..48f222c93 100644 --- a/go.mod +++ b/go.mod @@ -17,11 +17,11 @@ require ( github.com/awslabs/goformation/v4 v4.15.6 github.com/buger/goterm v0.0.0-20200322175922-2f3e71b85129 github.com/cnabio/cnab-to-oci v0.3.1-beta1 - github.com/compose-spec/compose-go v0.0.0-20210316123046-239a45752b0f + github.com/compose-spec/compose-go v0.0.0-20210322090015-6166d06f9ce2 github.com/containerd/console v1.0.1 github.com/containerd/containerd v1.4.3 github.com/containerd/continuity v0.0.0-20200928162600-f2cc35102c2a // indirect - github.com/distribution/distribution/v3 v3.0.0-20210209042832-22c074842eaa + github.com/distribution/distribution/v3 v3.0.0-20210316161203-a01c71e2477e github.com/docker/buildx v0.5.2-0.20210309210748-c9f02c32d495 github.com/docker/cli v20.10.3-0.20210127070556-d26bdfd4ea23+incompatible github.com/docker/docker v20.10.1+incompatible @@ -32,7 +32,7 @@ require ( github.com/gobwas/ws v1.0.4 github.com/golang/mock v1.4.4 github.com/golang/protobuf v1.4.3 - github.com/google/go-cmp v0.5.4 + github.com/google/go-cmp v0.5.5 github.com/hashicorp/go-multierror v1.1.0 github.com/hashicorp/go-uuid v1.0.2 github.com/iancoleman/strcase v0.1.2 @@ -49,13 +49,13 @@ require ( github.com/pkg/errors v0.9.1 github.com/prometheus/tsdb v0.10.0 github.com/sanathkr/go-yaml v0.0.0-20170819195128-ed9d249f429b - github.com/sirupsen/logrus v1.7.0 + github.com/sirupsen/logrus v1.8.1 github.com/spf13/cobra v1.1.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.6.1 github.com/valyala/fasttemplate v1.2.1 // indirect golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58 - golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 + golang.org/x/sync v0.0.0-20210220032951-036812b2e83c google.golang.org/grpc v1.33.2 google.golang.org/protobuf v1.25.0 gopkg.in/ini.v1 v1.62.0 diff --git a/go.sum b/go.sum index cf86da422..b9a2ae7ba 100644 --- a/go.sum +++ b/go.sum @@ -257,8 +257,9 @@ github.com/bombsimon/wsl/v2 v2.2.0/go.mod h1:Azh8c3XGEJl9LyX0/sFC+CKMc7Ssgua0g+6 github.com/bombsimon/wsl/v3 v3.0.0/go.mod h1:st10JtZYLE4D5sC7b8xV4zTKZwAQjCH/Hy2Pm1FNZIc= github.com/bombsimon/wsl/v3 v3.1.0/go.mod h1:st10JtZYLE4D5sC7b8xV4zTKZwAQjCH/Hy2Pm1FNZIc= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= -github.com/bshuster-repo/logrus-logstash-hook v0.4.1 h1:pgAtgj+A31JBVtEHu2uHuEx0n+2ukqUJnS2vVe5pQNA= github.com/bshuster-repo/logrus-logstash-hook v0.4.1/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk= +github.com/bshuster-repo/logrus-logstash-hook v1.0.0 h1:e+C0SB5R1pu//O4MQ3f9cFuPGoOVeF2fE4Og9otCc70= +github.com/bshuster-repo/logrus-logstash-hook v1.0.0/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk= github.com/buger/goterm v0.0.0-20200322175922-2f3e71b85129 h1:gfAMKE626QEuKG3si0pdTRcr/YEbBoxY+3GOH3gWvl4= github.com/buger/goterm v0.0.0-20200322175922-2f3e71b85129/go.mod h1:u9UyCz2eTrSGy6fbupqJ54eY5c4IC8gREQ1053dK12U= github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8= @@ -307,8 +308,8 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX 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/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/compose-spec/compose-go v0.0.0-20210316123046-239a45752b0f h1:bzO0YBNeACmWPuI6gmaRTlkpD3F8Gpcuu587Uf+h1ac= -github.com/compose-spec/compose-go v0.0.0-20210316123046-239a45752b0f/go.mod h1:iz28nqFmtFuYQxfzPb7zEceImHoVrWoumcBPQutHnQ8= +github.com/compose-spec/compose-go v0.0.0-20210322090015-6166d06f9ce2 h1:8t1noQjw1GkcYno4V93tBTR5w3RHDZre3JJpmaNWp0I= +github.com/compose-spec/compose-go v0.0.0-20210322090015-6166d06f9ce2/go.mod h1:6eIT9U2OgdHmkRD6szmqatCrWWEEUSwl/j2iJYH4jLo= github.com/containerd/cgroups v0.0.0-20190919134610-bf292b21730f/go.mod h1:OApqhQ4XNSNC13gXIwDjhOQxjWa/NxkwZXJ1EvqT0ko= github.com/containerd/cgroups v0.0.0-20200531161412-0dbf7f05ba59/go.mod h1:pA0z1pT8KYB3TCXK/ocprsh7MAkoW8bZVzPdih9snmM= github.com/containerd/cgroups v0.0.0-20200710171044-318312a37340 h1:9atoWyI9RtXFwf7UDbme/6M8Ud0rFrx+Q3ZWgSnsxtw= @@ -394,8 +395,8 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dimchansky/utfbom v1.1.0 h1:FcM3g+nofKgUteL8dm/UpdRXNC9KmADgTpLKsu0TRo4= github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8= -github.com/distribution/distribution/v3 v3.0.0-20210209042832-22c074842eaa h1:4D67sY0UhDO+F1EKq4dXzQhlRSK4/ZSoNnNvaDMyzBc= -github.com/distribution/distribution/v3 v3.0.0-20210209042832-22c074842eaa/go.mod h1:qW81H7oTHBUYY65QKDwObaF1CQJoc7Je0uc+n4Ar4OM= +github.com/distribution/distribution/v3 v3.0.0-20210316161203-a01c71e2477e h1:n81KvOMrLZa+VWHwST7dun9f0G98X3zREHS1ztYzZKU= +github.com/distribution/distribution/v3 v3.0.0-20210316161203-a01c71e2477e/go.mod h1:xpWTC2KnJMiDLkoawhsPQcXjvwATEBcbq0xevG2YR9M= github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= github.com/docker/buildx v0.5.2-0.20210309210748-c9f02c32d495 h1:bAIxNmEhw5aMebRNw8yxr2z3g0m7jArgbt0F6sOPXD4= github.com/docker/buildx v0.5.2-0.20210309210748-c9f02c32d495/go.mod h1:WadVNX2QxutvzYgtwu3jpYd0D/SKwQOrAipyrPHOEi8= @@ -710,8 +711,8 @@ github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-containerregistry v0.0.0-20191010200024-a3d713f9b7f8/go.mod h1:KyKXa9ciM8+lgMXwOVsXi7UxGrsf9mM61Mzs+xKUrKE= github.com/google/go-containerregistry v0.0.0-20191015185424-71da34e4d9b3/go.mod h1:ZXFeSndFcK4vB1NR4voH1Zm38K7ViUNiYtfIBDxrwf0= github.com/google/go-containerregistry v0.1.2/go.mod h1:GPivBPgdAyd2SU+vf6EpsgOtWDuPqjW0hJZt4rNdTZ4= @@ -852,8 +853,8 @@ github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJ github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/imdario/mergo v0.3.12-0.20210303221052-29fb3d3bdc55 h1:Z+928KmcMGWCKohke8GwDHOGQSlFQi2dg3uUbD5WDJA= -github.com/imdario/mergo v0.3.12-0.20210303221052-29fb3d3bdc55/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= +github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= @@ -1274,8 +1275,9 @@ github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= +github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v1.0.0 h1:UVQPSSmc3qtTi+zPPkCXvZX9VvW/xT/NsRvKfwY81a8= github.com/smartystreets/assertions v1.0.0/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= @@ -1605,8 +1607,9 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=