@@ -36,7 +36,6 @@ import (
3636 "github.com/containerd/containerd/v2/core/content"
3737 "github.com/containerd/containerd/v2/core/images"
3838 "github.com/containerd/containerd/v2/core/remotes"
39- remoteserrors "github.com/containerd/containerd/v2/core/remotes/errors"
4039)
4140
4241type dockerPusher struct {
@@ -149,8 +148,8 @@ func (p dockerPusher) push(ctx context.Context, desc ocispec.Descriptor, ref str
149148 return nil , fmt .Errorf ("content %v on remote: %w" , desc .Digest , errdefs .ErrAlreadyExists )
150149 }
151150 } else if resp .StatusCode != http .StatusNotFound {
152- err := remoteserrors . NewUnexpectedStatusErr (resp )
153- log .G (ctx ).WithField ( "resp" , resp ). WithField ( "body" , string ( err .(remoteserrors. ErrUnexpectedStatus ). Body ) ).Debug ("unexpected response" )
151+ err := unexpectedResponseErr (resp )
152+ log .G (ctx ).WithError ( err ).Debug ("unexpected response" )
154153 resp .Body .Close ()
155154 return nil , err
156155 }
@@ -224,8 +223,8 @@ func (p dockerPusher) push(ctx context.Context, desc ocispec.Descriptor, ref str
224223 })
225224 return nil , fmt .Errorf ("content %v on remote: %w" , desc .Digest , errdefs .ErrAlreadyExists )
226225 default :
227- err := remoteserrors . NewUnexpectedStatusErr (resp )
228- log .G (ctx ).WithField ( "resp" , resp ). WithField ( "body" , string ( err .(remoteserrors. ErrUnexpectedStatus ). Body ) ).Debug ("unexpected response" )
226+ err := unexpectedResponseErr (resp )
227+ log .G (ctx ).WithError ( err ).Debug ("unexpected response" )
229228 return nil , err
230229 }
231230
@@ -299,8 +298,8 @@ func (p dockerPusher) push(ctx context.Context, desc ocispec.Descriptor, ref str
299298 switch resp .StatusCode {
300299 case http .StatusOK , http .StatusCreated , http .StatusNoContent :
301300 default :
302- err := remoteserrors . NewUnexpectedStatusErr (resp )
303- log .G (ctx ).WithField ( "resp" , resp ). WithField ( "body" , string ( err .(remoteserrors. ErrUnexpectedStatus ). Body ) ).Debug ("unexpected response" )
301+ err := unexpectedResponseErr (resp )
302+ log .G (ctx ).WithError ( err ).Debug ("unexpected response" )
304303 pushw .setError (err )
305304 return
306305 }
@@ -513,7 +512,7 @@ func (pw *pushWriter) Commit(ctx context.Context, size int64, expected digest.Di
513512 switch resp .StatusCode {
514513 case http .StatusOK , http .StatusCreated , http .StatusNoContent , http .StatusAccepted :
515514 default :
516- return remoteserrors . NewUnexpectedStatusErr (resp )
515+ return unexpectedResponseErr (resp )
517516 }
518517
519518 status , err := pw .tracker .GetStatus (pw .ref )
0 commit comments