mirror of https://github.com/docker/compose.git
				
				
				
			introduce --all-resources to _not_ exclude resources not used by services
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
		
							parent
							
								
									29692b5921
								
							
						
					
					
						commit
						865a64afea
					
				|  | @ -132,6 +132,7 @@ type ProjectOptions struct { | ||||||
| 	Compatibility bool | 	Compatibility bool | ||||||
| 	Progress      string | 	Progress      string | ||||||
| 	Offline       bool | 	Offline       bool | ||||||
|  | 	All           bool | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // ProjectFunc does stuff within a types.Project
 | // ProjectFunc does stuff within a types.Project
 | ||||||
|  | @ -175,6 +176,7 @@ func (o *ProjectOptions) addProjectFlags(f *pflag.FlagSet) { | ||||||
| 	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", 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.MarkHidden("workdir") | 	_ = f.MarkHidden("workdir") | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -231,9 +233,8 @@ func (o *ProjectOptions) ToModel(ctx context.Context, dockerCli command.Cli, ser | ||||||
| 	return options.LoadModel(ctx) | 	return options.LoadModel(ctx) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (o *ProjectOptions) ToProject(ctx context.Context, dockerCli command.Cli, services []string, po ...cli.ProjectOptionsFn) (*types.Project, tracing.Metrics, error) { | func (o *ProjectOptions) ToProject(ctx context.Context, dockerCli command.Cli, services []string, po ...cli.ProjectOptionsFn) (*types.Project, tracing.Metrics, error) { //nolint:gocyclo
 | ||||||
| 	var metrics tracing.Metrics | 	var metrics tracing.Metrics | ||||||
| 
 |  | ||||||
| 	remotes := o.remoteLoaders(dockerCli) | 	remotes := o.remoteLoaders(dockerCli) | ||||||
| 	for _, r := range remotes { | 	for _, r := range remotes { | ||||||
| 		po = append(po, cli.WithResourceLoader(r)) | 		po = append(po, cli.WithResourceLoader(r)) | ||||||
|  | @ -300,7 +301,9 @@ func (o *ProjectOptions) ToProject(ctx context.Context, dockerCli command.Cli, s | ||||||
| 		project.Services[name] = s | 		project.Services[name] = s | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	project = project.WithoutUnnecessaryResources() | 	if !o.All { | ||||||
|  | 		project = project.WithoutUnnecessaryResources() | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
| 	project, err = project.WithSelectedServices(services) | 	project, err = project.WithSelectedServices(services) | ||||||
| 	return project, metrics, err | 	return project, metrics, err | ||||||
|  |  | ||||||
|  | @ -125,6 +125,10 @@ func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service, ex | ||||||
| 
 | 
 | ||||||
| 			up.validateNavigationMenu(dockerCli, experiments) | 			up.validateNavigationMenu(dockerCli, experiments) | ||||||
| 
 | 
 | ||||||
|  | 			if !p.All && len(project.Services) == 0 { | ||||||
|  | 				return fmt.Errorf("no service selected") | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
| 			return runUp(ctx, dockerCli, backend, create, up, build, project, services) | 			return runUp(ctx, dockerCli, backend, create, up, build, project, services) | ||||||
| 		}), | 		}), | ||||||
| 		ValidArgsFunction: completeServiceNames(dockerCli, p), | 		ValidArgsFunction: completeServiceNames(dockerCli, p), | ||||||
|  | @ -205,10 +209,6 @@ func runUp( | ||||||
| 	project *types.Project, | 	project *types.Project, | ||||||
| 	services []string, | 	services []string, | ||||||
| ) error { | ) error { | ||||||
| 	if len(project.Services) == 0 { |  | ||||||
| 		return fmt.Errorf("no service selected") |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	err := createOptions.Apply(project) | 	err := createOptions.Apply(project) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return err | 		return err | ||||||
|  |  | ||||||
|  | @ -43,6 +43,7 @@ Define and run multi-container applications with Docker | ||||||
| 
 | 
 | ||||||
| | Name                   | Type          | Default | Description                                                                                         | | | Name                   | Type          | Default | Description                                                                                         | | ||||||
| |:-----------------------|:--------------|:--------|:----------------------------------------------------------------------------------------------------| | |:-----------------------|:--------------|:--------|:----------------------------------------------------------------------------------------------------| | ||||||
|  | | `--all-resources`      |               |         | Include all resources, even those not used by services                                              | | ||||||
| | `--ansi`               | `string`      | `auto`  | Control when to print ANSI control characters ("never"\|"always"\|"auto")                           | | | `--ansi`               | `string`      | `auto`  | Control when to print ANSI control characters ("never"\|"always"\|"auto")                           | | ||||||
| | `--compatibility`      |               |         | Run compose in backward compatibility mode                                                          | | | `--compatibility`      |               |         | Run compose in backward compatibility mode                                                          | | ||||||
| | `--dry-run`            |               |         | Execute command in dry run mode                                                                     | | | `--dry-run`            |               |         | Execute command in dry run mode                                                                     | | ||||||
|  |  | ||||||
|  | @ -208,6 +208,16 @@ clink: | ||||||
|     - docker_compose_wait.yaml |     - docker_compose_wait.yaml | ||||||
|     - docker_compose_watch.yaml |     - docker_compose_watch.yaml | ||||||
| options: | options: | ||||||
|  |     - option: all-resources | ||||||
|  |       value_type: bool | ||||||
|  |       default_value: "false" | ||||||
|  |       description: Include all resources, even those not used by services | ||||||
|  |       deprecated: false | ||||||
|  |       hidden: false | ||||||
|  |       experimental: false | ||||||
|  |       experimentalcli: false | ||||||
|  |       kubernetes: false | ||||||
|  |       swarm: false | ||||||
|     - option: ansi |     - option: ansi | ||||||
|       value_type: string |       value_type: string | ||||||
|       default_value: auto |       default_value: auto | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue