Merge pull request #5100 from thaJeztah/bump_engine

vendor: github.com/docker/docker e622cea55698 (master / v27.0.0-dev)
This commit is contained in:
Sebastiaan van Stijn 2024-05-31 22:00:08 +02:00 committed by GitHub
commit 1a8fa8b73e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
32 changed files with 402 additions and 236 deletions

View File

@ -11,20 +11,20 @@ import (
type fakeClient struct { type fakeClient struct {
client.Client client.Client
networkCreateFunc func(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error) networkCreateFunc func(ctx context.Context, name string, options types.NetworkCreate) (network.CreateResponse, error)
networkConnectFunc func(ctx context.Context, networkID, container string, config *network.EndpointSettings) error networkConnectFunc func(ctx context.Context, networkID, container string, config *network.EndpointSettings) error
networkDisconnectFunc func(ctx context.Context, networkID, container string, force bool) error networkDisconnectFunc func(ctx context.Context, networkID, container string, force bool) error
networkRemoveFunc func(ctx context.Context, networkID string) error networkRemoveFunc func(ctx context.Context, networkID string) error
networkListFunc func(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) networkListFunc func(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error)
networkPruneFunc func(ctx context.Context, pruneFilters filters.Args) (types.NetworksPruneReport, error) networkPruneFunc func(ctx context.Context, pruneFilters filters.Args) (types.NetworksPruneReport, error)
networkInspectFunc func(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, []byte, error) networkInspectFunc func(ctx context.Context, networkID string, options network.InspectOptions) (types.NetworkResource, []byte, error)
} }
func (c *fakeClient) NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error) { func (c *fakeClient) NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (network.CreateResponse, error) {
if c.networkCreateFunc != nil { if c.networkCreateFunc != nil {
return c.networkCreateFunc(ctx, name, options) return c.networkCreateFunc(ctx, name, options)
} }
return types.NetworkCreateResponse{}, nil return network.CreateResponse{}, nil
} }
func (c *fakeClient) NetworkConnect(ctx context.Context, networkID, container string, config *network.EndpointSettings) error { func (c *fakeClient) NetworkConnect(ctx context.Context, networkID, container string, config *network.EndpointSettings) error {
@ -55,7 +55,7 @@ func (c *fakeClient) NetworkRemove(ctx context.Context, networkID string) error
return nil return nil
} }
func (c *fakeClient) NetworkInspectWithRaw(ctx context.Context, networkID string, opts types.NetworkInspectOptions) (types.NetworkResource, []byte, error) { func (c *fakeClient) NetworkInspectWithRaw(ctx context.Context, networkID string, opts network.InspectOptions) (types.NetworkResource, []byte, error) {
if c.networkInspectFunc != nil { if c.networkInspectFunc != nil {
return c.networkInspectFunc(ctx, networkID, opts) return c.networkInspectFunc(ctx, networkID, opts)
} }

View File

@ -18,7 +18,7 @@ func TestNetworkCreateErrors(t *testing.T) {
testCases := []struct { testCases := []struct {
args []string args []string
flags map[string]string flags map[string]string
networkCreateFunc func(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error) networkCreateFunc func(ctx context.Context, name string, options types.NetworkCreate) (network.CreateResponse, error)
expectedError string expectedError string
}{ }{
{ {
@ -26,8 +26,8 @@ func TestNetworkCreateErrors(t *testing.T) {
}, },
{ {
args: []string{"toto"}, args: []string{"toto"},
networkCreateFunc: func(ctx context.Context, name string, createBody types.NetworkCreate) (types.NetworkCreateResponse, error) { networkCreateFunc: func(ctx context.Context, name string, createBody types.NetworkCreate) (network.CreateResponse, error) {
return types.NetworkCreateResponse{}, errors.Errorf("error creating network") return network.CreateResponse{}, errors.Errorf("error creating network")
}, },
expectedError: "error creating network", expectedError: "error creating network",
}, },
@ -153,10 +153,10 @@ func TestNetworkCreateWithFlags(t *testing.T) {
}, },
} }
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
networkCreateFunc: func(ctx context.Context, name string, createBody types.NetworkCreate) (types.NetworkCreateResponse, error) { networkCreateFunc: func(ctx context.Context, name string, createBody types.NetworkCreate) (network.CreateResponse, error) {
assert.Check(t, is.Equal(expectedDriver, createBody.Driver), "not expected driver error") assert.Check(t, is.Equal(expectedDriver, createBody.Driver), "not expected driver error")
assert.Check(t, is.DeepEqual(expectedOpts, createBody.IPAM.Config), "not expected driver error") assert.Check(t, is.DeepEqual(expectedOpts, createBody.IPAM.Config), "not expected driver error")
return types.NetworkCreateResponse{ return network.CreateResponse{
ID: name, ID: name,
}, nil }, nil
}, },

View File

@ -11,7 +11,7 @@ import (
"github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/completion"
"github.com/docker/cli/cli/command/inspect" "github.com/docker/cli/cli/command/inspect"
flagsHelper "github.com/docker/cli/cli/flags" flagsHelper "github.com/docker/cli/cli/flags"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types/network"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -45,7 +45,7 @@ func runInspect(ctx context.Context, dockerCli command.Cli, opts inspectOptions)
client := dockerCli.Client() client := dockerCli.Client()
getNetFunc := func(name string) (any, []byte, error) { getNetFunc := func(name string) (any, []byte, error) {
return client.NetworkInspectWithRaw(ctx, name, types.NetworkInspectOptions{Verbose: opts.verbose}) return client.NetworkInspectWithRaw(ctx, name, network.InspectOptions{Verbose: opts.verbose})
} }
return inspect.Inspect(dockerCli.Out(), opts.names, opts.format, getNetFunc) return inspect.Inspect(dockerCli.Out(), opts.names, opts.format, getNetFunc)

View File

@ -7,7 +7,7 @@ import (
"github.com/docker/cli/cli" "github.com/docker/cli/cli"
"github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/completion" "github.com/docker/cli/cli/command/completion"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types/network"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -46,7 +46,7 @@ func runRemove(ctx context.Context, dockerCli command.Cli, networks []string, op
status := 0 status := 0
for _, name := range networks { for _, name := range networks {
nw, _, err := client.NetworkInspectWithRaw(ctx, name, types.NetworkInspectOptions{}) nw, _, err := client.NetworkInspectWithRaw(ctx, name, network.InspectOptions{})
if err == nil && nw.Ingress { if err == nil && nw.Ingress {
r, err := command.PromptForConfirmation(ctx, dockerCli.In(), dockerCli.Out(), ingressWarning) r, err := command.PromptForConfirmation(ctx, dockerCli.In(), dockerCli.Out(), ingressWarning)
if err != nil { if err != nil {

View File

@ -7,6 +7,7 @@ import (
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"github.com/pkg/errors" "github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
@ -104,7 +105,7 @@ func TestNetworkRemovePromptTermination(t *testing.T) {
networkRemoveFunc: func(ctx context.Context, networkID string) error { networkRemoveFunc: func(ctx context.Context, networkID string) error {
return errors.New("fakeClient networkRemoveFunc should not be called") return errors.New("fakeClient networkRemoveFunc should not be called")
}, },
networkInspectFunc: func(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, []byte, error) { networkInspectFunc: func(ctx context.Context, networkID string, options network.InspectOptions) (types.NetworkResource, []byte, error) {
return types.NetworkResource{ return types.NetworkResource{
ID: "existing-network", ID: "existing-network",
Name: "existing-network", Name: "existing-network",

View File

@ -5,6 +5,7 @@ import (
"github.com/docker/cli/internal/test/builders" "github.com/docker/cli/internal/test/builders"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/api/types/system" "github.com/docker/docker/api/types/system"
"github.com/docker/docker/client" "github.com/docker/docker/client"
@ -17,7 +18,7 @@ type fakeClient struct {
serviceListFunc func(context.Context, types.ServiceListOptions) ([]swarm.Service, error) serviceListFunc func(context.Context, types.ServiceListOptions) ([]swarm.Service, error)
taskListFunc func(context.Context, types.TaskListOptions) ([]swarm.Task, error) taskListFunc func(context.Context, types.TaskListOptions) ([]swarm.Task, error)
infoFunc func(ctx context.Context) (system.Info, error) infoFunc func(ctx context.Context) (system.Info, error)
networkInspectFunc func(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, error) networkInspectFunc func(ctx context.Context, networkID string, options network.InspectOptions) (types.NetworkResource, error)
nodeListFunc func(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error) nodeListFunc func(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error)
} }
@ -66,7 +67,7 @@ func (f *fakeClient) Info(ctx context.Context) (system.Info, error) {
return f.infoFunc(ctx) return f.infoFunc(ctx)
} }
func (f *fakeClient) NetworkInspect(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, error) { func (f *fakeClient) NetworkInspect(ctx context.Context, networkID string, options network.InspectOptions) (types.NetworkResource, error) {
if f.networkInspectFunc != nil { if f.networkInspectFunc != nil {
return f.networkInspectFunc(ctx, networkID, options) return f.networkInspectFunc(ctx, networkID, options)
} }

View File

@ -12,6 +12,7 @@ import (
"github.com/docker/cli/cli/command/formatter" "github.com/docker/cli/cli/command/formatter"
flagsHelper "github.com/docker/cli/cli/flags" flagsHelper "github.com/docker/cli/cli/flags"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -66,9 +67,9 @@ func runInspect(ctx context.Context, dockerCli command.Cli, opts inspectOptions)
} }
getNetwork := func(ref string) (any, []byte, error) { getNetwork := func(ref string) (any, []byte, error) {
network, _, err := client.NetworkInspectWithRaw(ctx, ref, types.NetworkInspectOptions{Scope: "swarm"}) nw, _, err := client.NetworkInspectWithRaw(ctx, ref, network.InspectOptions{Scope: "swarm"})
if err == nil || !errdefs.IsNotFound(err) { if err == nil || !errdefs.IsNotFound(err) {
return network, nil, err return nw, nil, err
} }
return nil, nil, errors.Errorf("Error: no such network: %s", ref) return nil, nil, errors.Errorf("Error: no such network: %s", ref)
} }

View File

@ -13,8 +13,8 @@ import (
"github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command"
"github.com/docker/cli/opts" "github.com/docker/cli/opts"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/client" "github.com/docker/docker/client"
gogotypes "github.com/gogo/protobuf/types" gogotypes "github.com/gogo/protobuf/types"
@ -376,7 +376,7 @@ func (c *credentialSpecOpt) Value() *swarm.CredentialSpec {
} }
func resolveNetworkID(ctx context.Context, apiClient client.NetworkAPIClient, networkIDOrName string) (string, error) { func resolveNetworkID(ctx context.Context, apiClient client.NetworkAPIClient, networkIDOrName string) (string, error) {
nw, err := apiClient.NetworkInspect(ctx, networkIDOrName, types.NetworkInspectOptions{Scope: "swarm"}) nw, err := apiClient.NetworkInspect(ctx, networkIDOrName, network.InspectOptions{Scope: "swarm"})
return nw.ID, err return nw.ID, err
} }

View File

@ -9,6 +9,7 @@ import (
"github.com/docker/cli/opts" "github.com/docker/cli/opts"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
@ -192,10 +193,10 @@ func TestToServiceNetwork(t *testing.T) {
} }
client := &fakeClient{ client := &fakeClient{
networkInspectFunc: func(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, error) { networkInspectFunc: func(ctx context.Context, networkID string, options network.InspectOptions) (types.NetworkResource, error) {
for _, network := range nws { for _, nw := range nws {
if network.ID == networkID || network.Name == networkID { if nw.ID == networkID || nw.Name == networkID {
return network, nil return nw, nil
} }
} }
return types.NetworkResource{}, fmt.Errorf("network not found: %s", networkID) return types.NetworkResource{}, fmt.Errorf("network not found: %s", networkID)

View File

@ -13,6 +13,7 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
mounttypes "github.com/docker/docker/api/types/mount" mounttypes "github.com/docker/docker/api/types/mount"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/api/types/versions" "github.com/docker/docker/api/types/versions"
"github.com/docker/docker/client" "github.com/docker/docker/client"
@ -1301,38 +1302,38 @@ func updateNetworks(ctx context.Context, apiClient client.NetworkAPIClient, flag
toRemove := buildToRemoveSet(flags, flagNetworkRemove) toRemove := buildToRemoveSet(flags, flagNetworkRemove)
idsToRemove := make(map[string]struct{}) idsToRemove := make(map[string]struct{})
for networkIDOrName := range toRemove { for networkIDOrName := range toRemove {
network, err := apiClient.NetworkInspect(ctx, networkIDOrName, types.NetworkInspectOptions{Scope: "swarm"}) nw, err := apiClient.NetworkInspect(ctx, networkIDOrName, network.InspectOptions{Scope: "swarm"})
if err != nil { if err != nil {
return err return err
} }
idsToRemove[network.ID] = struct{}{} idsToRemove[nw.ID] = struct{}{}
} }
existingNetworks := make(map[string]struct{}) existingNetworks := make(map[string]struct{})
var newNetworks []swarm.NetworkAttachmentConfig //nolint:prealloc var newNetworks []swarm.NetworkAttachmentConfig //nolint:prealloc
for _, network := range specNetworks { for _, nw := range specNetworks {
if _, exists := idsToRemove[network.Target]; exists { if _, exists := idsToRemove[nw.Target]; exists {
continue continue
} }
newNetworks = append(newNetworks, network) newNetworks = append(newNetworks, nw)
existingNetworks[network.Target] = struct{}{} existingNetworks[nw.Target] = struct{}{}
} }
if flags.Changed(flagNetworkAdd) { if flags.Changed(flagNetworkAdd) {
values := flags.Lookup(flagNetworkAdd).Value.(*opts.NetworkOpt) values := flags.Lookup(flagNetworkAdd).Value.(*opts.NetworkOpt)
networks := convertNetworks(*values) networks := convertNetworks(*values)
for _, network := range networks { for _, nw := range networks {
nwID, err := resolveNetworkID(ctx, apiClient, network.Target) nwID, err := resolveNetworkID(ctx, apiClient, nw.Target)
if err != nil { if err != nil {
return err return err
} }
if _, exists := existingNetworks[nwID]; exists { if _, exists := existingNetworks[nwID]; exists {
return errors.Errorf("service is already attached to network %s", network.Target) return errors.Errorf("service is already attached to network %s", nw.Target)
} }
network.Target = nwID nw.Target = nwID
newNetworks = append(newNetworks, network) newNetworks = append(newNetworks, nw)
existingNetworks[network.Target] = struct{}{} existingNetworks[nw.Target] = struct{}{}
} }
} }

View File

@ -11,6 +11,7 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
mounttypes "github.com/docker/docker/api/types/mount" mounttypes "github.com/docker/docker/api/types/mount"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/go-units" "github.com/docker/go-units"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
@ -853,10 +854,10 @@ func TestUpdateNetworks(t *testing.T) {
} }
client := &fakeClient{ client := &fakeClient{
networkInspectFunc: func(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, error) { networkInspectFunc: func(ctx context.Context, networkID string, options network.InspectOptions) (types.NetworkResource, error) {
for _, network := range nws { for _, nw := range nws {
if network.ID == networkID || network.Name == networkID { if nw.ID == networkID || nw.Name == networkID {
return network, nil return nw, nil
} }
} }
return types.NetworkResource{}, fmt.Errorf("network not found: %s", networkID) return types.NetworkResource{}, fmt.Errorf("network not found: %s", networkID)

View File

@ -12,6 +12,7 @@ import (
composetypes "github.com/docker/cli/cli/compose/types" composetypes "github.com/docker/cli/cli/compose/types"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
apiclient "github.com/docker/docker/client" apiclient "github.com/docker/docker/client"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
@ -81,8 +82,8 @@ func getServicesDeclaredNetworks(serviceConfigs []composetypes.ServiceConfig) ma
serviceNetworks["default"] = struct{}{} serviceNetworks["default"] = struct{}{}
continue continue
} }
for network := range serviceConfig.Networks { for nw := range serviceConfig.Networks {
serviceNetworks[network] = struct{}{} serviceNetworks[nw] = struct{}{}
} }
} }
return serviceNetworks return serviceNetworks
@ -95,14 +96,14 @@ func validateExternalNetworks(ctx context.Context, client apiclient.NetworkAPICl
// local-scoped networks, so there's no need to inspect them. // local-scoped networks, so there's no need to inspect them.
continue continue
} }
network, err := client.NetworkInspect(ctx, networkName, types.NetworkInspectOptions{}) nw, err := client.NetworkInspect(ctx, networkName, network.InspectOptions{})
switch { switch {
case errdefs.IsNotFound(err): case errdefs.IsNotFound(err):
return fmt.Errorf("network %q is declared as external, but could not be found. You need to create a swarm-scoped network before the stack is deployed", networkName) return fmt.Errorf("network %q is declared as external, but could not be found. You need to create a swarm-scoped network before the stack is deployed", networkName)
case err != nil: case err != nil:
return err return err
case network.Scope != "swarm": case nw.Scope != "swarm":
return fmt.Errorf("network %q is declared as external, but it is not in the right scope: %q instead of \"swarm\"", networkName, network.Scope) return fmt.Errorf("network %q is declared as external, but it is not in the right scope: %q instead of \"swarm\"", networkName, nw.Scope)
} }
} }
return nil return nil
@ -165,8 +166,8 @@ func createNetworks(ctx context.Context, dockerCli command.Cli, namespace conver
} }
existingNetworkMap := make(map[string]types.NetworkResource) existingNetworkMap := make(map[string]types.NetworkResource)
for _, network := range existingNetworks { for _, nw := range existingNetworks {
existingNetworkMap[network.Name] = network existingNetworkMap[nw.Name] = nw
} }
for name, createOpts := range networks { for name, createOpts := range networks {

View File

@ -6,6 +6,7 @@ import (
"github.com/docker/cli/internal/test/network" "github.com/docker/cli/internal/test/network"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
networktypes "github.com/docker/docker/api/types/network"
"github.com/pkg/errors" "github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
) )
@ -50,7 +51,7 @@ func TestValidateExternalNetworks(t *testing.T) {
for _, testcase := range testcases { for _, testcase := range testcases {
fakeClient := &network.FakeClient{ fakeClient := &network.FakeClient{
NetworkInspectFunc: func(_ context.Context, _ string, _ types.NetworkInspectOptions) (types.NetworkResource, error) { NetworkInspectFunc: func(_ context.Context, _ string, _ networktypes.InspectOptions) (types.NetworkResource, error) {
return testcase.inspectResponse, testcase.inspectError return testcase.inspectResponse, testcase.inspectError
}, },
} }

View File

@ -13,6 +13,7 @@ import (
"github.com/docker/cli/cli/command/inspect" "github.com/docker/cli/cli/command/inspect"
flagsHelper "github.com/docker/cli/cli/flags" flagsHelper "github.com/docker/cli/cli/flags"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -72,7 +73,7 @@ func inspectImages(ctx context.Context, dockerCli command.Cli) inspect.GetRefFun
func inspectNetwork(ctx context.Context, dockerCli command.Cli) inspect.GetRefFunc { func inspectNetwork(ctx context.Context, dockerCli command.Cli) inspect.GetRefFunc {
return func(ref string) (any, []byte, error) { return func(ref string) (any, []byte, error) {
return dockerCli.Client().NetworkInspectWithRaw(ctx, ref, types.NetworkInspectOptions{}) return dockerCli.Client().NetworkInspectWithRaw(ctx, ref, network.InspectOptions{})
} }
} }

View File

@ -4,17 +4,18 @@ import (
"context" "context"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/client" "github.com/docker/docker/client"
) )
// FakeClient is a fake NetworkAPIClient // FakeClient is a fake NetworkAPIClient
type FakeClient struct { type FakeClient struct {
client.NetworkAPIClient client.NetworkAPIClient
NetworkInspectFunc func(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, error) NetworkInspectFunc func(ctx context.Context, networkID string, options network.InspectOptions) (types.NetworkResource, error)
} }
// NetworkInspect fakes inspecting a network // NetworkInspect fakes inspecting a network
func (c *FakeClient) NetworkInspect(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, error) { func (c *FakeClient) NetworkInspect(ctx context.Context, networkID string, options network.InspectOptions) (types.NetworkResource, error) {
if c.NetworkInspectFunc != nil { if c.NetworkInspectFunc != nil {
return c.NetworkInspectFunc(ctx, networkID, options) return c.NetworkInspectFunc(ctx, networkID, options)
} }

View File

@ -12,7 +12,7 @@ require (
github.com/creack/pty v1.1.21 github.com/creack/pty v1.1.21
github.com/distribution/reference v0.5.0 github.com/distribution/reference v0.5.0
github.com/docker/distribution v2.8.3+incompatible github.com/docker/distribution v2.8.3+incompatible
github.com/docker/docker v26.1.1-0.20240516211257-06e3a49d66fa+incompatible github.com/docker/docker v26.1.1-0.20240530195642-e622cea55698+incompatible // master (v27.0.0-dev)
github.com/docker/docker-credential-helpers v0.8.2 github.com/docker/docker-credential-helpers v0.8.2
github.com/docker/go-connections v0.5.0 github.com/docker/go-connections v0.5.0
github.com/docker/go-units v0.5.0 github.com/docker/go-units v0.5.0
@ -29,7 +29,7 @@ require (
github.com/moby/term v0.5.0 github.com/moby/term v0.5.0
github.com/morikuni/aec v1.0.0 github.com/morikuni/aec v1.0.0
github.com/opencontainers/go-digest v1.0.0 github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.1.0-rc5 github.com/opencontainers/image-spec v1.1.0
github.com/pkg/errors v0.9.1 github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.9.3 github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.8.0 github.com/spf13/cobra v1.8.0
@ -56,7 +56,7 @@ require (
require ( require (
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/Microsoft/hcsshim v0.11.4 // indirect github.com/Microsoft/hcsshim v0.11.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect

View File

@ -8,8 +8,8 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8= github.com/Microsoft/hcsshim v0.11.5 h1:haEcLNpj9Ka1gd3B3tAEs9CpE0c+1IhoL59w/exYU38=
github.com/Microsoft/hcsshim v0.11.4/go.mod h1:smjE4dvqPX9Zldna+t5FG3rnoHhaB7QYxPRqGcpAD9w= github.com/Microsoft/hcsshim v0.11.5/go.mod h1:MV8xMfmECjl5HdO7U/3/hFVnkmSBjAjmA09d4bExKcU=
github.com/Shopify/logrus-bugsnag v0.0.0-20170309145241-6dbc35f2c30d h1:hi6J4K6DKrR4/ljxn6SF6nURyu785wKMuQcjt7H3VCQ= github.com/Shopify/logrus-bugsnag v0.0.0-20170309145241-6dbc35f2c30d h1:hi6J4K6DKrR4/ljxn6SF6nURyu785wKMuQcjt7H3VCQ=
github.com/Shopify/logrus-bugsnag v0.0.0-20170309145241-6dbc35f2c30d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ= github.com/Shopify/logrus-bugsnag v0.0.0-20170309145241-6dbc35f2c30d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
@ -59,8 +59,8 @@ github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v26.1.1-0.20240516211257-06e3a49d66fa+incompatible h1:Zp6B3afdBCdGNGM6dxdiThsrmUIJSoBFkFLonLhiO1k= github.com/docker/docker v26.1.1-0.20240530195642-e622cea55698+incompatible h1:ri3VMs8K77n+rXEESbkIW3L2x9h0jsOoJp7Um6x1KUE=
github.com/docker/docker v26.1.1-0.20240516211257-06e3a49d66fa+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker v26.1.1-0.20240530195642-e622cea55698+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker-credential-helpers v0.8.2 h1:bX3YxiGzFP5sOXWc3bTPEXdEaZSeVMrFgOr3T+zrFAo= github.com/docker/docker-credential-helpers v0.8.2 h1:bX3YxiGzFP5sOXWc3bTPEXdEaZSeVMrFgOr3T+zrFAo=
github.com/docker/docker-credential-helpers v0.8.2/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M= github.com/docker/docker-credential-helpers v0.8.2/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M=
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0= github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0=
@ -205,8 +205,8 @@ github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoT
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
github.com/opencontainers/image-spec v1.1.0-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/cbdlwvlWt0pnFI= github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug=
github.com/opencontainers/image-spec v1.1.0-rc5/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM=
github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=

View File

@ -2179,72 +2179,129 @@ definitions:
type: "object" type: "object"
properties: properties:
Name: Name:
description: |
Name of the network.
type: "string" type: "string"
example: "my_network"
Id: Id:
description: |
ID that uniquely identifies a network on a single machine.
type: "string" type: "string"
example: "7d86d31b1478e7cca9ebed7e73aa0fdeec46c5ca29497431d3007d2d9e15ed99"
Created: Created:
description: |
Date and time at which the network was created in
[RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds.
type: "string" type: "string"
format: "dateTime" format: "dateTime"
example: "2016-10-19T04:33:30.360899459Z"
Scope: Scope:
description: |
The level at which the network exists (e.g. `swarm` for cluster-wide
or `local` for machine level)
type: "string" type: "string"
example: "local"
Driver: Driver:
description: |
The name of the driver used to create the network (e.g. `bridge`,
`overlay`).
type: "string" type: "string"
example: "overlay"
EnableIPv6: EnableIPv6:
description: |
Whether the network was created with IPv6 enabled.
type: "boolean" type: "boolean"
example: false
IPAM: IPAM:
$ref: "#/definitions/IPAM" $ref: "#/definitions/IPAM"
Internal: Internal:
description: |
Whether the network is created to only allow internal networking
connectivity.
type: "boolean" type: "boolean"
default: false
example: false
Attachable: Attachable:
description: |
Wheter a global / swarm scope network is manually attachable by regular
containers from workers in swarm mode.
type: "boolean" type: "boolean"
default: false
example: false
Ingress: Ingress:
description: |
Whether the network is providing the routing-mesh for the swarm cluster.
type: "boolean" type: "boolean"
default: false
example: false
ConfigFrom:
$ref: "#/definitions/ConfigReference"
ConfigOnly:
description: |
Whether the network is a config-only network. Config-only networks are
placeholder networks for network configurations to be used by other
networks. Config-only networks cannot be used directly to run containers
or services.
type: "boolean"
default: false
Containers: Containers:
description: |
Contains endpoints attached to the network.
type: "object" type: "object"
additionalProperties: additionalProperties:
$ref: "#/definitions/NetworkContainer" $ref: "#/definitions/NetworkContainer"
example:
19a4d5d687db25203351ed79d478946f861258f018fe384f229f2efa4b23513c:
Name: "test"
EndpointID: "628cadb8bcb92de107b2a1e516cbffe463e321f548feb37697cce00ad694f21a"
MacAddress: "02:42:ac:13:00:02"
IPv4Address: "172.19.0.2/16"
IPv6Address: ""
Options: Options:
description: |
Network-specific options uses when creating the network.
type: "object" type: "object"
additionalProperties: additionalProperties:
type: "string" type: "string"
example:
com.docker.network.bridge.default_bridge: "true"
com.docker.network.bridge.enable_icc: "true"
com.docker.network.bridge.enable_ip_masquerade: "true"
com.docker.network.bridge.host_binding_ipv4: "0.0.0.0"
com.docker.network.bridge.name: "docker0"
com.docker.network.driver.mtu: "1500"
Labels: Labels:
description: "User-defined key/value metadata."
type: "object" type: "object"
additionalProperties: additionalProperties:
type: "string" type: "string"
example: example:
Name: "net01" com.example.some-label: "some-value"
Id: "7d86d31b1478e7cca9ebed7e73aa0fdeec46c5ca29497431d3007d2d9e15ed99" com.example.some-other-label: "some-other-value"
Created: "2016-10-19T04:33:30.360899459Z" Peers:
Scope: "local" description: |
Driver: "bridge" List of peer nodes for an overlay network. This field is only present
EnableIPv6: false for overlay networks, and omitted for other network types.
IPAM: type: "array"
Driver: "default" items:
Config: $ref: "#/definitions/PeerInfo"
- Subnet: "172.19.0.0/16" x-nullable: true
Gateway: "172.19.0.1" # TODO: Add Services (only present when "verbose" is set).
Options:
foo: "bar" ConfigReference:
Internal: false description: |
Attachable: false The config-only network source to provide the configuration for
Ingress: false this network.
Containers: type: "object"
19a4d5d687db25203351ed79d478946f861258f018fe384f229f2efa4b23513c: properties:
Name: "test" Network:
EndpointID: "628cadb8bcb92de107b2a1e516cbffe463e321f548feb37697cce00ad694f21a" description: |
MacAddress: "02:42:ac:13:00:02" The name of the config-only network that provides the network's
IPv4Address: "172.19.0.2/16" configuration. The specified network must be an existing config-only
IPv6Address: "" network. Only network names are allowed, not network IDs.
Options: type: "string"
com.docker.network.bridge.default_bridge: "true" example: "config_only_network_01"
com.docker.network.bridge.enable_icc: "true"
com.docker.network.bridge.enable_ip_masquerade: "true"
com.docker.network.bridge.host_binding_ipv4: "0.0.0.0"
com.docker.network.bridge.name: "docker0"
com.docker.network.driver.mtu: "1500"
Labels:
com.example.some-label: "some-value"
com.example.some-other-label: "some-other-value"
IPAM: IPAM:
type: "object" type: "object"
properties: properties:
@ -2252,6 +2309,7 @@ definitions:
description: "Name of the IPAM driver to use." description: "Name of the IPAM driver to use."
type: "string" type: "string"
default: "default" default: "default"
example: "default"
Config: Config:
description: | description: |
List of IPAM configuration options, specified as a map: List of IPAM configuration options, specified as a map:
@ -2267,16 +2325,21 @@ definitions:
type: "object" type: "object"
additionalProperties: additionalProperties:
type: "string" type: "string"
example:
foo: "bar"
IPAMConfig: IPAMConfig:
type: "object" type: "object"
properties: properties:
Subnet: Subnet:
type: "string" type: "string"
example: "172.20.0.0/16"
IPRange: IPRange:
type: "string" type: "string"
example: "172.20.10.0/24"
Gateway: Gateway:
type: "string" type: "string"
example: "172.20.10.11"
AuxiliaryAddresses: AuxiliaryAddresses:
type: "object" type: "object"
additionalProperties: additionalProperties:
@ -2287,14 +2350,53 @@ definitions:
properties: properties:
Name: Name:
type: "string" type: "string"
example: "container_1"
EndpointID: EndpointID:
type: "string" type: "string"
example: "628cadb8bcb92de107b2a1e516cbffe463e321f548feb37697cce00ad694f21a"
MacAddress: MacAddress:
type: "string" type: "string"
example: "02:42:ac:13:00:02"
IPv4Address: IPv4Address:
type: "string" type: "string"
example: "172.19.0.2/16"
IPv6Address: IPv6Address:
type: "string" type: "string"
example: ""
PeerInfo:
description: |
PeerInfo represents one peer of an overlay network.
type: "object"
properties:
Name:
description:
ID of the peer-node in the Swarm cluster.
type: "string"
example: "6869d7c1732b"
IP:
description:
IP-address of the peer-node in the Swarm cluster.
type: "string"
example: "10.133.77.91"
NetworkCreateResponse:
description: "OK response to NetworkCreate operation"
type: "object"
title: "NetworkCreateResponse"
x-go-name: "CreateResponse"
required: [Id, Warning]
properties:
Id:
description: "The ID of the created network."
type: "string"
x-nullable: false
example: "b5c4fc71e8022147cd25de22b22173de4e3b170134117172eb595cb91b4e7e5d"
Warning:
description: "Warnings encountered when creating the container"
type: "string"
x-nullable: false
example: ""
BuildInfo: BuildInfo:
type: "object" type: "object"
@ -2495,6 +2597,17 @@ definitions:
example: example:
- "server_x" - "server_x"
- "server_y" - "server_y"
DriverOpts:
description: |
DriverOpts is a mapping of driver options and values. These options
are passed directly to the driver and are driver specific.
type: "object"
x-nullable: true
additionalProperties:
type: "string"
example:
com.example.some-label: "some-value"
com.example.some-other-label: "some-other-value"
# Operational data # Operational data
NetworkID: NetworkID:
@ -2538,17 +2651,6 @@ definitions:
type: "integer" type: "integer"
format: "int64" format: "int64"
example: 64 example: 64
DriverOpts:
description: |
DriverOpts is a mapping of driver options and values. These options
are passed directly to the driver and are driver specific.
type: "object"
x-nullable: true
additionalProperties:
type: "string"
example:
com.example.some-label: "some-value"
com.example.some-other-label: "some-other-value"
DNSNames: DNSNames:
description: | description: |
List of all DNS names an endpoint has on a specific network. This List of all DNS names an endpoint has on a specific network. This
@ -10060,19 +10162,9 @@ paths:
- "application/json" - "application/json"
responses: responses:
201: 201:
description: "No error" description: "Network created successfully"
schema: schema:
type: "object" $ref: "#/definitions/NetworkCreateResponse"
title: "NetworkCreateResponse"
properties:
Id:
description: "The ID of the created network."
type: "string"
Warning:
type: "string"
example:
Id: "22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30"
Warning: ""
400: 400:
description: "bad parameter" description: "bad parameter"
schema: schema:
@ -10104,14 +10196,22 @@ paths:
Name: Name:
description: "The network's name." description: "The network's name."
type: "string" type: "string"
example: "my_network"
CheckDuplicate: CheckDuplicate:
description: | description: |
Deprecated: CheckDuplicate is now always enabled. Deprecated: CheckDuplicate is now always enabled.
type: "boolean" type: "boolean"
example: true
Driver: Driver:
description: "Name of the network driver plugin to use." description: "Name of the network driver plugin to use."
type: "string" type: "string"
default: "bridge" default: "bridge"
example: "bridge"
Scope:
description: |
The level at which the network exists (e.g. `swarm` for cluster-wide
or `local` for machine level).
type: "string"
Internal: Internal:
description: "Restrict external access to the network." description: "Restrict external access to the network."
type: "boolean" type: "boolean"
@ -10120,55 +10220,55 @@ paths:
Globally scoped network is manually attachable by regular Globally scoped network is manually attachable by regular
containers from workers in swarm mode. containers from workers in swarm mode.
type: "boolean" type: "boolean"
example: true
Ingress: Ingress:
description: | description: |
Ingress network is the network which provides the routing-mesh Ingress network is the network which provides the routing-mesh
in swarm mode. in swarm mode.
type: "boolean" type: "boolean"
example: false
ConfigOnly:
description: |
Creates a config-only network. Config-only networks are placeholder
networks for network configurations to be used by other networks.
Config-only networks cannot be used directly to run containers
or services.
type: "boolean"
default: false
example: false
ConfigFrom:
description: |
Specifies the source which will provide the configuration for
this network. The specified network must be an existing
config-only network; see ConfigOnly.
$ref: "#/definitions/ConfigReference"
IPAM: IPAM:
description: "Optional custom IP scheme for the network." description: "Optional custom IP scheme for the network."
$ref: "#/definitions/IPAM" $ref: "#/definitions/IPAM"
EnableIPv6: EnableIPv6:
description: "Enable IPv6 on the network." description: "Enable IPv6 on the network."
type: "boolean" type: "boolean"
example: true
Options: Options:
description: "Network specific options to be used by the drivers." description: "Network specific options to be used by the drivers."
type: "object" type: "object"
additionalProperties: additionalProperties:
type: "string" type: "string"
example:
com.docker.network.bridge.default_bridge: "true"
com.docker.network.bridge.enable_icc: "true"
com.docker.network.bridge.enable_ip_masquerade: "true"
com.docker.network.bridge.host_binding_ipv4: "0.0.0.0"
com.docker.network.bridge.name: "docker0"
com.docker.network.driver.mtu: "1500"
Labels: Labels:
description: "User-defined key/value metadata." description: "User-defined key/value metadata."
type: "object" type: "object"
additionalProperties: additionalProperties:
type: "string" type: "string"
example: example:
Name: "isolated_nw" com.example.some-label: "some-value"
CheckDuplicate: false com.example.some-other-label: "some-other-value"
Driver: "bridge"
EnableIPv6: true
IPAM:
Driver: "default"
Config:
- Subnet: "172.20.0.0/16"
IPRange: "172.20.10.0/24"
Gateway: "172.20.10.11"
- Subnet: "2001:db8:abcd::/64"
Gateway: "2001:db8:abcd::1011"
Options:
foo: "bar"
Internal: true
Attachable: false
Ingress: false
Options:
com.docker.network.bridge.default_bridge: "true"
com.docker.network.bridge.enable_icc: "true"
com.docker.network.bridge.enable_ip_masquerade: "true"
com.docker.network.bridge.host_binding_ipv4: "0.0.0.0"
com.docker.network.bridge.name: "docker0"
com.docker.network.driver.mtu: "1500"
Labels:
com.example.some-label: "some-value"
com.example.some-other-label: "some-other-value"
tags: ["Network"] tags: ["Network"]
/networks/{id}/connect: /networks/{id}/connect:

View File

@ -0,0 +1,19 @@
package network
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
// CreateResponse NetworkCreateResponse
//
// OK response to NetworkCreate operation
// swagger:model CreateResponse
type CreateResponse struct {
// The ID of the created network.
// Required: true
ID string `json:"Id"`
// Warnings encountered when creating the container
// Required: true
Warning string `json:"Warning"`
}

View File

@ -18,6 +18,7 @@ type EndpointSettings struct {
// Once the container is running, it becomes operational data (it may contain a // Once the container is running, it becomes operational data (it may contain a
// generated address). // generated address).
MacAddress string MacAddress string
DriverOpts map[string]string
// Operational data // Operational data
NetworkID string NetworkID string
EndpointID string EndpointID string
@ -27,7 +28,6 @@ type EndpointSettings struct {
IPv6Gateway string IPv6Gateway string
GlobalIPv6Address string GlobalIPv6Address string
GlobalIPv6PrefixLen int GlobalIPv6PrefixLen int
DriverOpts map[string]string
// DNSNames holds all the (non fully qualified) DNS names associated to this endpoint. First entry is used to // DNSNames holds all the (non fully qualified) DNS names associated to this endpoint. First entry is used to
// generate PTR records. // generate PTR records.
DNSNames []string DNSNames []string

View File

@ -17,6 +17,26 @@ const (
NetworkNat = "nat" NetworkNat = "nat"
) )
// InspectOptions holds parameters to inspect network.
type InspectOptions struct {
Scope string
Verbose bool
}
// 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
}
// Address represents an IP address // Address represents an IP address
type Address struct { type Address struct {
Addr string Addr string
@ -45,6 +65,16 @@ type ServiceInfo struct {
Tasks []Task Tasks []Task
} }
// EndpointResource contains network resources allocated and used for a
// container in a network.
type EndpointResource struct {
Name string
EndpointID string
MacAddress string
IPv4Address string
IPv6Address string
}
// NetworkingConfig represents the container's networking configuration for each of its interfaces // NetworkingConfig represents the container's networking configuration for each of its interfaces
// Carries the networking configs specified in the `docker run` and `docker network connect` commands // Carries the networking configs specified in the `docker run` and `docker network connect` commands
type NetworkingConfig struct { type NetworkingConfig struct {

View File

@ -425,80 +425,47 @@ type MountPoint struct {
// NetworkResource is the body of the "get network" http response message // NetworkResource is the body of the "get network" http response message
type NetworkResource struct { type NetworkResource struct {
Name string // Name is the requested name of the network Name string // Name is the requested name of the network
ID string `json:"Id"` // ID uniquely identifies a network on a single machine ID string `json:"Id"` // ID uniquely identifies a network on a single machine
Created time.Time // Created is the time the network created Created time.Time // Created is the time the network created
Scope string // Scope describes the level at which the network exists (e.g. `swarm` for cluster-wide or `local` for machine level) Scope string // Scope describes the level at which the network exists (e.g. `swarm` for cluster-wide or `local` for machine level)
Driver string // Driver is the Driver name used to create the network (e.g. `bridge`, `overlay`) Driver string // Driver is the Driver name used to create the network (e.g. `bridge`, `overlay`)
EnableIPv6 bool // EnableIPv6 represents whether to enable IPv6 EnableIPv6 bool // EnableIPv6 represents whether to enable IPv6
IPAM network.IPAM // IPAM is the network's IP Address Management IPAM network.IPAM // IPAM is the network's IP Address Management
Internal bool // Internal represents if the network is used internal only 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. 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. Ingress bool // Ingress indicates the network is providing the routing-mesh for the swarm cluster.
ConfigFrom network.ConfigReference // ConfigFrom specifies the source which will provide the configuration for this network. ConfigFrom network.ConfigReference // ConfigFrom specifies the source which will provide the configuration for this network.
ConfigOnly bool // ConfigOnly 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. ConfigOnly bool // ConfigOnly 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.
Containers map[string]EndpointResource // Containers contains endpoints belonging to the network Containers map[string]network.EndpointResource // Containers contains endpoints belonging to the network
Options map[string]string // Options holds the network specific options to use for when creating the network Options map[string]string // Options holds the network specific options to use for when creating the network
Labels map[string]string // Labels holds metadata specific to the network being created Labels map[string]string // Labels holds metadata specific to the network being created
Peers []network.PeerInfo `json:",omitempty"` // List of peer nodes for an overlay network Peers []network.PeerInfo `json:",omitempty"` // List of peer nodes for an overlay network
Services map[string]network.ServiceInfo `json:",omitempty"` Services map[string]network.ServiceInfo `json:",omitempty"`
}
// EndpointResource contains network resources allocated and used for a container in a network
type EndpointResource struct {
Name string
EndpointID string
MacAddress string
IPv4Address string
IPv6Address string
} }
// NetworkCreate is the expected body of the "create network" http request message // NetworkCreate is the expected body of the "create network" http request message
type NetworkCreate struct { type NetworkCreate struct {
// Deprecated: CheckDuplicate is deprecated since API v1.44, but it defaults to true when sent by the client // Deprecated: CheckDuplicate is deprecated since API v1.44, but it defaults to true when sent by the client
// package to older daemons. // package to older daemons.
CheckDuplicate bool `json:",omitempty"` CheckDuplicate bool `json:",omitempty"`
Driver string Driver string // Driver is the driver-name used to create the network (e.g. `bridge`, `overlay`)
Scope string Scope string // Scope describes the level at which the network exists (e.g. `swarm` for cluster-wide or `local` for machine level).
EnableIPv6 bool EnableIPv6 bool // EnableIPv6 represents whether to enable IPv6.
IPAM *network.IPAM IPAM *network.IPAM // IPAM is the network's IP Address Management.
Internal bool Internal bool // Internal represents if the network is used internal only.
Attachable bool Attachable bool // Attachable represents if the global scope is manually attachable by regular containers from workers in swarm mode.
Ingress bool Ingress bool // Ingress indicates the network is providing the routing-mesh for the swarm cluster.
ConfigOnly bool 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 *network.ConfigReference // ConfigFrom specifies the source which will provide the configuration for this network. The specified network must be a config-only network; see [NetworkCreate.ConfigOnly].
Options map[string]string Options map[string]string // Options specifies the network-specific options to use for when creating the network.
Labels map[string]string Labels map[string]string // Labels holds metadata specific to the network being created.
} }
// NetworkCreateRequest is the request message sent to the server for network create call. // NetworkCreateRequest is the request message sent to the server for network create call.
type NetworkCreateRequest struct { type NetworkCreateRequest struct {
NetworkCreate NetworkCreate
Name string Name string // Name is the requested name of the network.
}
// NetworkCreateResponse is the response message sent by the server for network create call
type NetworkCreateResponse struct {
ID string `json:"Id"`
Warning string
}
// NetworkConnect represents the data to be used to connect a container to the network
type NetworkConnect struct {
Container string
EndpointConfig *network.EndpointSettings `json:",omitempty"`
}
// NetworkDisconnect represents the data to be used to disconnect a container from the network
type NetworkDisconnect struct {
Container string
Force bool
}
// NetworkInspectOptions holds parameters to inspect network
type NetworkInspectOptions struct {
Scope string
Verbose bool
} }
// DiskUsageObject represents an object type used for disk usage query filtering. // DiskUsageObject represents an object type used for disk usage query filtering.

View File

@ -2,6 +2,7 @@ package types
import ( import (
"github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/image"
"github.com/docker/docker/api/types/network"
) )
// ImageImportOptions holds information to import images from the client host. // ImageImportOptions holds information to import images from the client host.
@ -33,3 +34,28 @@ type ImageListOptions = image.ListOptions
// //
// Deprecated: use [image.RemoveOptions]. // Deprecated: use [image.RemoveOptions].
type ImageRemoveOptions = image.RemoveOptions type ImageRemoveOptions = image.RemoveOptions
// NetworkCreateResponse is the response message sent by the server for network create call.
//
// Deprecated: use [network.CreateResponse].
type NetworkCreateResponse = network.CreateResponse
// NetworkInspectOptions holds parameters to inspect network.
//
// Deprecated: use [network.InspectOptions].
type NetworkInspectOptions = network.InspectOptions
// NetworkConnect represents the data to be used to connect a container to the network
//
// Deprecated: use [network.ConnectOptions].
type NetworkConnect = network.ConnectOptions
// NetworkDisconnect represents the data to be used to disconnect a container from the network
//
// Deprecated: use [network.DisconnectOptions].
type NetworkDisconnect = network.DisconnectOptions
// EndpointResource contains network resources allocated and used for a container in a network.
//
// Deprecated: use [network.EndpointResource].
type EndpointResource = network.EndpointResource

View File

@ -108,10 +108,10 @@ type ImageAPIClient interface {
// NetworkAPIClient defines API client methods for the networks // NetworkAPIClient defines API client methods for the networks
type NetworkAPIClient interface { type NetworkAPIClient interface {
NetworkConnect(ctx context.Context, network, container string, config *network.EndpointSettings) error NetworkConnect(ctx context.Context, network, container string, config *network.EndpointSettings) error
NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error) NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (network.CreateResponse, error)
NetworkDisconnect(ctx context.Context, network, container string, force bool) error NetworkDisconnect(ctx context.Context, network, container string, force bool) error
NetworkInspect(ctx context.Context, network string, options types.NetworkInspectOptions) (types.NetworkResource, error) NetworkInspect(ctx context.Context, network string, options network.InspectOptions) (types.NetworkResource, error)
NetworkInspectWithRaw(ctx context.Context, network string, options types.NetworkInspectOptions) (types.NetworkResource, []byte, error) NetworkInspectWithRaw(ctx context.Context, network string, options network.InspectOptions) (types.NetworkResource, []byte, error)
NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error)
NetworkRemove(ctx context.Context, network string) error NetworkRemove(ctx context.Context, network string) error
NetworksPrune(ctx context.Context, pruneFilter filters.Args) (types.NetworksPruneReport, error) NetworksPrune(ctx context.Context, pruneFilter filters.Args) (types.NetworksPruneReport, error)

View File

@ -3,13 +3,12 @@ package client // import "github.com/docker/docker/client"
import ( import (
"context" "context"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
) )
// NetworkConnect connects a container to an existent network in the docker host. // NetworkConnect connects a container to an existent network in the docker host.
func (cli *Client) NetworkConnect(ctx context.Context, networkID, containerID string, config *network.EndpointSettings) error { func (cli *Client) NetworkConnect(ctx context.Context, networkID, containerID string, config *network.EndpointSettings) error {
nc := types.NetworkConnect{ nc := network.ConnectOptions{
Container: containerID, Container: containerID,
EndpointConfig: config, EndpointConfig: config,
} }

View File

@ -5,12 +5,13 @@ import (
"encoding/json" "encoding/json"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/versions" "github.com/docker/docker/api/types/versions"
) )
// NetworkCreate creates a new network in the docker host. // NetworkCreate creates a new network in the docker host.
func (cli *Client) NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error) { func (cli *Client) NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (network.CreateResponse, error) {
var response types.NetworkCreateResponse var response network.CreateResponse
// Make sure we negotiated (if the client is configured to do so), // Make sure we negotiated (if the client is configured to do so),
// as code below contains API-version specific handling of options. // as code below contains API-version specific handling of options.

View File

@ -3,12 +3,15 @@ package client // import "github.com/docker/docker/client"
import ( import (
"context" "context"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types/network"
) )
// NetworkDisconnect disconnects a container from an existent network in the docker host. // NetworkDisconnect disconnects a container from an existent network in the docker host.
func (cli *Client) NetworkDisconnect(ctx context.Context, networkID, containerID string, force bool) error { func (cli *Client) NetworkDisconnect(ctx context.Context, networkID, containerID string, force bool) error {
nd := types.NetworkDisconnect{Container: containerID, Force: force} nd := network.DisconnectOptions{
Container: containerID,
Force: force,
}
resp, err := cli.post(ctx, "/networks/"+networkID+"/disconnect", nil, nd, nil) resp, err := cli.post(ctx, "/networks/"+networkID+"/disconnect", nil, nd, nil)
ensureReaderClosed(resp) ensureReaderClosed(resp)
return err return err

View File

@ -8,16 +8,17 @@ import (
"net/url" "net/url"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/network"
) )
// NetworkInspect returns the information for a specific network configured in the docker host. // NetworkInspect returns the information for a specific network configured in the docker host.
func (cli *Client) NetworkInspect(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, error) { func (cli *Client) NetworkInspect(ctx context.Context, networkID string, options network.InspectOptions) (types.NetworkResource, error) {
networkResource, _, err := cli.NetworkInspectWithRaw(ctx, networkID, options) networkResource, _, err := cli.NetworkInspectWithRaw(ctx, networkID, options)
return networkResource, err return networkResource, err
} }
// NetworkInspectWithRaw returns the information for a specific network configured in the docker host and its raw representation. // NetworkInspectWithRaw returns the information for a specific network configured in the docker host and its raw representation.
func (cli *Client) NetworkInspectWithRaw(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, []byte, error) { func (cli *Client) NetworkInspectWithRaw(ctx context.Context, networkID string, options network.InspectOptions) (types.NetworkResource, []byte, error) {
if networkID == "" { if networkID == "" {
return types.NetworkResource{}, nil, objectNotFoundError{object: "network", id: networkID} return types.NetworkResource{}, nil, objectNotFoundError{object: "network", id: networkID}
} }

View File

@ -159,7 +159,7 @@ func magicNumberMatcher(m []byte) matcher {
// zstdMatcher detects zstd compression algorithm. // zstdMatcher detects zstd compression algorithm.
// Zstandard compressed data is made of one or more frames. // Zstandard compressed data is made of one or more frames.
// There are two frame formats defined by Zstandard: Zstandard frames and Skippable frames. // There are two frame formats defined by Zstandard: Zstandard frames and Skippable frames.
// See https://tools.ietf.org/id/draft-kucherawy-dispatch-zstd-00.html#rfc.section.2 for more details. // See https://datatracker.ietf.org/doc/html/rfc8878#section-3 for more details.
func zstdMatcher() matcher { func zstdMatcher() matcher {
return func(source []byte) bool { return func(source []byte) bool {
if bytes.HasPrefix(source, zstdMagic) { if bytes.HasPrefix(source, zstdMagic) {

View File

@ -21,12 +21,20 @@ const (
// MediaTypeLayoutHeader specifies the media type for the oci-layout. // MediaTypeLayoutHeader specifies the media type for the oci-layout.
MediaTypeLayoutHeader = "application/vnd.oci.layout.header.v1+json" MediaTypeLayoutHeader = "application/vnd.oci.layout.header.v1+json"
// MediaTypeImageManifest specifies the media type for an image manifest.
MediaTypeImageManifest = "application/vnd.oci.image.manifest.v1+json"
// MediaTypeImageIndex specifies the media type for an image index. // MediaTypeImageIndex specifies the media type for an image index.
MediaTypeImageIndex = "application/vnd.oci.image.index.v1+json" MediaTypeImageIndex = "application/vnd.oci.image.index.v1+json"
// MediaTypeImageManifest specifies the media type for an image manifest.
MediaTypeImageManifest = "application/vnd.oci.image.manifest.v1+json"
// MediaTypeImageConfig specifies the media type for the image configuration.
MediaTypeImageConfig = "application/vnd.oci.image.config.v1+json"
// MediaTypeEmptyJSON specifies the media type for an unused blob containing the value "{}".
MediaTypeEmptyJSON = "application/vnd.oci.empty.v1+json"
)
const (
// MediaTypeImageLayer is the media type used for layers referenced by the manifest. // MediaTypeImageLayer is the media type used for layers referenced by the manifest.
MediaTypeImageLayer = "application/vnd.oci.image.layer.v1.tar" MediaTypeImageLayer = "application/vnd.oci.image.layer.v1.tar"
@ -37,7 +45,15 @@ const (
// MediaTypeImageLayerZstd is the media type used for zstd compressed // MediaTypeImageLayerZstd is the media type used for zstd compressed
// layers referenced by the manifest. // layers referenced by the manifest.
MediaTypeImageLayerZstd = "application/vnd.oci.image.layer.v1.tar+zstd" MediaTypeImageLayerZstd = "application/vnd.oci.image.layer.v1.tar+zstd"
)
// Non-distributable layer media-types.
//
// Deprecated: Non-distributable layers are deprecated, and not recommended
// for future use. Implementations SHOULD NOT produce new non-distributable
// layers.
// https://github.com/opencontainers/image-spec/pull/965
const (
// MediaTypeImageLayerNonDistributable is the media type for layers referenced by // MediaTypeImageLayerNonDistributable is the media type for layers referenced by
// the manifest but with distribution restrictions. // the manifest but with distribution restrictions.
// //
@ -66,10 +82,4 @@ const (
// layers. // layers.
// https://github.com/opencontainers/image-spec/pull/965 // https://github.com/opencontainers/image-spec/pull/965
MediaTypeImageLayerNonDistributableZstd = "application/vnd.oci.image.layer.nondistributable.v1.tar+zstd" MediaTypeImageLayerNonDistributableZstd = "application/vnd.oci.image.layer.nondistributable.v1.tar+zstd"
// MediaTypeImageConfig specifies the media type for the image configuration.
MediaTypeImageConfig = "application/vnd.oci.image.config.v1+json"
// MediaTypeEmptyJSON specifies the media type for an unused blob containing the value `{}`
MediaTypeEmptyJSON = "application/vnd.oci.empty.v1+json"
) )

View File

@ -25,7 +25,7 @@ const (
VersionPatch = 0 VersionPatch = 0
// VersionDev indicates development branch. Releases will be empty string. // VersionDev indicates development branch. Releases will be empty string.
VersionDev = "-rc.5" VersionDev = ""
) )
// Version is the specification version that the package types support. // Version is the specification version that the package types support.

8
vendor/modules.txt vendored
View File

@ -12,8 +12,8 @@ github.com/Microsoft/go-winio/internal/fs
github.com/Microsoft/go-winio/internal/socket github.com/Microsoft/go-winio/internal/socket
github.com/Microsoft/go-winio/internal/stringbuffer github.com/Microsoft/go-winio/internal/stringbuffer
github.com/Microsoft/go-winio/pkg/guid github.com/Microsoft/go-winio/pkg/guid
# github.com/Microsoft/hcsshim v0.11.4 # github.com/Microsoft/hcsshim v0.11.5
## explicit; go 1.18 ## explicit; go 1.21
github.com/Microsoft/hcsshim/osversion github.com/Microsoft/hcsshim/osversion
# github.com/beorn7/perks v1.0.1 # github.com/beorn7/perks v1.0.1
## explicit; go 1.11 ## explicit; go 1.11
@ -56,7 +56,7 @@ github.com/docker/distribution/registry/client/transport
github.com/docker/distribution/registry/storage/cache github.com/docker/distribution/registry/storage/cache
github.com/docker/distribution/registry/storage/cache/memory github.com/docker/distribution/registry/storage/cache/memory
github.com/docker/distribution/uuid github.com/docker/distribution/uuid
# github.com/docker/docker v26.1.1-0.20240516211257-06e3a49d66fa+incompatible # github.com/docker/docker v26.1.1-0.20240530195642-e622cea55698+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
@ -224,7 +224,7 @@ github.com/morikuni/aec
# github.com/opencontainers/go-digest v1.0.0 # github.com/opencontainers/go-digest v1.0.0
## explicit; go 1.13 ## explicit; go 1.13
github.com/opencontainers/go-digest github.com/opencontainers/go-digest
# github.com/opencontainers/image-spec v1.1.0-rc5 # github.com/opencontainers/image-spec v1.1.0
## explicit; go 1.18 ## explicit; go 1.18
github.com/opencontainers/image-spec/specs-go github.com/opencontainers/image-spec/specs-go
github.com/opencontainers/image-spec/specs-go/v1 github.com/opencontainers/image-spec/specs-go/v1