Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #52 from grammarly/EOF_push_error
Browse files Browse the repository at this point in the history
fix eof push error with 0 exitcode
  • Loading branch information
Yuriy Bogdanov committed Dec 7, 2015
2 parents eec16c9 + 215aa3a commit 142bf31
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/rocker/build/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (c *DockerClient) PullImage(name string) error {
pipeReader, pipeWriter = io.Pipe()
fdOut, isTerminalOut = term.GetFdInfo(c.log.Out)
out = c.log.Out
errch = make(chan error)
errch = make(chan error, 1)
)

if !isTerminalOut {
Expand Down Expand Up @@ -417,6 +417,7 @@ func (c *DockerClient) PushImage(imageName string) (digest string, err error) {
OutputStream: outStream,
RawJSONStream: true,
}
errch = make(chan error, 1)
)

if !isTerminalOut {
Expand All @@ -429,16 +430,18 @@ func (c *DockerClient) PushImage(imageName string) (digest string, err error) {

// TODO: DisplayJSONMessagesStream may fail by client.PushImage run without errors
go func() {
if err := jsonmessage.DisplayJSONMessagesStream(pipeReader, out, fdOut, isTerminalOut); err != nil {
c.log.Errorf("Failed to process json stream, error %s", err)
}
errch <- jsonmessage.DisplayJSONMessagesStream(pipeReader, out, fdOut, isTerminalOut)
}()

if err := c.client.PushImage(opts, c.auth); err != nil {
return "", err
}
pipeWriter.Close()

if err := <-errch; err != nil {
return "", fmt.Errorf("Failed to process json stream, error %s", err)
}

// It is the best way to have pushed image digest so far
matches := captureDigest.FindStringSubmatch(buf.String())
if len(matches) > 0 {
Expand Down

0 comments on commit 142bf31

Please sign in to comment.