mirror of
https://github.com/docker/cli.git
synced 2026-11-14 00:33:51 -04:00
vendor: github.com/moby/moby/client v0.6.3
full diff: https://github.com/moby/moby/compare/402d0a16f131...client/v0.6.3 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
+1
-1
@@ -34,7 +34,7 @@ require (
|
||||
github.com/mattn/go-runewidth v0.0.31
|
||||
github.com/moby/go-archive v0.3.3
|
||||
github.com/moby/moby/api v1.57.0
|
||||
github.com/moby/moby/client v0.6.3-0.20261106011722-402d0a16f131
|
||||
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
|
||||
|
||||
+2
-2
@@ -90,8 +90,8 @@ 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.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-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/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=
|
||||
|
||||
-43
@@ -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}
|
||||
}
|
||||
}
|
||||
|
||||
+55
@@ -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,
|
||||
}
|
||||
}
|
||||
+2
-34
@@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -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 {
|
||||
|
||||
+2
-1
@@ -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
|
||||
|
||||
Vendored
+2
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user