mirror of https://github.com/docker/compose.git
add dry-run flag
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
parent
5a2b7b83cd
commit
fbf845c5f8
|
@ -261,6 +261,7 @@ func RootCommand(streams api.Streams, backend api.Service) *cobra.Command { //no
|
||||||
verbose bool
|
verbose bool
|
||||||
version bool
|
version bool
|
||||||
parallel int
|
parallel int
|
||||||
|
dryRun bool
|
||||||
)
|
)
|
||||||
c := &cobra.Command{
|
c := &cobra.Command{
|
||||||
Short: "Docker Compose",
|
Short: "Docker Compose",
|
||||||
|
@ -335,6 +336,7 @@ func RootCommand(streams api.Streams, backend api.Service) *cobra.Command { //no
|
||||||
if parallel > 0 {
|
if parallel > 0 {
|
||||||
backend.MaxConcurrency(parallel)
|
backend.MaxConcurrency(parallel)
|
||||||
}
|
}
|
||||||
|
backend.DryRunMode(dryRun)
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -389,6 +391,8 @@ func RootCommand(streams api.Streams, backend api.Service) *cobra.Command { //no
|
||||||
c.Flags().MarkHidden("no-ansi") //nolint:errcheck
|
c.Flags().MarkHidden("no-ansi") //nolint:errcheck
|
||||||
c.Flags().BoolVar(&verbose, "verbose", false, "Show more output")
|
c.Flags().BoolVar(&verbose, "verbose", false, "Show more output")
|
||||||
c.Flags().MarkHidden("verbose") //nolint:errcheck
|
c.Flags().MarkHidden("verbose") //nolint:errcheck
|
||||||
|
c.Flags().BoolVar(&dryRun, "dry-run", false, "Execute command in dry run mode")
|
||||||
|
c.Flags().MarkHidden("dry-run") //nolint:errcheck
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ Docker Compose
|
||||||
|:-----------------------|:--------------|:--------|:----------------------------------------------------------------------------------------------------|
|
|:-----------------------|:--------------|:--------|:----------------------------------------------------------------------------------------------------|
|
||||||
| `--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 |
|
||||||
| `--env-file` | `string` | | Specify an alternate environment file. |
|
| `--env-file` | `string` | | Specify an alternate environment file. |
|
||||||
| `-f`, `--file` | `stringArray` | | Compose configuration files |
|
| `-f`, `--file` | `stringArray` | | Compose configuration files |
|
||||||
| `--parallel` | `int` | `-1` | Control max parallelism, -1 for unlimited |
|
| `--parallel` | `int` | `-1` | Control max parallelism, -1 for unlimited |
|
||||||
|
|
|
@ -178,6 +178,16 @@ options:
|
||||||
experimentalcli: false
|
experimentalcli: false
|
||||||
kubernetes: false
|
kubernetes: false
|
||||||
swarm: false
|
swarm: false
|
||||||
|
- option: dry-run
|
||||||
|
value_type: bool
|
||||||
|
default_value: "false"
|
||||||
|
description: Execute command in dry run mode
|
||||||
|
deprecated: false
|
||||||
|
hidden: false
|
||||||
|
experimental: false
|
||||||
|
experimentalcli: false
|
||||||
|
kubernetes: false
|
||||||
|
swarm: false
|
||||||
- option: env-file
|
- option: env-file
|
||||||
value_type: string
|
value_type: string
|
||||||
description: Specify an alternate environment file.
|
description: Specify an alternate environment file.
|
||||||
|
|
|
@ -77,6 +77,8 @@ type Service interface {
|
||||||
Images(ctx context.Context, projectName string, options ImagesOptions) ([]ImageSummary, error)
|
Images(ctx context.Context, projectName string, options ImagesOptions) ([]ImageSummary, error)
|
||||||
// MaxConcurrency defines upper limit for concurrent operations against engine API
|
// MaxConcurrency defines upper limit for concurrent operations against engine API
|
||||||
MaxConcurrency(parallel int)
|
MaxConcurrency(parallel int)
|
||||||
|
// DryRunMode defines if dry run applies to the command
|
||||||
|
DryRunMode(dryRun bool)
|
||||||
// Watch services' development context and sync/notify/rebuild/restart on changes
|
// Watch services' development context and sync/notify/rebuild/restart on changes
|
||||||
Watch(ctx context.Context, project *types.Project, services []string, options WatchOptions) error
|
Watch(ctx context.Context, project *types.Project, services []string, options WatchOptions) error
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,7 @@ type ServiceProxy struct {
|
||||||
ImagesFn func(ctx context.Context, projectName string, options ImagesOptions) ([]ImageSummary, error)
|
ImagesFn func(ctx context.Context, projectName string, options ImagesOptions) ([]ImageSummary, error)
|
||||||
WatchFn func(ctx context.Context, project *types.Project, services []string, options WatchOptions) error
|
WatchFn func(ctx context.Context, project *types.Project, services []string, options WatchOptions) error
|
||||||
MaxConcurrencyFn func(parallel int)
|
MaxConcurrencyFn func(parallel int)
|
||||||
|
DryRunModeFn func(dryRun bool)
|
||||||
interceptors []Interceptor
|
interceptors []Interceptor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,3 +325,7 @@ func (s *ServiceProxy) Watch(ctx context.Context, project *types.Project, servic
|
||||||
func (s *ServiceProxy) MaxConcurrency(i int) {
|
func (s *ServiceProxy) MaxConcurrency(i int) {
|
||||||
s.MaxConcurrencyFn(i)
|
s.MaxConcurrencyFn(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *ServiceProxy) DryRunMode(dryRun bool) {
|
||||||
|
s.DryRunModeFn(dryRun)
|
||||||
|
}
|
||||||
|
|
|
@ -43,12 +43,14 @@ func NewComposeService(dockerCli command.Cli) api.Service {
|
||||||
return &composeService{
|
return &composeService{
|
||||||
dockerCli: dockerCli,
|
dockerCli: dockerCli,
|
||||||
maxConcurrency: -1,
|
maxConcurrency: -1,
|
||||||
|
dryRun: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type composeService struct {
|
type composeService struct {
|
||||||
dockerCli command.Cli
|
dockerCli command.Cli
|
||||||
maxConcurrency int
|
maxConcurrency int
|
||||||
|
dryRun bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *composeService) apiClient() client.APIClient {
|
func (s *composeService) apiClient() client.APIClient {
|
||||||
|
@ -63,6 +65,10 @@ func (s *composeService) MaxConcurrency(i int) {
|
||||||
s.maxConcurrency = i
|
s.maxConcurrency = i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *composeService) DryRunMode(dryRun bool) {
|
||||||
|
s.dryRun = dryRun
|
||||||
|
}
|
||||||
|
|
||||||
func (s *composeService) stdout() *streams.Out {
|
func (s *composeService) stdout() *streams.Out {
|
||||||
return s.dockerCli.Out()
|
return s.dockerCli.Out()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue