introduce run —quiet-pull to align with up

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2021-11-21 16:49:54 +01:00
parent 10cd7e130f
commit cbd3d37adf
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E
3 changed files with 6 additions and 1 deletions

View File

@ -54,6 +54,7 @@ type runOptions struct {
servicePorts bool servicePorts bool
name string name string
noDeps bool noDeps bool
quietPull bool
} }
func (opts runOptions) apply(project *types.Project) error { func (opts runOptions) apply(project *types.Project) error {
@ -153,6 +154,7 @@ func runCommand(p *projectOptions, backend api.Service) *cobra.Command {
flags.StringArrayVarP(&opts.publish, "publish", "p", []string{}, "Publish a container's port(s) to the host.") flags.StringArrayVarP(&opts.publish, "publish", "p", []string{}, "Publish a container's port(s) to the host.")
flags.BoolVar(&opts.useAliases, "use-aliases", false, "Use the service's network useAliases in the network(s) the container connects to.") flags.BoolVar(&opts.useAliases, "use-aliases", false, "Use the service's network useAliases in the network(s) the container connects to.")
flags.BoolVar(&opts.servicePorts, "service-ports", false, "Run command with the service's ports enabled and mapped to the host.") flags.BoolVar(&opts.servicePorts, "service-ports", false, "Run command with the service's ports enabled and mapped to the host.")
flags.BoolVar(&opts.quietPull, "quiet-pull", false, "Pull without printing progress information.")
flags.SetNormalizeFunc(normalizeRunFlags) flags.SetNormalizeFunc(normalizeRunFlags)
flags.SetInterspersed(false) flags.SetInterspersed(false)
@ -215,6 +217,7 @@ func runRun(ctx context.Context, backend api.Service, project *types.Project, op
UseNetworkAliases: opts.useAliases, UseNetworkAliases: opts.useAliases,
NoDeps: opts.noDeps, NoDeps: opts.noDeps,
Index: 0, Index: 0,
QuietPull: opts.quietPull,
} }
exitCode, err := backend.RunOneOffContainer(ctx, project, runOpts) exitCode, err := backend.RunOneOffContainer(ctx, project, runOpts)
if exitCode != 0 { if exitCode != 0 {

View File

@ -227,6 +227,8 @@ type RunOptions struct {
Privileged bool Privileged bool
UseNetworkAliases bool UseNetworkAliases bool
NoDeps bool NoDeps bool
// QuietPull makes the pulling process quiet
QuietPull bool
// used by exec // used by exec
Index int Index int
} }

View File

@ -156,7 +156,7 @@ func (s *composeService) prepareRun(ctx context.Context, project *types.Project,
service.Labels = service.Labels.Add(api.SlugLabel, slug) service.Labels = service.Labels.Add(api.SlugLabel, slug)
service.Labels = service.Labels.Add(api.OneoffLabel, "True") service.Labels = service.Labels.Add(api.OneoffLabel, "True")
if err := s.ensureImagesExists(ctx, project, false); err != nil { // all dependencies already checked, but might miss service img if err := s.ensureImagesExists(ctx, project, opts.QuietPull); err != nil { // all dependencies already checked, but might miss service img
return "", err return "", err
} }
if !opts.NoDeps { if !opts.NoDeps {