mirror of https://github.com/docker/compose.git
				
				
				
			Set --progress flag default value from env if provided
Signed-off-by: Anvar Umuraliev <an.umuraliev@gmail.com>
This commit is contained in:
		
							parent
							
								
									f8dae06df8
								
							
						
					
					
						commit
						5bb46035cf
					
				| 
						 | 
					@ -69,6 +69,8 @@ const (
 | 
				
			||||||
	ComposeEnvFiles = "COMPOSE_ENV_FILES"
 | 
						ComposeEnvFiles = "COMPOSE_ENV_FILES"
 | 
				
			||||||
	// ComposeMenu defines if the navigation menu should be rendered. Can be also set via --menu
 | 
						// ComposeMenu defines if the navigation menu should be rendered. Can be also set via --menu
 | 
				
			||||||
	ComposeMenu = "COMPOSE_MENU"
 | 
						ComposeMenu = "COMPOSE_MENU"
 | 
				
			||||||
 | 
						// ComposeProgress defines type of progress output, if --progress isn't used
 | 
				
			||||||
 | 
						ComposeProgress = "COMPOSE_PROGRESS"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// rawEnv load a dot env file using docker/cli key=value parser, without attempt to interpolate or evaluate values
 | 
					// rawEnv load a dot env file using docker/cli key=value parser, without attempt to interpolate or evaluate values
 | 
				
			||||||
| 
						 | 
					@ -228,7 +230,7 @@ func (o *ProjectOptions) addProjectFlags(f *pflag.FlagSet) {
 | 
				
			||||||
	f.StringVar(&o.ProjectDir, "project-directory", "", "Specify an alternate working directory\n(default: the path of the, first specified, Compose file)")
 | 
						f.StringVar(&o.ProjectDir, "project-directory", "", "Specify an alternate working directory\n(default: the path of the, first specified, Compose file)")
 | 
				
			||||||
	f.StringVar(&o.WorkDir, "workdir", "", "DEPRECATED! USE --project-directory INSTEAD.\nSpecify an alternate working directory\n(default: the path of the, first specified, Compose file)")
 | 
						f.StringVar(&o.WorkDir, "workdir", "", "DEPRECATED! USE --project-directory INSTEAD.\nSpecify an alternate working directory\n(default: the path of the, first specified, Compose file)")
 | 
				
			||||||
	f.BoolVar(&o.Compatibility, "compatibility", false, "Run compose in backward compatibility mode")
 | 
						f.BoolVar(&o.Compatibility, "compatibility", false, "Run compose in backward compatibility mode")
 | 
				
			||||||
	f.StringVar(&o.Progress, "progress", string(buildkit.AutoMode), fmt.Sprintf(`Set type of progress output (%s)`, strings.Join(printerModes, ", ")))
 | 
						f.StringVar(&o.Progress, "progress", defaultStringVar(ComposeProgress, string(buildkit.AutoMode)), fmt.Sprintf(`Set type of progress output (%s)`, strings.Join(printerModes, ", ")))
 | 
				
			||||||
	f.BoolVar(&o.All, "all-resources", false, "Include all resources, even those not used by services")
 | 
						f.BoolVar(&o.All, "all-resources", false, "Include all resources, even those not used by services")
 | 
				
			||||||
	_ = f.MarkHidden("workdir")
 | 
						_ = f.MarkHidden("workdir")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -240,6 +242,14 @@ func defaultStringArrayVar(env string) []string {
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// get default value for a command line flag from the env variable, if the env variable is not set, it returns the provided default value 'def'
 | 
				
			||||||
 | 
					func defaultStringVar(env, def string) string {
 | 
				
			||||||
 | 
						if v, ok := os.LookupEnv(env); ok {
 | 
				
			||||||
 | 
							return v
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return def
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (o *ProjectOptions) projectOrName(ctx context.Context, dockerCli command.Cli, services ...string) (*types.Project, string, error) {
 | 
					func (o *ProjectOptions) projectOrName(ctx context.Context, dockerCli command.Cli, services ...string) (*types.Project, string, error) {
 | 
				
			||||||
	name := o.ProjectName
 | 
						name := o.ProjectName
 | 
				
			||||||
	var project *types.Project
 | 
						var project *types.Project
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,7 +19,6 @@ package progress
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"context"
 | 
						"context"
 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
	"os"
 | 
					 | 
				
			||||||
	"sync"
 | 
						"sync"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/docker/cli/cli/streams"
 | 
						"github.com/docker/cli/cli/streams"
 | 
				
			||||||
| 
						 | 
					@ -122,9 +121,6 @@ func NewWriter(ctx context.Context, out *streams.Out, progressTitle string) (Wri
 | 
				
			||||||
	if !ok {
 | 
						if !ok {
 | 
				
			||||||
		dryRun = false
 | 
							dryRun = false
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if v, ok := os.LookupEnv("COMPOSE_PROGRESS"); ok && Mode == ModeAuto {
 | 
					 | 
				
			||||||
		Mode = v
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if Mode == ModeQuiet {
 | 
						if Mode == ModeQuiet {
 | 
				
			||||||
		return quiet{}, nil
 | 
							return quiet{}, nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue