mirror of https://github.com/docker/docs.git
Return weird behaviour of returning json errors
We need this, so client can get error from stream and not from status code, which is already 200, because write to ResponseWriter was occured. Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
parent
fa3e2dd45e
commit
ec51ba01db
|
@ -861,11 +861,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 {
|
||||
|
@ -873,8 +874,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
|
||||
|
||||
|
|
Loading…
Reference in New Issue