Bump docker

This commit is contained in:
Jesse Duffield 2023-10-11 09:09:47 +11:00
parent f25a5ebff7
commit 6473810fa9
22 changed files with 162 additions and 86 deletions

2
go.mod
View file

@ -7,7 +7,7 @@ require (
github.com/boz/go-throttle v0.0.0-20160922054636-fdc4eab740c1 github.com/boz/go-throttle v0.0.0-20160922054636-fdc4eab740c1
github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21 github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21
github.com/docker/cli v20.10.15+incompatible github.com/docker/cli v20.10.15+incompatible
github.com/docker/docker v20.10.15+incompatible github.com/docker/docker v20.10.27-0.20230918140811-29a0e76e6495+incompatible
github.com/fatih/color v1.10.0 github.com/fatih/color v1.10.0
github.com/go-errors/errors v1.4.2 github.com/go-errors/errors v1.4.2
github.com/gookit/color v1.5.0 github.com/gookit/color v1.5.0

4
go.sum
View file

@ -16,8 +16,8 @@ github.com/docker/cli v20.10.15+incompatible h1:HGO75iIgpyuG1m0hw0Kp7hY5o7XELmY1
github.com/docker/cli v20.10.15+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/cli v20.10.15+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8=
github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v20.10.15+incompatible h1:dk9FewY/9Xwm4ay/HViEEHSQuM/kL4F+JaG6GQdgmGo= github.com/docker/docker v20.10.27-0.20230918140811-29a0e76e6495+incompatible h1:pgbpJ4kql71BzDNYSe18E489Ni4vn4yQ+0Xj8567Lvc=
github.com/docker/docker v20.10.15+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker v20.10.27-0.20230918140811-29a0e76e6495+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker-credential-helpers v0.8.0 h1:YQFtbBQb4VrpoPxhFuzEBPQ9E16qz5SpHLS+uswaCp8= github.com/docker/docker-credential-helpers v0.8.0 h1:YQFtbBQb4VrpoPxhFuzEBPQ9E16qz5SpHLS+uswaCp8=
github.com/docker/docker-credential-helpers v0.8.0/go.mod h1:UGFXcuoQ5TxPiB54nHOZ32AWRqQdECoh/Mg0AlEYb40= github.com/docker/docker-credential-helpers v0.8.0/go.mod h1:UGFXcuoQ5TxPiB54nHOZ32AWRqQdECoh/Mg0AlEYb40=
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=

View file

@ -24,7 +24,7 @@ info:
title: "Docker Engine API" title: "Docker Engine API"
version: "1.41" version: "1.41"
x-logo: x-logo:
url: "https://docs.docker.com/images/logo-docker-main.png" url: "https://docs.docker.com/assets/images/logo-docker-main.png"
description: | description: |
The Engine API is an HTTP API served by Docker Engine. It is the API the The Engine API is an HTTP API served by Docker Engine. It is the API the
Docker client uses to communicate with the Engine, so everything the Docker Docker client uses to communicate with the Engine, so everything the Docker
@ -1891,23 +1891,52 @@ definitions:
BuildCache: BuildCache:
type: "object" type: "object"
description: |
BuildCache contains information about a build cache record.
properties: properties:
ID: ID:
type: "string" type: "string"
description: |
Unique ID of the build cache record.
example: "ndlpt0hhvkqcdfkputsk4cq9c"
Parent: Parent:
description: |
ID of the parent build cache record.
type: "string" type: "string"
example: "hw53o5aio51xtltp5xjp8v7fx"
Type: Type:
type: "string" type: "string"
description: |
Cache record type.
example: "regular"
# see https://github.com/moby/buildkit/blob/fce4a32258dc9d9664f71a4831d5de10f0670677/client/diskusage.go#L75-L84
enum:
- "internal"
- "frontend"
- "source.local"
- "source.git.checkout"
- "exec.cachemount"
- "regular"
Description: Description:
type: "string" type: "string"
description: |
Description of the build-step that produced the build cache.
example: "mount / from exec /bin/sh -c echo 'Binary::apt::APT::Keep-Downloaded-Packages \"true\";' > /etc/apt/apt.conf.d/keep-cache"
InUse: InUse:
type: "boolean" type: "boolean"
description: |
Indicates if the build cache is in use.
example: false
Shared: Shared:
type: "boolean" type: "boolean"
description: |
Indicates if the build cache is shared.
example: true
Size: Size:
description: | description: |
Amount of disk space used by the build cache (in bytes). Amount of disk space used by the build cache (in bytes).
type: "integer" type: "integer"
example: 51
CreatedAt: CreatedAt:
description: | description: |
Date and time at which the build cache was created in Date and time at which the build cache was created in
@ -1925,6 +1954,7 @@ definitions:
example: "2017-08-09T07:09:37.632105588Z" example: "2017-08-09T07:09:37.632105588Z"
UsageCount: UsageCount:
type: "integer" type: "integer"
example: 26
ImageID: ImageID:
type: "object" type: "object"
@ -3347,7 +3377,7 @@ definitions:
Limits: Limits:
description: "Define resources limits." description: "Define resources limits."
$ref: "#/definitions/Limit" $ref: "#/definitions/Limit"
Reservation: Reservations:
description: "Define resources reservation." description: "Define resources reservation."
$ref: "#/definitions/ResourceObject" $ref: "#/definitions/ResourceObject"
RestartPolicy: RestartPolicy:
@ -5415,6 +5445,28 @@ paths:
`/?[a-zA-Z0-9][a-zA-Z0-9_.-]+`. `/?[a-zA-Z0-9][a-zA-Z0-9_.-]+`.
type: "string" type: "string"
pattern: "^/?[a-zA-Z0-9][a-zA-Z0-9_.-]+$" pattern: "^/?[a-zA-Z0-9][a-zA-Z0-9_.-]+$"
- name: "platform"
in: "query"
description: |
Platform in the format `os[/arch[/variant]]` used for image lookup.
When specified, the daemon checks if the requested image is present
in the local image cache with the given OS and Architecture, and
otherwise returns a `404` status.
If the option is not set, the host's native OS and Architecture are
used to look up the image in the image cache. However, if no platform
is passed and the given image does exist in the local image cache,
but its OS or architecture does not match, the container is created
with the available image, and a warning is added to the `Warnings`
field in the response, for example;
WARNING: The requested image's platform (linux/arm64/v8) does not
match the detected host platform (linux/amd64) and no
specific platform was requested
type: "string"
default: ""
- name: "body" - name: "body"
in: "body" in: "body"
description: "Container to create" description: "Container to create"

View file

@ -1,4 +1,5 @@
/*Package filters provides tools for encoding a mapping of keys to a set of /*
Package filters provides tools for encoding a mapping of keys to a set of
multiple values. multiple values.
*/ */
package filters // import "github.com/docker/docker/api/types/filters" package filters // import "github.com/docker/docker/api/types/filters"
@ -48,7 +49,7 @@ func (args Args) Keys() []string {
// MarshalJSON returns a JSON byte representation of the Args // MarshalJSON returns a JSON byte representation of the Args
func (args Args) MarshalJSON() ([]byte, error) { func (args Args) MarshalJSON() ([]byte, error) {
if len(args.fields) == 0 { if len(args.fields) == 0 {
return []byte{}, nil return []byte("{}"), nil
} }
return json.Marshal(args.fields) return json.Marshal(args.fields)
} }
@ -106,9 +107,6 @@ func FromJSON(p string) (Args, error) {
// UnmarshalJSON populates the Args from JSON encode bytes // UnmarshalJSON populates the Args from JSON encode bytes
func (args Args) UnmarshalJSON(raw []byte) error { func (args Args) UnmarshalJSON(raw []byte) error {
if len(raw) == 0 {
return nil
}
return json.Unmarshal(raw, &args.fields) return json.Unmarshal(raw, &args.fields)
} }

View file

@ -45,31 +45,32 @@ func (ipnet *NetIPNet) UnmarshalJSON(b []byte) (err error) {
// IndexInfo contains information about a registry // IndexInfo contains information about a registry
// //
// RepositoryInfo Examples: // RepositoryInfo Examples:
// {
// "Index" : {
// "Name" : "docker.io",
// "Mirrors" : ["https://registry-2.docker.io/v1/", "https://registry-3.docker.io/v1/"],
// "Secure" : true,
// "Official" : true,
// },
// "RemoteName" : "library/debian",
// "LocalName" : "debian",
// "CanonicalName" : "docker.io/debian"
// "Official" : true,
// }
// //
// { // {
// "Index" : { // "Index" : {
// "Name" : "127.0.0.1:5000", // "Name" : "docker.io",
// "Mirrors" : [], // "Mirrors" : ["https://registry-2.docker.io/v1/", "https://registry-3.docker.io/v1/"],
// "Secure" : false, // "Secure" : true,
// "Official" : false, // "Official" : true,
// }, // },
// "RemoteName" : "user/repo", // "RemoteName" : "library/debian",
// "LocalName" : "127.0.0.1:5000/user/repo", // "LocalName" : "debian",
// "CanonicalName" : "127.0.0.1:5000/user/repo", // "CanonicalName" : "docker.io/debian"
// "Official" : false, // "Official" : true,
// } // }
//
// {
// "Index" : {
// "Name" : "127.0.0.1:5000",
// "Mirrors" : [],
// "Secure" : false,
// "Official" : false,
// },
// "RemoteName" : "user/repo",
// "LocalName" : "127.0.0.1:5000/user/repo",
// "CanonicalName" : "127.0.0.1:5000/user/repo",
// "Official" : false,
// }
type IndexInfo struct { type IndexInfo struct {
// Name is the name of the registry, such as "docker.io" // Name is the name of the registry, such as "docker.io"
Name string Name string

View file

@ -100,8 +100,10 @@ func GetTimestamp(value string, reference time.Time) (string, error) {
// if the incoming nanosecond portion is longer or shorter than 9 digits it is // if the incoming nanosecond portion is longer or shorter than 9 digits it is
// converted to nanoseconds. The expectation is that the seconds and // converted to nanoseconds. The expectation is that the seconds and
// seconds will be used to create a time variable. For example: // seconds will be used to create a time variable. For example:
// seconds, nanoseconds, err := ParseTimestamp("1136073600.000000001",0) //
// if err == nil since := time.Unix(seconds, nanoseconds) // seconds, nanoseconds, err := ParseTimestamp("1136073600.000000001",0)
// if err == nil since := time.Unix(seconds, nanoseconds)
//
// returns seconds as def(aultSeconds) if value == "" // returns seconds as def(aultSeconds) if value == ""
func ParseTimestamps(value string, def int64) (int64, int64, error) { func ParseTimestamps(value string, def int64) (int64, int64, error) {
if value == "" { if value == "" {

View file

@ -4,7 +4,7 @@ Package client is a Go client for the Docker Engine API.
For more information about the Engine API, see the documentation: For more information about the Engine API, see the documentation:
https://docs.docker.com/engine/api/ https://docs.docker.com/engine/api/
Usage # Usage
You use the library by creating a client object and calling methods on it. The You use the library by creating a client object and calling methods on it. The
client can be created either from environment variables with NewClientWithOpts(client.FromEnv), client can be created either from environment variables with NewClientWithOpts(client.FromEnv),
@ -37,7 +37,6 @@ For example, to list running containers (the equivalent of "docker ps"):
fmt.Printf("%s %s\n", container.ID[:10], container.Image) fmt.Printf("%s %s\n", container.ID[:10], container.Image)
} }
} }
*/ */
package client // import "github.com/docker/docker/client" package client // import "github.com/docker/docker/client"
@ -57,6 +56,36 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
) )
// DummyHost is a hostname used for local communication.
//
// It acts as a valid formatted hostname for local connections (such as "unix://"
// or "npipe://") which do not require a hostname. It should never be resolved,
// but uses the special-purpose ".localhost" TLD (as defined in [RFC 2606, Section 2]
// and [RFC 6761, Section 6.3]).
//
// [RFC 7230, Section 5.4] defines that an empty header must be used for such
// cases:
//
// If the authority component is missing or undefined for the target URI,
// then a client MUST send a Host header field with an empty field-value.
//
// However, [Go stdlib] enforces the semantics of HTTP(S) over TCP, does not
// allow an empty header to be used, and requires req.URL.Scheme to be either
// "http" or "https".
//
// For further details, refer to:
//
// - https://github.com/docker/engine-api/issues/189
// - https://github.com/golang/go/issues/13624
// - https://github.com/golang/go/issues/61076
// - https://github.com/moby/moby/issues/45935
//
// [RFC 2606, Section 2]: https://www.rfc-editor.org/rfc/rfc2606.html#section-2
// [RFC 6761, Section 6.3]: https://www.rfc-editor.org/rfc/rfc6761#section-6.3
// [RFC 7230, Section 5.4]: https://datatracker.ietf.org/doc/html/rfc7230#section-5.4
// [Go stdlib]: https://github.com/golang/go/blob/6244b1946bc2101b01955468f1be502dbadd6807/src/net/http/transport.go#L558-L569
const DummyHost = "api.moby.localhost"
// ErrRedirect is the error returned by checkRedirect when the request is non-GET. // ErrRedirect is the error returned by checkRedirect when the request is non-GET.
var ErrRedirect = errors.New("unexpected redirect in response") var ErrRedirect = errors.New("unexpected redirect in response")
@ -135,9 +164,6 @@ func NewClientWithOpts(ops ...Opt) (*Client, error) {
} }
} }
if _, ok := c.client.Transport.(http.RoundTripper); !ok {
return nil, fmt.Errorf("unable to verify TLS configuration, invalid transport %v", c.client.Transport)
}
if c.scheme == "" { if c.scheme == "" {
c.scheme = "http" c.scheme = "http"

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/json" "encoding/json"
"io/ioutil" "io"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
) )
@ -23,7 +23,7 @@ func (cli *Client) ConfigInspectWithRaw(ctx context.Context, id string) (swarm.C
return swarm.Config{}, nil, wrapResponseError(err, resp, "config", id) return swarm.Config{}, nil, wrapResponseError(err, resp, "config", id)
} }
body, err := ioutil.ReadAll(resp.body) body, err := io.ReadAll(resp.body)
if err != nil { if err != nil {
return swarm.Config{}, nil, err return swarm.Config{}, nil, err
} }

View file

@ -22,7 +22,7 @@ import (
// multiplexed. // multiplexed.
// The format of the multiplexed stream is as follows: // The format of the multiplexed stream is as follows:
// //
// [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}[]byte{OUTPUT} // [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}[]byte{OUTPUT}
// //
// STREAM_TYPE can be 1 for stdout and 2 for stderr // STREAM_TYPE can be 1 for stdout and 2 for stderr
// //

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/json" "encoding/json"
"io/ioutil" "io"
"net/url" "net/url"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
@ -41,7 +41,7 @@ func (cli *Client) ContainerInspectWithRaw(ctx context.Context, containerID stri
return types.ContainerJSON{}, nil, wrapResponseError(err, serverResp, "container", containerID) return types.ContainerJSON{}, nil, wrapResponseError(err, serverResp, "container", containerID)
} }
body, err := ioutil.ReadAll(serverResp.body) body, err := io.ReadAll(serverResp.body)
if err != nil { if err != nil {
return types.ContainerJSON{}, nil, err return types.ContainerJSON{}, nil, err
} }

View file

@ -24,7 +24,7 @@ import (
// multiplexed. // multiplexed.
// The format of the multiplexed stream is as follows: // The format of the multiplexed stream is as follows:
// //
// [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}[]byte{OUTPUT} // [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}[]byte{OUTPUT}
// //
// STREAM_TYPE can be 1 for stdout and 2 for stderr // STREAM_TYPE can be 1 for stdout and 2 for stderr
// //

View file

@ -62,7 +62,11 @@ func fallbackDial(proto, addr string, tlsConfig *tls.Config) (net.Conn, error) {
} }
func (cli *Client) setupHijackConn(ctx context.Context, req *http.Request, proto string) (net.Conn, error) { func (cli *Client) setupHijackConn(ctx context.Context, req *http.Request, proto string) (net.Conn, error) {
req.Host = cli.addr req.URL.Host = cli.addr
if cli.proto == "unix" || cli.proto == "npipe" {
// Override host header for non-tcp connections.
req.Host = DummyHost
}
req.Header.Set("Connection", "Upgrade") req.Header.Set("Connection", "Upgrade")
req.Header.Set("Upgrade", proto) req.Header.Set("Upgrade", proto)

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/json" "encoding/json"
"io/ioutil" "io"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
) )
@ -20,7 +20,7 @@ func (cli *Client) ImageInspectWithRaw(ctx context.Context, imageID string) (typ
return types.ImageInspect{}, nil, wrapResponseError(err, serverResp, "image", imageID) return types.ImageInspect{}, nil, wrapResponseError(err, serverResp, "image", imageID)
} }
body, err := ioutil.ReadAll(serverResp.body) body, err := io.ReadAll(serverResp.body)
if err != nil { if err != nil {
return types.ImageInspect{}, nil, err return types.ImageInspect{}, nil, err
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/json" "encoding/json"
"io/ioutil" "io"
"net/url" "net/url"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
@ -39,7 +39,7 @@ func (cli *Client) NetworkInspectWithRaw(ctx context.Context, networkID string,
return networkResource, nil, wrapResponseError(err, resp, "network", networkID) return networkResource, nil, wrapResponseError(err, resp, "network", networkID)
} }
body, err := ioutil.ReadAll(resp.body) body, err := io.ReadAll(resp.body)
if err != nil { if err != nil {
return networkResource, nil, err return networkResource, nil, err
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/json" "encoding/json"
"io/ioutil" "io"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
) )
@ -20,7 +20,7 @@ func (cli *Client) NodeInspectWithRaw(ctx context.Context, nodeID string) (swarm
return swarm.Node{}, nil, wrapResponseError(err, serverResp, "node", nodeID) return swarm.Node{}, nil, wrapResponseError(err, serverResp, "node", nodeID)
} }
body, err := ioutil.ReadAll(serverResp.body) body, err := io.ReadAll(serverResp.body)
if err != nil { if err != nil {
return swarm.Node{}, nil, err return swarm.Node{}, nil, err
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/json" "encoding/json"
"io/ioutil" "io"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
) )
@ -20,7 +20,7 @@ func (cli *Client) PluginInspectWithRaw(ctx context.Context, name string) (*type
return nil, nil, wrapResponseError(err, resp, "plugin", name) return nil, nil, wrapResponseError(err, resp, "plugin", name)
} }
body, err := ioutil.ReadAll(resp.body) body, err := io.ReadAll(resp.body)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }

View file

@ -6,7 +6,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net" "net"
"net/http" "net/http"
"net/url" "net/url"
@ -89,16 +88,14 @@ func (cli *Client) buildRequest(method, path string, body io.Reader, headers hea
return nil, err return nil, err
} }
req = cli.addHeaders(req, headers) req = cli.addHeaders(req, headers)
req.URL.Scheme = cli.scheme
req.URL.Host = cli.addr
if cli.proto == "unix" || cli.proto == "npipe" { if cli.proto == "unix" || cli.proto == "npipe" {
// For local communications, it doesn't matter what the host is. We just // Override host header for non-tcp connections.
// need a valid and meaningful host name. (See #189) req.Host = DummyHost
req.Host = "docker"
} }
req.URL.Host = cli.addr
req.URL.Scheme = cli.scheme
if expectedPayload && req.Header.Get("Content-Type") == "" { if expectedPayload && req.Header.Get("Content-Type") == "" {
req.Header.Set("Content-Type", "text/plain") req.Header.Set("Content-Type", "text/plain")
} }
@ -129,7 +126,7 @@ func (cli *Client) doRequest(ctx context.Context, req *http.Request) (serverResp
} }
if cli.scheme == "https" && strings.Contains(err.Error(), "bad certificate") { if cli.scheme == "https" && strings.Contains(err.Error(), "bad certificate") {
return serverResp, errors.Wrap(err, "The server probably has client authentication (--tlsverify) enabled. Please check your TLS client certification settings") return serverResp, errors.Wrap(err, "the server probably has client authentication (--tlsverify) enabled; check your TLS client certification settings")
} }
// Don't decorate context sentinel errors; users may be comparing to // Don't decorate context sentinel errors; users may be comparing to
@ -141,7 +138,7 @@ func (cli *Client) doRequest(ctx context.Context, req *http.Request) (serverResp
if nErr, ok := err.(*url.Error); ok { if nErr, ok := err.(*url.Error); ok {
if nErr, ok := nErr.Err.(*net.OpError); ok { if nErr, ok := nErr.Err.(*net.OpError); ok {
if os.IsPermission(nErr.Err) { if os.IsPermission(nErr.Err) {
return serverResp, errors.Wrapf(err, "Got permission denied while trying to connect to the Docker daemon socket at %v", cli.host) return serverResp, errors.Wrapf(err, "permission denied while trying to connect to the Docker daemon socket at %v", cli.host)
} }
} }
} }
@ -150,10 +147,8 @@ func (cli *Client) doRequest(ctx context.Context, req *http.Request) (serverResp
if err.Timeout() { if err.Timeout() {
return serverResp, ErrorConnectionFailed(cli.host) return serverResp, ErrorConnectionFailed(cli.host)
} }
if !err.Temporary() { if strings.Contains(err.Error(), "connection refused") || strings.Contains(err.Error(), "dial unix") {
if strings.Contains(err.Error(), "connection refused") || strings.Contains(err.Error(), "dial unix") { return serverResp, ErrorConnectionFailed(cli.host)
return serverResp, ErrorConnectionFailed(cli.host)
}
} }
} }
@ -170,10 +165,10 @@ func (cli *Client) doRequest(ctx context.Context, req *http.Request) (serverResp
if strings.Contains(err.Error(), `open //./pipe/docker_engine`) { if strings.Contains(err.Error(), `open //./pipe/docker_engine`) {
// Checks if client is running with elevated privileges // Checks if client is running with elevated privileges
if f, elevatedErr := os.Open("\\\\.\\PHYSICALDRIVE0"); elevatedErr == nil { if f, elevatedErr := os.Open("\\\\.\\PHYSICALDRIVE0"); elevatedErr == nil {
err = errors.Wrap(err, "In the default daemon configuration on Windows, the docker client must be run with elevated privileges to connect.") err = errors.Wrap(err, "in the default daemon configuration on Windows, the docker client must be run with elevated privileges to connect")
} else { } else {
f.Close() f.Close()
err = errors.Wrap(err, "This error may indicate that the docker daemon is not running.") err = errors.Wrap(err, "this error may indicate that the docker daemon is not running")
} }
} }
@ -201,7 +196,7 @@ func (cli *Client) checkResponseErr(serverResp serverResponse) error {
R: serverResp.body, R: serverResp.body,
N: int64(bodyMax), N: int64(bodyMax),
} }
body, err = ioutil.ReadAll(bodyR) body, err = io.ReadAll(bodyR)
if err != nil { if err != nil {
return err return err
} }
@ -242,10 +237,8 @@ func (cli *Client) addHeaders(req *http.Request, headers headers) *http.Request
req.Header.Set(k, v) req.Header.Set(k, v)
} }
if headers != nil { for k, v := range headers {
for k, v := range headers { req.Header[k] = v
req.Header[k] = v
}
} }
return req return req
} }
@ -263,7 +256,7 @@ func encodeData(data interface{}) (*bytes.Buffer, error) {
func ensureReaderClosed(response serverResponse) { func ensureReaderClosed(response serverResponse) {
if response.body != nil { if response.body != nil {
// Drain up to 512 bytes and close the body to let the Transport reuse the connection // Drain up to 512 bytes and close the body to let the Transport reuse the connection
io.CopyN(ioutil.Discard, response.body, 512) io.CopyN(io.Discard, response.body, 512)
response.body.Close() response.body.Close()
} }
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/json" "encoding/json"
"io/ioutil" "io"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
) )
@ -23,7 +23,7 @@ func (cli *Client) SecretInspectWithRaw(ctx context.Context, id string) (swarm.S
return swarm.Secret{}, nil, wrapResponseError(err, resp, "secret", id) return swarm.Secret{}, nil, wrapResponseError(err, resp, "secret", id)
} }
body, err := ioutil.ReadAll(resp.body) body, err := io.ReadAll(resp.body)
if err != nil { if err != nil {
return swarm.Secret{}, nil, err return swarm.Secret{}, nil, err
} }

View file

@ -5,7 +5,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"net/url" "net/url"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
@ -25,7 +25,7 @@ func (cli *Client) ServiceInspectWithRaw(ctx context.Context, serviceID string,
return swarm.Service{}, nil, wrapResponseError(err, serverResp, "service", serviceID) return swarm.Service{}, nil, wrapResponseError(err, serverResp, "service", serviceID)
} }
body, err := ioutil.ReadAll(serverResp.body) body, err := io.ReadAll(serverResp.body)
if err != nil { if err != nil {
return swarm.Service{}, nil, err return swarm.Service{}, nil, err
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/json" "encoding/json"
"io/ioutil" "io"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
) )
@ -20,7 +20,7 @@ func (cli *Client) TaskInspectWithRaw(ctx context.Context, taskID string) (swarm
return swarm.Task{}, nil, wrapResponseError(err, serverResp, "task", taskID) return swarm.Task{}, nil, wrapResponseError(err, serverResp, "task", taskID)
} }
body, err := ioutil.ReadAll(serverResp.body) body, err := io.ReadAll(serverResp.body)
if err != nil { if err != nil {
return swarm.Task{}, nil, err return swarm.Task{}, nil, err
} }

View file

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/json" "encoding/json"
"io/ioutil" "io"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
) )
@ -28,7 +28,7 @@ func (cli *Client) VolumeInspectWithRaw(ctx context.Context, volumeID string) (t
return volume, nil, wrapResponseError(err, resp, "volume", volumeID) return volume, nil, wrapResponseError(err, resp, "volume", volumeID)
} }
body, err := ioutil.ReadAll(resp.body) body, err := io.ReadAll(resp.body)
if err != nil { if err != nil {
return volume, nil, err return volume, nil, err
} }

2
vendor/modules.txt vendored
View file

@ -30,7 +30,7 @@ github.com/docker/cli/cli/context/store
## explicit ## explicit
github.com/docker/distribution/digestset github.com/docker/distribution/digestset
github.com/docker/distribution/reference github.com/docker/distribution/reference
# github.com/docker/docker v20.10.15+incompatible # github.com/docker/docker v20.10.27-0.20230918140811-29a0e76e6495+incompatible
## explicit ## explicit
github.com/docker/docker/api github.com/docker/docker/api
github.com/docker/docker/api/types github.com/docker/docker/api/types