mirror of https://github.com/docker/compose.git
Merge pull request #9168 from KoditkarVedant/9089-add-support-to-docker-compose-push-quiet-option
Add support to push images quietly via compose cli 🤫
This commit is contained in:
commit
1c14d30777
|
@ -29,6 +29,7 @@ type pushOptions struct {
|
||||||
composeOptions
|
composeOptions
|
||||||
|
|
||||||
Ignorefailures bool
|
Ignorefailures bool
|
||||||
|
Quiet bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func pushCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
func pushCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||||
|
@ -44,6 +45,7 @@ func pushCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||||
ValidArgsFunction: completeServiceNames(p),
|
ValidArgsFunction: completeServiceNames(p),
|
||||||
}
|
}
|
||||||
pushCmd.Flags().BoolVar(&opts.Ignorefailures, "ignore-push-failures", false, "Push what it can and ignores images with push failures")
|
pushCmd.Flags().BoolVar(&opts.Ignorefailures, "ignore-push-failures", false, "Push what it can and ignores images with push failures")
|
||||||
|
pushCmd.Flags().BoolVarP(&opts.Quiet, "quiet", "q", false, "Push without printing progress information")
|
||||||
|
|
||||||
return pushCmd
|
return pushCmd
|
||||||
}
|
}
|
||||||
|
@ -56,5 +58,6 @@ func runPush(ctx context.Context, backend api.Service, opts pushOptions, service
|
||||||
|
|
||||||
return backend.Push(ctx, project, api.PushOptions{
|
return backend.Push(ctx, project, api.PushOptions{
|
||||||
IgnoreFailures: opts.Ignorefailures,
|
IgnoreFailures: opts.Ignorefailures,
|
||||||
|
Quiet: opts.Quiet,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ Push service images
|
||||||
| Name | Type | Default | Description |
|
| Name | Type | Default | Description |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| `--ignore-push-failures` | | | Push what it can and ignores images with push failures |
|
| `--ignore-push-failures` | | | Push what it can and ignores images with push failures |
|
||||||
|
| `-q`, `--quiet` | | | Push without printing progress information |
|
||||||
|
|
||||||
|
|
||||||
<!---MARKER_GEN_END-->
|
<!---MARKER_GEN_END-->
|
||||||
|
|
|
@ -33,6 +33,17 @@ options:
|
||||||
experimentalcli: false
|
experimentalcli: false
|
||||||
kubernetes: false
|
kubernetes: false
|
||||||
swarm: false
|
swarm: false
|
||||||
|
- option: quiet
|
||||||
|
shorthand: q
|
||||||
|
value_type: bool
|
||||||
|
default_value: "false"
|
||||||
|
description: Push without printing progress information
|
||||||
|
deprecated: false
|
||||||
|
hidden: false
|
||||||
|
experimental: false
|
||||||
|
experimentalcli: false
|
||||||
|
kubernetes: false
|
||||||
|
swarm: false
|
||||||
deprecated: false
|
deprecated: false
|
||||||
experimental: false
|
experimental: false
|
||||||
experimentalcli: false
|
experimentalcli: false
|
||||||
|
|
|
@ -183,6 +183,7 @@ type ConvertOptions struct {
|
||||||
|
|
||||||
// PushOptions group options of the Push API
|
// PushOptions group options of the Push API
|
||||||
type PushOptions struct {
|
type PushOptions struct {
|
||||||
|
Quiet bool
|
||||||
IgnoreFailures bool
|
IgnoreFailures bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *composeService) Push(ctx context.Context, project *types.Project, options api.PushOptions) error {
|
func (s *composeService) Push(ctx context.Context, project *types.Project, options api.PushOptions) error {
|
||||||
|
if options.Quiet {
|
||||||
|
return s.push(ctx, project, options)
|
||||||
|
}
|
||||||
return progress.Run(ctx, func(ctx context.Context) error {
|
return progress.Run(ctx, func(ctx context.Context) error {
|
||||||
return s.push(ctx, project, options)
|
return s.push(ctx, project, options)
|
||||||
})
|
})
|
||||||
|
@ -65,7 +68,7 @@ func (s *composeService) push(ctx context.Context, project *types.Project, optio
|
||||||
}
|
}
|
||||||
service := service
|
service := service
|
||||||
eg.Go(func() error {
|
eg.Go(func() error {
|
||||||
err := s.pushServiceImage(ctx, service, info, s.configFile(), w)
|
err := s.pushServiceImage(ctx, service, info, s.configFile(), w, options.Quiet)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !options.IgnoreFailures {
|
if !options.IgnoreFailures {
|
||||||
return err
|
return err
|
||||||
|
@ -78,7 +81,7 @@ func (s *composeService) push(ctx context.Context, project *types.Project, optio
|
||||||
return eg.Wait()
|
return eg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *composeService) pushServiceImage(ctx context.Context, service types.ServiceConfig, info moby.Info, configFile driver.Auth, w progress.Writer) error {
|
func (s *composeService) pushServiceImage(ctx context.Context, service types.ServiceConfig, info moby.Info, configFile driver.Auth, w progress.Writer, quietPush bool) error {
|
||||||
ref, err := reference.ParseNormalizedNamed(service.Image)
|
ref, err := reference.ParseNormalizedNamed(service.Image)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -121,7 +124,10 @@ func (s *composeService) pushServiceImage(ctx context.Context, service types.Ser
|
||||||
if jm.Error != nil {
|
if jm.Error != nil {
|
||||||
return errors.New(jm.Error.Message)
|
return errors.New(jm.Error.Message)
|
||||||
}
|
}
|
||||||
toPushProgressEvent(service.Name, jm, w)
|
|
||||||
|
if !quietPush {
|
||||||
|
toPushProgressEvent(service.Name, jm, w)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue