1
0
mirror of https://github.com/docker/compose.git synced 2025-04-07 19:55:07 +02:00

Introduce --env-file

fixes 

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2021-01-19 11:01:52 +01:00
parent c881e22ab8
commit ed18cefc04
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E
5 changed files with 7 additions and 3 deletions

@ -33,6 +33,7 @@ type composeOptions struct {
WorkingDir string
ConfigPaths []string
Environment []string
EnvFile string
Format string
Detach bool
Build bool
@ -73,6 +74,7 @@ func (o *composeOptions) toProject() (*types.Project, error) {
func (o *composeOptions) toProjectOptions() (*cli.ProjectOptions, error) {
return cli.NewProjectOptions(o.ConfigPaths,
cli.WithOsEnv,
cli.WithEnvFile(o.EnvFile),
cli.WithDotEnv,
cli.WithEnv(o.Environment),
cli.WithWorkingDirectory(o.WorkingDir),

@ -40,6 +40,7 @@ func convertCommand() *cobra.Command {
convertCmd.Flags().StringVar(&opts.WorkingDir, "workdir", "", "Work dir")
convertCmd.Flags().StringArrayVarP(&opts.ConfigPaths, "file", "f", []string{}, "Compose configuration files")
convertCmd.Flags().StringArrayVarP(&opts.Environment, "environment", "e", []string{}, "Environment variables")
convertCmd.Flags().StringVar(&opts.EnvFile, "env-file", "", "Specify an alternate environment file.")
convertCmd.Flags().StringVar(&opts.Format, "format", "yaml", "Format the output. Values: [yaml | json]")
return convertCmd

@ -55,6 +55,7 @@ func upCommand(contextType string) *cobra.Command {
upCmd.Flags().StringVar(&opts.WorkingDir, "workdir", "", "Work dir")
upCmd.Flags().StringArrayVarP(&opts.ConfigPaths, "file", "f", []string{}, "Compose configuration files")
upCmd.Flags().StringArrayVarP(&opts.Environment, "environment", "e", []string{}, "Environment variables")
upCmd.Flags().StringVar(&opts.EnvFile, "env-file", "", "Specify an alternate environment file.")
upCmd.Flags().BoolVarP(&opts.Detach, "detach", "d", false, "Detached mode: Run containers in the background")
upCmd.Flags().BoolVar(&opts.Build, "build", false, "Build images before starting containers.")
upCmd.Flags().BoolVar(&opts.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file.")

2
go.mod

@ -17,7 +17,7 @@ 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-20210113150448-e0b1ffe70cc5
github.com/compose-spec/compose-go v0.0.0-20210119095023-cd294eea46e9
github.com/containerd/console v1.0.1
github.com/containerd/containerd v1.4.3
github.com/containerd/continuity v0.0.0-20200928162600-f2cc35102c2a // indirect

4
go.sum

@ -271,8 +271,8 @@ github.com/cnabio/cnab-to-oci v0.3.1-beta1/go.mod h1:8BomA5Vye+3V/Kd2NSFblCBmp1r
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
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-20210113150448-e0b1ffe70cc5 h1:YBR7Ds5WrY+FNxN2aRRZyEB1E86PD+g1O5RjK++acx8=
github.com/compose-spec/compose-go v0.0.0-20210113150448-e0b1ffe70cc5/go.mod h1:rz7rjxJGA/pWpLdBmDdqymGm2okEDYgBE7yx569xW+I=
github.com/compose-spec/compose-go v0.0.0-20210119095023-cd294eea46e9 h1:fk9KYzKkVy6q1ETSXOPDHxeoj2ZBKZFP27XVfVMRMUM=
github.com/compose-spec/compose-go v0.0.0-20210119095023-cd294eea46e9/go.mod h1:rz7rjxJGA/pWpLdBmDdqymGm2okEDYgBE7yx569xW+I=
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=