Merge pull request #12702 from LK4D4/good_ol_flushed

Return weird behaviour of returning json errors
This commit is contained in:
Jessie Frazelle 2015-04-23 13:03:29 -07:00
commit 1492a7d7fd

View file

@ -862,11 +862,12 @@ func (s *Server) postImagesPush(eng *engine.Engine, version version.Version, w h
useJSON := version.GreaterThan("1.0")
name := vars["name"]
output := utils.NewWriteFlusher(w)
imagePushConfig := &graph.ImagePushConfig{
MetaHeaders: metaHeaders,
AuthConfig: authConfig,
Tag: r.Form.Get("tag"),
OutStream: utils.NewWriteFlusher(w),
OutStream: output,
Json: useJSON,
}
if useJSON {
@ -874,8 +875,11 @@ func (s *Server) postImagesPush(eng *engine.Engine, version version.Version, w h
}
if err := s.daemon.Repositories().Push(name, imagePushConfig); err != nil {
if !output.Flushed() {
return err
}
sf := streamformatter.NewStreamFormatter(useJSON)
return fmt.Errorf(string(sf.FormatError(err)))
output.Write(sf.FormatError(err))
}
return nil