diff --git a/vendor.mod b/vendor.mod index b2d83cdbafd2..8c2ecc54343c 100644 --- a/vendor.mod +++ b/vendor.mod @@ -33,8 +33,8 @@ require ( github.com/google/uuid v1.6.0 github.com/mattn/go-runewidth v0.0.31 github.com/moby/go-archive v0.3.3 - github.com/moby/moby/api v1.56.2-0.20261106011722-402d0a16f131 - github.com/moby/moby/client v0.6.3-0.20261106011722-402d0a16f131 + github.com/moby/moby/api v1.57.0 + github.com/moby/moby/client v0.6.3 github.com/moby/patternmatcher v0.6.1 github.com/moby/swarmkit/v2 v2.1.3 github.com/moby/sys/atomicwriter v0.1.0 diff --git a/vendor.sum b/vendor.sum index 9bcf48c69167..5e0a24bdb5cd 100644 --- a/vendor.sum +++ b/vendor.sum @@ -88,10 +88,10 @@ github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3N github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= github.com/moby/go-archive v0.3.3 h1:OxxR9paxsluYi+zDUEXTTaIxtkK3viymW+Ka7vRhhME= github.com/moby/go-archive v0.3.3/go.mod h1:Npdv43fFqlhZW7Xo8fbm3ZMYFvAGNviUPqX21VERbcE= -github.com/moby/moby/api v1.56.2-0.20261106011722-402d0a16f131 h1:tPz9ahj8F7AjQw62XQFP65kmoxF3rXTYSit3q06/yQc= -github.com/moby/moby/api v1.56.2-0.20261106011722-402d0a16f131/go.mod h1:pRZ1QRtx6AVhdckeFYo4DUX4ASNF0SCllhyY6aj2mgg= -github.com/moby/moby/client v0.6.3-0.20261106011722-402d0a16f131 h1:ReIO7lalQVE4BetZuIvrxScg8Rxv4Sk74XRs06ryRDU= -github.com/moby/moby/client v0.6.3-0.20261106011722-402d0a16f131/go.mod h1:dPyRteJDuLdP8to3kWmNAU/tbMwSFCE88yKHvY/nZ9k= +github.com/moby/moby/api v1.57.0 h1:K2ykv5UZjwFCtmtL486T+SUEVrQ46w3v7isf214RCcw= +github.com/moby/moby/api v1.57.0/go.mod h1:pRZ1QRtx6AVhdckeFYo4DUX4ASNF0SCllhyY6aj2mgg= +github.com/moby/moby/client v0.6.3 h1:XJn2T8YdXBdMgQl7JrOx09NEBuzIpVXcsN2KDHufAKY= +github.com/moby/moby/client v0.6.3/go.mod h1:7CXNAnAhcwwqjwjXqLembJczRorLfM+5mu0d5363lCc= github.com/moby/patternmatcher v0.6.1 h1:qlhtafmr6kgMIJjKJMDmMWq7WLkKIo23hsrpR3x084U= github.com/moby/patternmatcher v0.6.1/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= github.com/moby/swarmkit/v2 v2.1.3 h1:UcwtwkIRjr75qSgUWCTIuzKUzAXlidxsiqVMnyxSF1w= diff --git a/vendor/github.com/moby/moby/client/errors.go b/vendor/github.com/moby/moby/client/errors.go index 9fbfa7666ed0..571297f8e542 100644 --- a/vendor/github.com/moby/moby/client/errors.go +++ b/vendor/github.com/moby/moby/client/errors.go @@ -4,10 +4,7 @@ import ( "context" "errors" "fmt" - "net/http" - cerrdefs "github.com/containerd/errdefs" - "github.com/containerd/errdefs/pkg/errhttp" "github.com/moby/moby/client/pkg/versions" ) @@ -72,43 +69,3 @@ func (cli *Client) requiresVersion(ctx context.Context, apiRequired, feature str } return nil } - -type httpError struct { - err error - errdef error -} - -func (e *httpError) Error() string { - return e.err.Error() -} - -func (e *httpError) Unwrap() error { - return e.err -} - -func (e *httpError) Is(target error) bool { - return errors.Is(e.errdef, target) -} - -// httpErrorFromStatusCode creates an errdef error, based on the provided HTTP status-code -func httpErrorFromStatusCode(err error, statusCode int) error { - if err == nil { - return nil - } - base := errhttp.ToNative(statusCode) - if base != nil { - return &httpError{err: err, errdef: base} - } - - switch { - case statusCode >= http.StatusOK && statusCode < http.StatusBadRequest: - // it's a client error - return err - case statusCode >= http.StatusBadRequest && statusCode < http.StatusInternalServerError: - return &httpError{err: err, errdef: cerrdefs.ErrInvalidArgument} - case statusCode >= http.StatusInternalServerError && statusCode < 600: - return &httpError{err: err, errdef: cerrdefs.ErrInternal} - default: - return &httpError{err: err, errdef: cerrdefs.ErrUnknown} - } -} diff --git a/vendor/github.com/moby/moby/client/internal/httperror/httperror.go b/vendor/github.com/moby/moby/client/internal/httperror/httperror.go new file mode 100644 index 000000000000..42dc74d5215d --- /dev/null +++ b/vendor/github.com/moby/moby/client/internal/httperror/httperror.go @@ -0,0 +1,55 @@ +// Package httperror classifies errors using HTTP status codes. +package httperror + +import ( + "errors" + "net/http" + + cerrdefs "github.com/containerd/errdefs" + "github.com/containerd/errdefs/pkg/errhttp" +) + +type httpError struct { + err error + errDef error +} + +func (e *httpError) Error() string { + return e.err.Error() +} + +func (e *httpError) Unwrap() error { + return e.err +} + +func (e *httpError) Is(target error) bool { + return errors.Is(e.errDef, target) +} + +// FromStatusCode classifies err using the HTTP status code while preserving +// its message and error chain. +func FromStatusCode(err error, statusCode int) error { + if err == nil || statusCode == 0 { + return err + } + if statusCode >= http.StatusOK && statusCode < http.StatusBadRequest { + // The HTTP status indicates success or redirection, so err may originate + // from client-side processing. Preserve it without adding a classification. + return err + } + errDef := errhttp.ToNative(statusCode) + if cerrdefs.IsUnknown(errDef) { + switch { + case statusCode >= http.StatusBadRequest && statusCode < http.StatusInternalServerError: + errDef = cerrdefs.ErrInvalidArgument + case statusCode >= http.StatusInternalServerError && statusCode < 600: + errDef = cerrdefs.ErrInternal + default: + errDef = cerrdefs.ErrUnknown + } + } + return &httpError{ + err: err, + errDef: errDef, + } +} diff --git a/vendor/github.com/moby/moby/client/internal/jsonmessages.go b/vendor/github.com/moby/moby/client/internal/jsonmessages.go index 05210d0dc73c..6d8d1bfd66f6 100644 --- a/vendor/github.com/moby/moby/client/internal/jsonmessages.go +++ b/vendor/github.com/moby/moby/client/internal/jsonmessages.go @@ -8,7 +8,7 @@ import ( "iter" "sync" - "github.com/containerd/errdefs/pkg/errhttp" + "github.com/moby/moby/client/internal/httperror" "github.com/moby/moby/api/types/jsonstream" ) @@ -96,40 +96,8 @@ func (r Stream) Wait(ctx context.Context) error { } if jm.Error != nil { // push/pull failures. - return httpErrorFromStatusCode(jm.Error, jm.Error.Code) + return httperror.FromStatusCode(jm.Error, jm.Error.Code) } } return nil } - -type httpError struct { - err error - errdef error -} - -func (e *httpError) Error() string { - return e.err.Error() -} - -func (e *httpError) Unwrap() error { - return e.err -} - -func (e *httpError) Is(target error) bool { - return errors.Is(e.errdef, target) -} - -// httpErrorFromStatusCode creates an errdef error, based on the provided HTTP status-code -// -// TODO(thaJeztah): unify with the implementation in client and move to an internal package -// see https://github.com/moby/moby/blob/client/v0.4.0/client/errors.go#L76-L114 -func httpErrorFromStatusCode(err error, statusCode int) error { - if err == nil { - return nil - } - - return &httpError{ - err: err, - errdef: errhttp.ToNative(statusCode), - } -} diff --git a/vendor/github.com/moby/moby/client/pkg/jsonmessage/jsonmessage.go b/vendor/github.com/moby/moby/client/pkg/jsonmessage/jsonmessage.go index 7fae6dceaaf2..80726dfccf98 100644 --- a/vendor/github.com/moby/moby/client/pkg/jsonmessage/jsonmessage.go +++ b/vendor/github.com/moby/moby/client/pkg/jsonmessage/jsonmessage.go @@ -11,6 +11,7 @@ import ( "github.com/docker/go-units" "github.com/moby/moby/api/types/jsonstream" + "github.com/moby/moby/client/internal/httperror" "github.com/moby/term" ) @@ -144,7 +145,7 @@ func cursorDown(out io.Writer, l uint) { // error if [jsonstream.Message.Error] is non-nil. func Display(jm jsonstream.Message, out io.Writer, isTerminal bool, width uint16) error { if jm.Error != nil { - return jm.Error + return httperror.FromStatusCode(jm.Error, jm.Error.Code) } var endl string if isTerminal && jm.Stream == "" && jm.Progress != nil { diff --git a/vendor/github.com/moby/moby/client/request.go b/vendor/github.com/moby/moby/client/request.go index 7d57b6b6adbd..259c0cfdad68 100644 --- a/vendor/github.com/moby/moby/client/request.go +++ b/vendor/github.com/moby/moby/client/request.go @@ -15,6 +15,7 @@ import ( "strings" "github.com/moby/moby/api/types/common" + "github.com/moby/moby/client/internal/httperror" ) // head sends an http request to the docker API using the method HEAD. @@ -226,7 +227,7 @@ func checkResponseErr(serverResp *http.Response) (retErr error) { return nil } defer func() { - retErr = httpErrorFromStatusCode(retErr, serverResp.StatusCode) + retErr = httperror.FromStatusCode(retErr, serverResp.StatusCode) }() var body []byte diff --git a/vendor/modules.txt b/vendor/modules.txt index ecdfb4bd6940..a4d5bcda8909 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -167,7 +167,7 @@ github.com/moby/go-archive github.com/moby/go-archive/compression github.com/moby/go-archive/internal/archiveoptions github.com/moby/go-archive/tarheader -# github.com/moby/moby/api v1.56.2-0.20261106011722-402d0a16f131 +# github.com/moby/moby/api v1.57.0 ## explicit; go 1.24 github.com/moby/moby/api/pkg/authconfig github.com/moby/moby/api/pkg/stdcopy @@ -189,10 +189,11 @@ github.com/moby/moby/api/types/storage github.com/moby/moby/api/types/swarm github.com/moby/moby/api/types/system github.com/moby/moby/api/types/volume -# github.com/moby/moby/client v0.6.3-0.20261106011722-402d0a16f131 +# github.com/moby/moby/client v0.6.3 ## explicit; go 1.24 github.com/moby/moby/client github.com/moby/moby/client/internal +github.com/moby/moby/client/internal/httperror github.com/moby/moby/client/internal/mod github.com/moby/moby/client/internal/timestamp github.com/moby/moby/client/pkg/jsonmessage