mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #25690 from yongtang/25661-docker-build-detect-tty
Suppress verbose "Sending build context" messages in non tty scenarios
This commit is contained in:
commit
9dd8ccc746
1 changed files with 19 additions and 0 deletions
|
@ -104,6 +104,22 @@ func NewBuildCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// lastProgressOutput is the same as progress.Output except
|
||||||
|
// that it only output with the last update. It is used in
|
||||||
|
// non terminal scenarios to depresss verbose messages
|
||||||
|
type lastProgressOutput struct {
|
||||||
|
output progress.Output
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteProgress formats progress information from a ProgressReader.
|
||||||
|
func (out *lastProgressOutput) WriteProgress(prog progress.Progress) error {
|
||||||
|
if !prog.LastUpdate {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return out.output.WriteProgress(prog)
|
||||||
|
}
|
||||||
|
|
||||||
func runBuild(dockerCli *client.DockerCli, options buildOptions) error {
|
func runBuild(dockerCli *client.DockerCli, options buildOptions) error {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -211,6 +227,9 @@ func runBuild(dockerCli *client.DockerCli, options buildOptions) error {
|
||||||
|
|
||||||
// Setup an upload progress bar
|
// Setup an upload progress bar
|
||||||
progressOutput := streamformatter.NewStreamFormatter().NewProgressOutput(progBuff, true)
|
progressOutput := streamformatter.NewStreamFormatter().NewProgressOutput(progBuff, true)
|
||||||
|
if !dockerCli.IsTerminalOut() {
|
||||||
|
progressOutput = &lastProgressOutput{output: progressOutput}
|
||||||
|
}
|
||||||
|
|
||||||
var body io.Reader = progress.NewProgressReader(buildCtx, progressOutput, 0, "", "Sending build context to Docker daemon")
|
var body io.Reader = progress.NewProgressReader(buildCtx, progressOutput, 0, "", "Sending build context to Docker daemon")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue