vendor: github.com/moby/moby/api, github.com/moby/moby/client master

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-08-27 16:35:41 +02:00
parent f40caed86c
commit cdf705ce66
20 changed files with 96 additions and 85 deletions

View File

@ -32,10 +32,8 @@ func TestNewAttachCommandErrors(t *testing.T) {
expectedError: "cannot attach to a stopped container",
containerInspectFunc: func(containerID string) (container.InspectResponse, error) {
return container.InspectResponse{
ContainerJSONBase: &container.ContainerJSONBase{
State: &container.State{
Running: false,
},
State: &container.State{
Running: false,
},
}, nil
},
@ -46,11 +44,9 @@ func TestNewAttachCommandErrors(t *testing.T) {
expectedError: "cannot attach to a paused container",
containerInspectFunc: func(containerID string) (container.InspectResponse, error) {
return container.InspectResponse{
ContainerJSONBase: &container.ContainerJSONBase{
State: &container.State{
Running: true,
Paused: true,
},
State: &container.State{
Running: true,
Paused: true,
},
}, nil
},
@ -61,12 +57,10 @@ func TestNewAttachCommandErrors(t *testing.T) {
expectedError: "cannot attach to a restarting container",
containerInspectFunc: func(containerID string) (container.InspectResponse, error) {
return container.InspectResponse{
ContainerJSONBase: &container.ContainerJSONBase{
State: &container.State{
Running: true,
Paused: false,
Restarting: true,
},
State: &container.State{
Running: true,
Paused: false,
Restarting: true,
},
}, nil
},

View File

@ -21,8 +21,8 @@ var logFn = func(expectedOut string) func(string, container.LogsOptions) (io.Rea
func TestRunLogs(t *testing.T) {
inspectFn := func(containerID string) (container.InspectResponse, error) {
return container.InspectResponse{
Config: &container.Config{Tty: true},
ContainerJSONBase: &container.ContainerJSONBase{State: &container.State{Running: false}},
Config: &container.Config{Tty: true},
State: &container.State{Running: false},
}, nil
}

View File

@ -10,7 +10,7 @@ import (
type fakeClient struct {
client.Client
networkCreateFunc func(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error)
networkCreateFunc func(ctx context.Context, name string, options client.NetworkCreateOptions) (network.CreateResponse, error)
networkConnectFunc func(ctx context.Context, networkID, container string, config *network.EndpointSettings) error
networkDisconnectFunc func(ctx context.Context, networkID, container string, force bool) error
networkRemoveFunc func(ctx context.Context, networkID string) error
@ -19,7 +19,7 @@ type fakeClient struct {
networkInspectFunc func(ctx context.Context, networkID string, options client.NetworkInspectOptions) (network.Inspect, []byte, error)
}
func (c *fakeClient) NetworkCreate(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error) {
func (c *fakeClient) NetworkCreate(ctx context.Context, name string, options client.NetworkCreateOptions) (network.CreateResponse, error) {
if c.networkCreateFunc != nil {
return c.networkCreateFunc(ctx, name, options)
}

View File

@ -113,7 +113,7 @@ func runCreate(ctx context.Context, apiClient client.NetworkAPIClient, output io
Network: options.configFrom,
}
}
resp, err := apiClient.NetworkCreate(ctx, options.name, network.CreateOptions{
resp, err := apiClient.NetworkCreate(ctx, options.name, client.NetworkCreateOptions{
Driver: options.driver,
Options: options.driverOpts.GetAll(),
IPAM: ipamCfg,

View File

@ -9,6 +9,7 @@ import (
"github.com/docker/cli/internal/test"
"github.com/moby/moby/api/types/network"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
)
@ -17,7 +18,7 @@ func TestNetworkCreateErrors(t *testing.T) {
testCases := []struct {
args []string
flags map[string]string
networkCreateFunc func(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error)
networkCreateFunc func(ctx context.Context, name string, options client.NetworkCreateOptions) (network.CreateResponse, error)
expectedError string
}{
{
@ -25,7 +26,7 @@ func TestNetworkCreateErrors(t *testing.T) {
},
{
args: []string{"toto"},
networkCreateFunc: func(ctx context.Context, name string, createBody network.CreateOptions) (network.CreateResponse, error) {
networkCreateFunc: func(ctx context.Context, name string, createBody client.NetworkCreateOptions) (network.CreateResponse, error) {
return network.CreateResponse{}, errors.New("error creating network")
},
expectedError: "error creating network",
@ -162,7 +163,7 @@ func TestNetworkCreateWithFlags(t *testing.T) {
},
}
cli := test.NewFakeCli(&fakeClient{
networkCreateFunc: func(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error) {
networkCreateFunc: func(ctx context.Context, name string, options client.NetworkCreateOptions) (network.CreateResponse, error) {
assert.Check(t, is.Equal(expectedDriver, options.Driver), "not expected driver error")
assert.Check(t, is.DeepEqual(expectedOpts, options.IPAM.Config), "not expected driver error")
return network.CreateResponse{
@ -220,7 +221,7 @@ func TestNetworkCreateIPv4(t *testing.T) {
for _, tc := range tests {
t.Run(tc.doc, func(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{
networkCreateFunc: func(ctx context.Context, name string, createBody network.CreateOptions) (network.CreateResponse, error) {
networkCreateFunc: func(ctx context.Context, name string, createBody client.NetworkCreateOptions) (network.CreateResponse, error) {
assert.Check(t, is.DeepEqual(createBody.EnableIPv4, tc.expected))
return network.CreateResponse{ID: name}, nil
},
@ -274,7 +275,7 @@ func TestNetworkCreateIPv6(t *testing.T) {
for _, tc := range tests {
t.Run(tc.doc, func(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{
networkCreateFunc: func(ctx context.Context, name string, createBody network.CreateOptions) (network.CreateResponse, error) {
networkCreateFunc: func(ctx context.Context, name string, createBody client.NetworkCreateOptions) (network.CreateResponse, error) {
assert.Check(t, is.DeepEqual(tc.expected, createBody.EnableIPv6))
return network.CreateResponse{ID: name}, nil
},

View File

@ -156,7 +156,7 @@ func createConfigs(ctx context.Context, dockerCLI command.Cli, configs []swarm.C
return nil
}
func createNetworks(ctx context.Context, dockerCLI command.Cli, namespace convert.Namespace, networks map[string]network.CreateOptions) error {
func createNetworks(ctx context.Context, dockerCLI command.Cli, namespace convert.Namespace, networks map[string]client.NetworkCreateOptions) error {
apiClient := dockerCLI.Client()
existingNetworks, err := getStackNetworks(ctx, apiClient, namespace.Name())

View File

@ -7,6 +7,7 @@ import (
composetypes "github.com/docker/cli/cli/compose/types"
"github.com/moby/moby/api/types/network"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
)
const (
@ -51,13 +52,13 @@ func AddStackLabel(namespace Namespace, labels map[string]string) map[string]str
type networkMap map[string]composetypes.NetworkConfig
// Networks from the compose-file type to the engine API type
func Networks(namespace Namespace, networks networkMap, servicesNetworks map[string]struct{}) (map[string]network.CreateOptions, []string) {
func Networks(namespace Namespace, networks networkMap, servicesNetworks map[string]struct{}) (map[string]client.NetworkCreateOptions, []string) {
if networks == nil {
networks = make(map[string]composetypes.NetworkConfig)
}
externalNetworks := []string{}
result := make(map[string]network.CreateOptions)
result := make(map[string]client.NetworkCreateOptions)
for internalName := range servicesNetworks {
nw := networks[internalName]
if nw.External.External {
@ -65,7 +66,7 @@ func Networks(namespace Namespace, networks networkMap, servicesNetworks map[str
continue
}
createOpts := network.CreateOptions{
createOpts := client.NetworkCreateOptions{
Labels: AddStackLabel(namespace, nw.Labels),
Driver: nw.Driver,
Options: nw.DriverOpts,

View File

@ -5,6 +5,7 @@ import (
composetypes "github.com/docker/cli/cli/compose/types"
"github.com/moby/moby/api/types/network"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/fs"
@ -76,7 +77,7 @@ func TestNetworks(t *testing.T) {
Name: "othername",
},
}
expected := map[string]network.CreateOptions{
expected := map[string]client.NetworkCreateOptions{
"foo_default": {
Labels: map[string]string{
LabelNamespace: "foo",

View File

@ -28,8 +28,8 @@ require (
github.com/google/uuid v1.6.0
github.com/mattn/go-runewidth v0.0.16
github.com/moby/go-archive v0.1.0
github.com/moby/moby/api v1.52.0-alpha.1.0.20250826224528-62884141100c // master
github.com/moby/moby/client v0.1.0-alpha.0.0.20250826224528-62884141100c // master
github.com/moby/moby/api v1.52.0-alpha.1.0.20250827142737-8ac1bfa6c554 // master
github.com/moby/moby/client v0.1.0-alpha.0.0.20250827142737-8ac1bfa6c554 // master
github.com/moby/patternmatcher v0.6.0
github.com/moby/swarmkit/v2 v2.0.0
github.com/moby/sys/atomicwriter v0.1.0

View File

@ -170,10 +170,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.1.0 h1:Kk/5rdW/g+H8NHdJW2gsXyZ7UnzvJNOy6VKJqueWdcQ=
github.com/moby/go-archive v0.1.0/go.mod h1:G9B+YoujNohJmrIYFBpSd54GTUB4lt9S+xVQvsJyFuo=
github.com/moby/moby/api v1.52.0-alpha.1.0.20250826224528-62884141100c h1:AcG4SepExP6gSs565xPaCqlmEq0uDHKE1rYvnvVPCKk=
github.com/moby/moby/api v1.52.0-alpha.1.0.20250826224528-62884141100c/go.mod h1:8sBV0soUREiudtow4vqJGOxa4GyHI5vLQmvgKdHq5Ok=
github.com/moby/moby/client v0.1.0-alpha.0.0.20250826224528-62884141100c h1:+O0DPAuYz+gqyPLChsGdFUIR2ujMlyJcTchS5PDdrYU=
github.com/moby/moby/client v0.1.0-alpha.0.0.20250826224528-62884141100c/go.mod h1:7pOYrEHdG7I0dNZEC+yqk/p8ZOxGMR1KgoexzCEDe0w=
github.com/moby/moby/api v1.52.0-alpha.1.0.20250827142737-8ac1bfa6c554 h1:N6U77C4Lro2uqDeBGP4Zz3UIHjaQst8E45P9vOeUY7E=
github.com/moby/moby/api v1.52.0-alpha.1.0.20250827142737-8ac1bfa6c554/go.mod h1:8sBV0soUREiudtow4vqJGOxa4GyHI5vLQmvgKdHq5Ok=
github.com/moby/moby/client v0.1.0-alpha.0.0.20250827142737-8ac1bfa6c554 h1:8Vd0p/2rVqjnyQxUbcaox9uVhbgxr9axxfSWdpq1KXc=
github.com/moby/moby/client v0.1.0-alpha.0.0.20250827142737-8ac1bfa6c554/go.mod h1:7pOYrEHdG7I0dNZEC+yqk/p8ZOxGMR1KgoexzCEDe0w=
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.0.0 h1:jkWQKQaJ4ltA61/mC9UdPe1McLma55RUcacTO+pPweY=

View File

@ -119,16 +119,9 @@ type Summary struct {
Mounts []MountPoint
}
// ContainerJSONBase contains response of Engine API GET "/containers/{name:.*}/json"
// for API version 1.18 and older.
//
// TODO(thaJeztah): combine ContainerJSONBase and InspectResponse into a single struct.
// The split between ContainerJSONBase (ContainerJSONBase) and InspectResponse (InspectResponse)
// was done in commit 6deaa58ba5f051039643cedceee97c8695e2af74 (https://github.com/moby/moby/pull/13675).
// ContainerJSONBase contained all fields for API < 1.19, and InspectResponse
// held fields that were added in API 1.19 and up. Given that the minimum
// supported API version is now 1.24, we no longer use the separate type.
type ContainerJSONBase struct {
// InspectResponse is the response for the GET "/containers/{name:.*}/json"
// endpoint.
type InspectResponse struct {
ID string `json:"Id"`
Created string
Path string
@ -151,12 +144,6 @@ type ContainerJSONBase struct {
GraphDriver storage.DriverData
SizeRw *int64 `json:",omitempty"`
SizeRootFs *int64 `json:",omitempty"`
}
// InspectResponse is the response for the GET "/containers/{name:.*}/json"
// endpoint.
type InspectResponse struct {
*ContainerJSONBase
Mounts []MountPoint
Config *Config
NetworkSettings *NetworkSettings

View File

@ -21,16 +21,7 @@ const (
// CreateRequest is the request message sent to the server for network create call.
type CreateRequest struct {
CreateOptions
Name string // Name is the requested name of the network.
// Deprecated: CheckDuplicate is deprecated since API v1.44, but it defaults to true when sent by the client
// package to older daemons.
CheckDuplicate *bool `json:",omitempty"`
}
// CreateOptions holds options to create a network.
type CreateOptions struct {
Name string // Name is the requested name of the network.
Driver string // Driver is the driver-name used to create the network (e.g. `bridge`, `overlay`)
Scope string // Scope describes the level at which the network exists (e.g. `swarm` for cluster-wide or `local` for machine level).
EnableIPv4 *bool `json:",omitempty"` // EnableIPv4 represents whether to enable IPv4.
@ -43,20 +34,10 @@ type CreateOptions struct {
ConfigFrom *ConfigReference // ConfigFrom specifies the source which will provide the configuration for this network. The specified network must be a config-only network; see [CreateOptions.ConfigOnly].
Options map[string]string // Options specifies the network-specific options to use for when creating the network.
Labels map[string]string // Labels holds metadata specific to the network being created.
}
// ConnectOptions represents the data to be used to connect a container to the
// network.
type ConnectOptions struct {
Container string
EndpointConfig *EndpointSettings `json:",omitempty"`
}
// DisconnectOptions represents the data to be used to disconnect a container
// from the network.
type DisconnectOptions struct {
Container string
Force bool
// Deprecated: CheckDuplicate is deprecated since API v1.44, but it defaults to true when sent by the client
// package to older daemons.
CheckDuplicate *bool `json:",omitempty"`
}
// Inspect is the body of the "get network" http response message.

View File

@ -129,7 +129,7 @@ type ImageAPIClient interface {
// NetworkAPIClient defines API client methods for the networks
type NetworkAPIClient interface {
NetworkConnect(ctx context.Context, network, container string, config *network.EndpointSettings) error
NetworkCreate(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error)
NetworkCreate(ctx context.Context, name string, options NetworkCreateOptions) (network.CreateResponse, error)
NetworkDisconnect(ctx context.Context, network, container string, force bool) error
NetworkInspect(ctx context.Context, network string, options NetworkInspectOptions) (network.Inspect, error)
NetworkInspectWithRaw(ctx context.Context, network string, options NetworkInspectOptions) (network.Inspect, []byte, error)

View File

@ -18,7 +18,7 @@ func (cli *Client) NetworkConnect(ctx context.Context, networkID, containerID st
return err
}
nc := network.ConnectOptions{
nc := NetworkConnectOptions{
Container: containerID,
EndpointConfig: config,
}

View File

@ -0,0 +1,10 @@
package client
import "github.com/moby/moby/api/types/network"
// NetworkConnectOptions represents the data to be used to connect a container to the
// network.
type NetworkConnectOptions struct {
Container string
EndpointConfig *network.EndpointSettings `json:",omitempty"`
}

View File

@ -9,7 +9,7 @@ import (
)
// NetworkCreate creates a new network in the docker host.
func (cli *Client) NetworkCreate(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error) {
func (cli *Client) NetworkCreate(ctx context.Context, name string, options NetworkCreateOptions) (network.CreateResponse, error) {
// Make sure we negotiated (if the client is configured to do so),
// as code below contains API-version specific handling of options.
//
@ -20,8 +20,19 @@ func (cli *Client) NetworkCreate(ctx context.Context, name string, options netwo
}
networkCreateRequest := network.CreateRequest{
CreateOptions: options,
Name: name,
Name: name,
Driver: options.Driver,
Scope: options.Scope,
EnableIPv4: options.EnableIPv4,
EnableIPv6: options.EnableIPv6,
IPAM: options.IPAM,
Internal: options.Internal,
Attachable: options.Attachable,
Ingress: options.Ingress,
ConfigOnly: options.ConfigOnly,
ConfigFrom: options.ConfigFrom,
Options: options.Options,
Labels: options.Labels,
}
if versions.LessThan(cli.version, "1.44") {
enabled := true

View File

@ -0,0 +1,19 @@
package client
import "github.com/moby/moby/api/types/network"
// NetworkCreateOptions holds options to create a network.
type NetworkCreateOptions struct {
Driver string // Driver is the driver-name used to create the network (e.g. `bridge`, `overlay`)
Scope string // Scope describes the level at which the network exists (e.g. `swarm` for cluster-wide or `local` for machine level).
EnableIPv4 *bool // EnableIPv4 represents whether to enable IPv4.
EnableIPv6 *bool // EnableIPv6 represents whether to enable IPv6.
IPAM *network.IPAM // IPAM is the network's IP Address Management.
Internal bool // Internal represents if the network is used internal only.
Attachable bool // Attachable represents if the global scope is manually attachable by regular containers from workers in swarm mode.
Ingress bool // Ingress indicates the network is providing the routing-mesh for the swarm cluster.
ConfigOnly bool // ConfigOnly creates a config-only network. Config-only networks are place-holder networks for network configurations to be used by other networks. ConfigOnly networks cannot be used directly to run containers or services.
ConfigFrom *network.ConfigReference // ConfigFrom specifies the source which will provide the configuration for this network. The specified network must be a config-only network; see [CreateOptions.ConfigOnly].
Options map[string]string // Options specifies the network-specific options to use for when creating the network.
Labels map[string]string // Labels holds metadata specific to the network being created.
}

View File

@ -2,8 +2,6 @@ package client
import (
"context"
"github.com/moby/moby/api/types/network"
)
// NetworkDisconnect disconnects a container from an existent network in the docker host.
@ -18,7 +16,7 @@ func (cli *Client) NetworkDisconnect(ctx context.Context, networkID, containerID
return err
}
nd := network.DisconnectOptions{
nd := NetworkDisconnectOptions{
Container: containerID,
Force: force,
}

View File

@ -0,0 +1,8 @@
package client
// NetworkDisconnectOptions represents the data to be used to disconnect a container
// from the network.
type NetworkDisconnectOptions struct {
Container string
Force bool
}

4
vendor/modules.txt vendored
View File

@ -168,7 +168,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.52.0-alpha.1.0.20250826224528-62884141100c
# github.com/moby/moby/api v1.52.0-alpha.1.0.20250827142737-8ac1bfa6c554
## explicit; go 1.23.0
github.com/moby/moby/api/pkg/authconfig
github.com/moby/moby/api/pkg/progress
@ -194,7 +194,7 @@ github.com/moby/moby/api/types/swarm
github.com/moby/moby/api/types/system
github.com/moby/moby/api/types/versions
github.com/moby/moby/api/types/volume
# github.com/moby/moby/client v0.1.0-alpha.0.0.20250826224528-62884141100c
# github.com/moby/moby/client v0.1.0-alpha.0.0.20250827142737-8ac1bfa6c554
## explicit; go 1.23.0
github.com/moby/moby/client
github.com/moby/moby/client/internal/timestamp