Merge pull request #6764 from vvoland/update-docker

vendor: github.com/moby/moby/api v1.53.0 & github.com/moby/moby/client v0.2.2
This commit is contained in:
Sebastiaan van Stijn
2026-01-26 20:20:51 +01:00
committed by GitHub
16 changed files with 107 additions and 45 deletions
+2 -2
View File
@@ -28,8 +28,8 @@ require (
github.com/google/uuid v1.6.0
github.com/mattn/go-runewidth v0.0.19
github.com/moby/go-archive v0.2.0
github.com/moby/moby/api v1.53.0-rc.2
github.com/moby/moby/client v0.2.2-rc.2
github.com/moby/moby/api v1.53.0
github.com/moby/moby/client v0.2.2
github.com/moby/patternmatcher v0.6.0
github.com/moby/swarmkit/v2 v2.1.1
github.com/moby/sys/atomicwriter v0.1.0
+4 -4
View File
@@ -113,10 +113,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.2.0 h1:zg5QDUM2mi0JIM9fdQZWC7U8+2ZfixfTYoHL7rWUcP8=
github.com/moby/go-archive v0.2.0/go.mod h1:mNeivT14o8xU+5q1YnNrkQVpK+dnNe/K6fHqnTg4qPU=
github.com/moby/moby/api v1.53.0-rc.2 h1:Ajc2MnWJRC2AAqhIGNaqvwaA2mMYKyuso5PjxPP2KM4=
github.com/moby/moby/api v1.53.0-rc.2/go.mod h1:8mb+ReTlisw4pS6BRzCMts5M49W5M7bKt1cJy/YbAqc=
github.com/moby/moby/client v0.2.2-rc.2 h1:j8cmCofnlLCimDzFUYsrrACJZWsRiq0ZqGrbbVX2fFs=
github.com/moby/moby/client v0.2.2-rc.2/go.mod h1:LxIGylF1oOCPvokq90dMSUy44ODFFLkt2vRgDE1RKck=
github.com/moby/moby/api v1.53.0 h1:PihqG1ncw4W+8mZs69jlwGXdaYBeb5brF6BL7mPIS/w=
github.com/moby/moby/api v1.53.0/go.mod h1:8mb+ReTlisw4pS6BRzCMts5M49W5M7bKt1cJy/YbAqc=
github.com/moby/moby/client v0.2.2 h1:Pt4hRMCAIlyjL3cr8M5TrXCwKzguebPAc2do2ur7dEM=
github.com/moby/moby/client v0.2.2/go.mod h1:2EkIPVNCqR05CMIzL1mfA07t0HvVUUOl85pasRz/GmQ=
github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk=
github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
github.com/moby/swarmkit/v2 v2.1.1 h1:yvTJ8MMCc3f0qTA44J6R59EZ5yZawdYopkpuLk4+ICU=
+5 -1
View File
@@ -71,11 +71,15 @@ func DecodeRequestBody(r io.ReadCloser) (*registry.AuthConfig, error) {
func decode(r io.Reader) (*registry.AuthConfig, error) {
authConfig := &registry.AuthConfig{}
if err := json.NewDecoder(r).Decode(authConfig); err != nil {
dec := json.NewDecoder(r)
if err := dec.Decode(authConfig); err != nil {
// always return an (empty) AuthConfig to increase compatibility with
// the existing API.
return &registry.AuthConfig{}, invalid(fmt.Errorf("invalid JSON: %w", err))
}
if dec.More() {
return &registry.AuthConfig{}, invalid(errors.New("multiple JSON documents not allowed"))
}
return authConfig, nil
}
+3 -3
View File
@@ -58,9 +58,9 @@ func (es *EndpointSettings) Copy() *EndpointSettings {
// EndpointIPAMConfig represents IPAM configurations for the endpoint
type EndpointIPAMConfig struct {
IPv4Address netip.Addr `json:",omitempty"`
IPv6Address netip.Addr `json:",omitempty"`
LinkLocalIPs []netip.Addr `json:",omitempty"`
IPv4Address netip.Addr `json:"IPv4Address,omitzero"`
IPv6Address netip.Addr `json:"IPv6Address,omitzero"`
LinkLocalIPs []netip.Addr `json:"LinkLocalIPs,omitempty"`
}
// Copy makes a copy of the endpoint ipam config
+5 -3
View File
@@ -11,9 +11,11 @@ import (
// in the absence of go.dev/issue/29678.
type HardwareAddr net.HardwareAddr
var _ encoding.TextMarshaler = (HardwareAddr)(nil)
var _ encoding.TextUnmarshaler = (*HardwareAddr)(nil)
var _ fmt.Stringer = (HardwareAddr)(nil)
var (
_ encoding.TextMarshaler = (HardwareAddr)(nil)
_ encoding.TextUnmarshaler = (*HardwareAddr)(nil)
_ fmt.Stringer = (HardwareAddr)(nil)
)
func (m *HardwareAddr) UnmarshalText(text []byte) error {
if len(text) == 0 {
+3 -3
View File
@@ -13,9 +13,9 @@ type IPAM struct {
// IPAMConfig represents IPAM configurations
type IPAMConfig struct {
Subnet netip.Prefix `json:",omitempty"`
IPRange netip.Prefix `json:",omitempty"`
Gateway netip.Addr `json:",omitempty"`
Subnet netip.Prefix `json:"Subnet,omitzero"`
IPRange netip.Prefix `json:"IPRange,omitzero"`
Gateway netip.Addr `json:"Gateway,omitzero"`
AuxAddress map[string]netip.Addr `json:"AuxiliaryAddresses,omitempty"`
}
+4 -4
View File
@@ -61,7 +61,7 @@ type EndpointVirtualIP struct {
// Addr is the virtual ip address.
// This field accepts CIDR notation, for example `10.0.0.1/24`, to maintain backwards
// compatibility, but only the IP address is used.
Addr netip.Prefix `json:",omitempty"`
Addr netip.Prefix `json:"Addr,omitzero"`
}
// Network represents a network.
@@ -111,7 +111,7 @@ type IPAMOptions struct {
// IPAMConfig represents ipam configuration.
type IPAMConfig struct {
Subnet netip.Prefix `json:",omitempty"`
Range netip.Prefix `json:",omitempty"`
Gateway netip.Addr `json:",omitempty"`
Subnet netip.Prefix `json:"Subnet,omitzero"`
Range netip.Prefix `json:"Range,omitzero"`
Gateway netip.Addr `json:"Gateway,omitzero"`
}
+3 -3
View File
@@ -109,14 +109,14 @@ type Limit struct {
Pids int64 `json:",omitempty"`
}
// GenericResource represents a "user defined" resource which can
// GenericResource represents a "user-defined" resource which can
// be either an integer (e.g: SSD=3) or a string (e.g: SSD=sda1)
type GenericResource struct {
NamedResourceSpec *NamedGenericResource `json:",omitempty"`
DiscreteResourceSpec *DiscreteGenericResource `json:",omitempty"`
}
// NamedGenericResource represents a "user defined" resource which is defined
// NamedGenericResource represents a "user-defined" resource which is defined
// as a string.
// "Kind" is used to describe the Kind of a resource (e.g: "GPU", "FPGA", "SSD", ...)
// Value is used to identify the resource (GPU="UUID-1", FPGA="/dev/sdb5", ...)
@@ -125,7 +125,7 @@ type NamedGenericResource struct {
Value string `json:",omitempty"`
}
// DiscreteGenericResource represents a "user defined" resource which is defined
// DiscreteGenericResource represents a "user-defined" resource which is defined
// as an integer
// "Kind" is used to describe the Kind of a resource (e.g: "GPU", "FPGA", "SSD", ...)
// Value is used to count the resource (SSD=5, HDD=3, ...)
+8
View File
@@ -59,6 +59,7 @@ import (
"net/http"
"net/url"
"path"
"slices"
"strings"
"sync"
"sync/atomic"
@@ -241,6 +242,13 @@ func New(ops ...Opt) (*Client, error) {
c.client.Transport = otelhttp.NewTransport(c.client.Transport, c.traceOpts...)
if len(cfg.responseHooks) > 0 {
c.client.Transport = &responseHookTransport{
base: c.client.Transport,
hooks: slices.Clone(cfg.responseHooks),
}
}
return c, nil
}
+25
View File
@@ -2,6 +2,7 @@ package client
import (
"context"
"errors"
"fmt"
"net"
"net/http"
@@ -55,10 +56,19 @@ type clientConfig struct {
// takes precedence. Either field disables API-version negotiation.
envAPIVersion string
// responseHooks is a list of custom response hooks to call on responses.
responseHooks []ResponseHook
// traceOpts is a list of options to configure the tracing span.
traceOpts []otelhttp.Option
}
// ResponseHook is called for each HTTP response returned by the daemon.
// Hooks are invoked in the order they were added.
//
// Hooks must not read or close resp.Body.
type ResponseHook func(*http.Response)
// Opt is a configuration option to initialize a [Client].
type Opt func(*clientConfig) error
@@ -348,3 +358,18 @@ func WithTraceOptions(opts ...otelhttp.Option) Opt {
return nil
}
}
// WithResponseHook adds a ResponseHook to the client. ResponseHooks are called
// for each HTTP response returned by the daemon. Hooks are invoked in the order
// they were added.
//
// Hooks must not read or close resp.Body.
func WithResponseHook(h ResponseHook) Opt {
return func(c *clientConfig) error {
if h == nil {
return errors.New("invalid response hook: hook is nil")
}
c.responseHooks = append(c.responseHooks, h)
return nil
}
}
+23
View File
@@ -0,0 +1,23 @@
package client
import (
"net/http"
)
type responseHookTransport struct {
base http.RoundTripper
hooks []ResponseHook
}
func (t *responseHookTransport) RoundTrip(req *http.Request) (*http.Response, error) {
resp, err := t.base.RoundTrip(req)
if err != nil {
return resp, err
}
for _, h := range t.hooks {
h(resp)
}
return resp, nil
}
+1 -1
View File
@@ -23,7 +23,7 @@ type ContainerAttachResult struct {
// ContainerAttach attaches a connection to a container in the server.
// It returns a [HijackedResponse] with the hijacked connection
// and a reader to get output. It's up to the called to close
// and a reader to get output. It's up to the caller to close
// the hijacked connection by calling [HijackedResponse.Close].
//
// The stream format on the response uses one of two formats:
+3 -5
View File
@@ -82,8 +82,7 @@ type ExecStartOptions struct {
}
// ExecStartResult holds the result of starting a container exec.
type ExecStartResult struct {
}
type ExecStartResult struct{}
// ExecStart starts an exec process already created in the docker host.
func (cli *Client) ExecStart(ctx context.Context, execID string, options ExecStartOptions) (ExecStartResult, error) {
@@ -118,7 +117,7 @@ type ExecAttachResult struct {
// ExecAttach attaches a connection to an exec process in the server.
//
// It returns a [HijackedResponse] with the hijacked connection
// and a reader to get output. It's up to the called to close
// and a reader to get output. It's up to the caller to close
// the hijacked connection by calling [HijackedResponse.Close].
//
// The stream format on the response uses one of two formats:
@@ -160,8 +159,7 @@ func getConsoleSize(hasTTY bool, consoleSize ConsoleSize) (*[2]uint, error) {
}
// ExecInspectOptions holds options for inspecting a container exec.
type ExecInspectOptions struct {
}
type ExecInspectOptions struct{}
// ExecInspectResult holds the result of inspecting a container exec.
//
+15 -11
View File
@@ -13,11 +13,23 @@ import (
type ContainerListOptions struct {
Size bool
All bool
Latest bool
Since string
Before string
Limit int
Filters Filters
// Latest is non-functional and should not be used. Use Limit: 1 instead.
//
// Deprecated: the Latest option is non-functional and should not be used. Use Limit: 1 instead.
Latest bool
// Since is no longer supported. Use the "since" filter instead.
//
// Deprecated: the Since option is no longer supported since docker 1.12 (API 1.24). Use the "since" filter instead.
Since string
// Before is no longer supported. Use the "since" filter instead.
//
// Deprecated: the Before option is no longer supported since docker 1.12 (API 1.24). Use the "before" filter instead.
Before string
}
type ContainerListResult struct {
@@ -36,14 +48,6 @@ func (cli *Client) ContainerList(ctx context.Context, options ContainerListOptio
query.Set("limit", strconv.Itoa(options.Limit))
}
if options.Since != "" {
query.Set("since", options.Since)
}
if options.Before != "" {
query.Set("before", options.Before)
}
if options.Size {
query.Set("size", "1")
}
+1 -3
View File
@@ -42,8 +42,7 @@ func (cli *Client) ContainerResize(ctx context.Context, containerID string, opti
type ExecResizeOptions ContainerResizeOptions
// ExecResizeResult holds the result of resizing a container exec TTY.
type ExecResizeResult struct {
}
type ExecResizeResult struct{}
// ExecResize changes the size of the tty for an exec process running inside a container.
func (cli *Client) ExecResize(ctx context.Context, execID string, options ExecResizeOptions) (ExecResizeResult, error) {
@@ -62,5 +61,4 @@ func (cli *Client) ExecResize(ctx context.Context, execID string, options ExecRe
return ExecResizeResult{}, err
}
return ExecResizeResult{}, nil
}
+2 -2
View File
@@ -167,7 +167,7 @@ github.com/moby/docker-image-spec/specs-go/v1
github.com/moby/go-archive
github.com/moby/go-archive/compression
github.com/moby/go-archive/tarheader
# github.com/moby/moby/api v1.53.0-rc.2
# github.com/moby/moby/api v1.53.0
## explicit; go 1.24.0
github.com/moby/moby/api/pkg/authconfig
github.com/moby/moby/api/pkg/stdcopy
@@ -189,7 +189,7 @@ 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.2.2-rc.2
# github.com/moby/moby/client v0.2.2
## explicit; go 1.24.0
github.com/moby/moby/client
github.com/moby/moby/client/internal