Avoid loop when discarding contents of progress pipe

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
This commit is contained in:
Aaron Lehmann 2017-05-16 14:32:29 -07:00
parent 103bfb2739
commit 51f698337d
2 changed files with 3 additions and 15 deletions

View File

@ -2,6 +2,7 @@ package service
import (
"io"
"io/ioutil"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/service/progress"
@ -20,14 +21,7 @@ func waitOnService(ctx context.Context, dockerCli *command.DockerCli, serviceID
}()
if opts.quiet {
go func() {
for {
var buf [1024]byte
if _, err := pipeReader.Read(buf[:]); err != nil {
return
}
}
}()
go io.Copy(ioutil.Discard, pipeReader)
return <-errChan
}

View File

@ -102,13 +102,7 @@ func runRotateCA(dockerCli command.Cli, flags *pflag.FlagSet, opts caOptions) er
}()
if opts.quiet {
go func() {
for {
if _, err := io.Copy(ioutil.Discard, pipeReader); err != nil {
return
}
}
}()
go io.Copy(ioutil.Discard, pipeReader)
return <-errChan
}