@@ -222,7 +222,7 @@ func (p dockerPusher) Push(ctx context.Context, desc ocispec.Descriptor) (conten
222222 // TODO: Support chunked upload
223223
224224 pr , pw := io .Pipe ()
225- respC := make (chan * http. Response , 1 )
225+ respC := make (chan response , 1 )
226226 body := ioutil .NopCloser (pr )
227227
228228 req .body = func () (io.ReadCloser , error ) {
@@ -240,6 +240,7 @@ func (p dockerPusher) Push(ctx context.Context, desc ocispec.Descriptor) (conten
240240 defer close (respC )
241241 resp , err := req .do (ctx )
242242 if err != nil {
243+ respC <- response {err : err }
243244 pr .CloseWithError (err )
244245 return
245246 }
@@ -251,7 +252,7 @@ func (p dockerPusher) Push(ctx context.Context, desc ocispec.Descriptor) (conten
251252 log .G (ctx ).WithField ("resp" , resp ).WithField ("body" , string (err .(remoteserrors.ErrUnexpectedStatus ).Body )).Debug ("unexpected response" )
252253 pr .CloseWithError (err )
253254 }
254- respC <- resp
255+ respC <- response { Response : resp }
255256 }()
256257
257258 return & pushWriter {
@@ -284,12 +285,17 @@ func getManifestPath(object string, dgst digest.Digest) []string {
284285 return []string {"manifests" , object }
285286}
286287
288+ type response struct {
289+ * http.Response
290+ err error
291+ }
292+
287293type pushWriter struct {
288294 base * dockerBase
289295 ref string
290296
291297 pipe * io.PipeWriter
292- responseC <- chan * http. Response
298+ responseC <- chan response
293299 isManifest bool
294300
295301 expected digest.Digest
@@ -339,8 +345,8 @@ func (pw *pushWriter) Commit(ctx context.Context, size int64, expected digest.Di
339345
340346 // TODO: timeout waiting for response
341347 resp := <- pw .responseC
342- if resp = = nil {
343- return errors . New ( "no response" )
348+ if resp . err ! = nil {
349+ return resp . err
344350 }
345351
346352 // 201 is specified return status, some registries return
0 commit comments