mirror of https://github.com/docker/cli.git
vendor: github.com/docker/docker 59996a493cfc (v27.0.0-dev)
full diff: 181e70cc07...59996a493c
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
482bf8613c
commit
97b7746df0
|
@ -3,7 +3,6 @@ package network
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/api/types/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
|
@ -11,16 +10,16 @@ import (
|
||||||
|
|
||||||
type fakeClient struct {
|
type fakeClient struct {
|
||||||
client.Client
|
client.Client
|
||||||
networkCreateFunc func(ctx context.Context, name string, options types.NetworkCreate) (network.CreateResponse, error)
|
networkCreateFunc func(ctx context.Context, name string, options network.CreateOptions) (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 network.ListOptions) ([]network.Summary, error)
|
networkListFunc func(ctx context.Context, options network.ListOptions) ([]network.Summary, error)
|
||||||
networkPruneFunc func(ctx context.Context, pruneFilters filters.Args) (types.NetworksPruneReport, error)
|
networkPruneFunc func(ctx context.Context, pruneFilters filters.Args) (network.PruneReport, error)
|
||||||
networkInspectFunc func(ctx context.Context, networkID string, options network.InspectOptions) (network.Inspect, []byte, error)
|
networkInspectFunc func(ctx context.Context, networkID string, options network.InspectOptions) (network.Inspect, []byte, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *fakeClient) NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (network.CreateResponse, error) {
|
func (c *fakeClient) NetworkCreate(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error) {
|
||||||
if c.networkCreateFunc != nil {
|
if c.networkCreateFunc != nil {
|
||||||
return c.networkCreateFunc(ctx, name, options)
|
return c.networkCreateFunc(ctx, name, options)
|
||||||
}
|
}
|
||||||
|
@ -62,9 +61,9 @@ func (c *fakeClient) NetworkInspectWithRaw(ctx context.Context, networkID string
|
||||||
return network.Inspect{}, nil, nil
|
return network.Inspect{}, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *fakeClient) NetworksPrune(ctx context.Context, pruneFilter filters.Args) (types.NetworksPruneReport, error) {
|
func (c *fakeClient) NetworksPrune(ctx context.Context, pruneFilter filters.Args) (network.PruneReport, error) {
|
||||||
if c.networkPruneFunc != nil {
|
if c.networkPruneFunc != nil {
|
||||||
return c.networkPruneFunc(ctx, pruneFilter)
|
return c.networkPruneFunc(ctx, pruneFilter)
|
||||||
}
|
}
|
||||||
return types.NetworksPruneReport{}, nil
|
return network.PruneReport{}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import (
|
||||||
"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/cli/opts"
|
"github.com/docker/cli/opts"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -104,7 +103,7 @@ func runCreate(ctx context.Context, dockerCli command.Cli, options createOptions
|
||||||
Network: options.configFrom,
|
Network: options.configFrom,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resp, err := client.NetworkCreate(ctx, options.name, types.NetworkCreate{
|
resp, err := client.NetworkCreate(ctx, options.name, network.CreateOptions{
|
||||||
Driver: options.driver,
|
Driver: options.driver,
|
||||||
Options: options.driverOpts.GetAll(),
|
Options: options.driverOpts.GetAll(),
|
||||||
IPAM: &network.IPAM{
|
IPAM: &network.IPAM{
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
|
@ -18,7 +17,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) (network.CreateResponse, error)
|
networkCreateFunc func(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error)
|
||||||
expectedError string
|
expectedError string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
@ -26,7 +25,7 @@ func TestNetworkCreateErrors(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
args: []string{"toto"},
|
args: []string{"toto"},
|
||||||
networkCreateFunc: func(ctx context.Context, name string, createBody types.NetworkCreate) (network.CreateResponse, error) {
|
networkCreateFunc: func(ctx context.Context, name string, createBody network.CreateOptions) (network.CreateResponse, error) {
|
||||||
return network.CreateResponse{}, errors.Errorf("error creating network")
|
return network.CreateResponse{}, errors.Errorf("error creating network")
|
||||||
},
|
},
|
||||||
expectedError: "error creating network",
|
expectedError: "error creating network",
|
||||||
|
@ -153,9 +152,9 @@ func TestNetworkCreateWithFlags(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cli := test.NewFakeCli(&fakeClient{
|
cli := test.NewFakeCli(&fakeClient{
|
||||||
networkCreateFunc: func(ctx context.Context, name string, createBody types.NetworkCreate) (network.CreateResponse, error) {
|
networkCreateFunc: func(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error) {
|
||||||
assert.Check(t, is.Equal(expectedDriver, createBody.Driver), "not expected driver error")
|
assert.Check(t, is.Equal(expectedDriver, options.Driver), "not expected driver error")
|
||||||
assert.Check(t, is.DeepEqual(expectedOpts, createBody.IPAM.Config), "not expected driver error")
|
assert.Check(t, is.DeepEqual(expectedOpts, options.IPAM.Config), "not expected driver error")
|
||||||
return network.CreateResponse{
|
return network.CreateResponse{
|
||||||
ID: name,
|
ID: name,
|
||||||
}, nil
|
}, nil
|
||||||
|
@ -212,7 +211,7 @@ func TestNetworkCreateIPv6(t *testing.T) {
|
||||||
tc := tc
|
tc := tc
|
||||||
t.Run(tc.doc, func(t *testing.T) {
|
t.Run(tc.doc, func(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{
|
cli := test.NewFakeCli(&fakeClient{
|
||||||
networkCreateFunc: func(ctx context.Context, name string, createBody types.NetworkCreate) (network.CreateResponse, error) {
|
networkCreateFunc: func(ctx context.Context, name string, createBody network.CreateOptions) (network.CreateResponse, error) {
|
||||||
assert.Check(t, is.DeepEqual(tc.expected, createBody.EnableIPv6))
|
assert.Check(t, is.DeepEqual(tc.expected, createBody.EnableIPv6))
|
||||||
return network.CreateResponse{ID: name}, nil
|
return network.CreateResponse{ID: name}, nil
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,8 +5,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
|
"github.com/docker/docker/api/types/network"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@ func TestNetworkPrunePromptTermination(t *testing.T) {
|
||||||
t.Cleanup(cancel)
|
t.Cleanup(cancel)
|
||||||
|
|
||||||
cli := test.NewFakeCli(&fakeClient{
|
cli := test.NewFakeCli(&fakeClient{
|
||||||
networkPruneFunc: func(ctx context.Context, pruneFilters filters.Args) (types.NetworksPruneReport, error) {
|
networkPruneFunc: func(ctx context.Context, pruneFilters filters.Args) (network.PruneReport, error) {
|
||||||
return types.NetworksPruneReport{}, errors.New("fakeClient networkPruneFunc should not be called")
|
return network.PruneReport{}, errors.New("fakeClient networkPruneFunc should not be called")
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
cmd := NewPruneCommand(cli)
|
cmd := NewPruneCommand(cli)
|
||||||
|
|
|
@ -157,7 +157,7 @@ func createConfigs(ctx context.Context, dockerCli command.Cli, configs []swarm.C
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func createNetworks(ctx context.Context, dockerCli command.Cli, namespace convert.Namespace, networks map[string]types.NetworkCreate) error {
|
func createNetworks(ctx context.Context, dockerCli command.Cli, namespace convert.Namespace, networks map[string]network.CreateOptions) error {
|
||||||
client := dockerCli.Client()
|
client := dockerCli.Client()
|
||||||
|
|
||||||
existingNetworks, err := getStackNetworks(ctx, client, namespace.Name())
|
existingNetworks, err := getStackNetworks(ctx, client, namespace.Name())
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/events"
|
"github.com/docker/docker/api/types/events"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
|
"github.com/docker/docker/api/types/network"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ type fakeClient struct {
|
||||||
serverVersion func(ctx context.Context) (types.Version, error)
|
serverVersion func(ctx context.Context) (types.Version, error)
|
||||||
eventsFn func(context.Context, types.EventsOptions) (<-chan events.Message, <-chan error)
|
eventsFn func(context.Context, types.EventsOptions) (<-chan events.Message, <-chan error)
|
||||||
containerPruneFunc func(ctx context.Context, pruneFilters filters.Args) (types.ContainersPruneReport, error)
|
containerPruneFunc func(ctx context.Context, pruneFilters filters.Args) (types.ContainersPruneReport, error)
|
||||||
networkPruneFunc func(ctx context.Context, pruneFilter filters.Args) (types.NetworksPruneReport, error)
|
networkPruneFunc func(ctx context.Context, pruneFilter filters.Args) (network.PruneReport, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) ServerVersion(ctx context.Context) (types.Version, error) {
|
func (cli *fakeClient) ServerVersion(ctx context.Context) (types.Version, error) {
|
||||||
|
@ -38,9 +39,9 @@ func (cli *fakeClient) ContainersPrune(ctx context.Context, pruneFilters filters
|
||||||
return types.ContainersPruneReport{}, nil
|
return types.ContainersPruneReport{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) NetworksPrune(ctx context.Context, pruneFilter filters.Args) (types.NetworksPruneReport, error) {
|
func (cli *fakeClient) NetworksPrune(ctx context.Context, pruneFilter filters.Args) (network.PruneReport, error) {
|
||||||
if cli.networkPruneFunc != nil {
|
if cli.networkPruneFunc != nil {
|
||||||
return cli.networkPruneFunc(ctx, pruneFilter)
|
return cli.networkPruneFunc(ctx, pruneFilter)
|
||||||
}
|
}
|
||||||
return types.NetworksPruneReport{}, nil
|
return network.PruneReport{}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,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/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
|
"github.com/docker/docker/api/types/network"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
is "gotest.tools/v3/assert/cmp"
|
is "gotest.tools/v3/assert/cmp"
|
||||||
|
@ -62,8 +63,8 @@ func TestSystemPrunePromptTermination(t *testing.T) {
|
||||||
containerPruneFunc: func(ctx context.Context, pruneFilters filters.Args) (types.ContainersPruneReport, error) {
|
containerPruneFunc: func(ctx context.Context, pruneFilters filters.Args) (types.ContainersPruneReport, error) {
|
||||||
return types.ContainersPruneReport{}, errors.New("fakeClient containerPruneFunc should not be called")
|
return types.ContainersPruneReport{}, errors.New("fakeClient containerPruneFunc should not be called")
|
||||||
},
|
},
|
||||||
networkPruneFunc: func(ctx context.Context, pruneFilters filters.Args) (types.NetworksPruneReport, error) {
|
networkPruneFunc: func(ctx context.Context, pruneFilters filters.Args) (network.PruneReport, error) {
|
||||||
return types.NetworksPruneReport{}, errors.New("fakeClient networkPruneFunc should not be called")
|
return network.PruneReport{}, errors.New("fakeClient networkPruneFunc should not be called")
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
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/network"
|
||||||
networktypes "github.com/docker/docker/api/types/network"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -52,45 +51,45 @@ func AddStackLabel(namespace Namespace, labels map[string]string) map[string]str
|
||||||
type networkMap map[string]composetypes.NetworkConfig
|
type networkMap map[string]composetypes.NetworkConfig
|
||||||
|
|
||||||
// Networks from the compose-file type to the engine API type
|
// Networks from the compose-file type to the engine API type
|
||||||
func Networks(namespace Namespace, networks networkMap, servicesNetworks map[string]struct{}) (map[string]types.NetworkCreate, []string) {
|
func Networks(namespace Namespace, networks networkMap, servicesNetworks map[string]struct{}) (map[string]network.CreateOptions, []string) {
|
||||||
if networks == nil {
|
if networks == nil {
|
||||||
networks = make(map[string]composetypes.NetworkConfig)
|
networks = make(map[string]composetypes.NetworkConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
externalNetworks := []string{}
|
externalNetworks := []string{}
|
||||||
result := make(map[string]types.NetworkCreate)
|
result := make(map[string]network.CreateOptions)
|
||||||
for internalName := range servicesNetworks {
|
for internalName := range servicesNetworks {
|
||||||
network := networks[internalName]
|
nw := networks[internalName]
|
||||||
if network.External.External {
|
if nw.External.External {
|
||||||
externalNetworks = append(externalNetworks, network.Name)
|
externalNetworks = append(externalNetworks, nw.Name)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
createOpts := types.NetworkCreate{
|
createOpts := network.CreateOptions{
|
||||||
Labels: AddStackLabel(namespace, network.Labels),
|
Labels: AddStackLabel(namespace, nw.Labels),
|
||||||
Driver: network.Driver,
|
Driver: nw.Driver,
|
||||||
Options: network.DriverOpts,
|
Options: nw.DriverOpts,
|
||||||
Internal: network.Internal,
|
Internal: nw.Internal,
|
||||||
Attachable: network.Attachable,
|
Attachable: nw.Attachable,
|
||||||
}
|
}
|
||||||
|
|
||||||
if network.Ipam.Driver != "" || len(network.Ipam.Config) > 0 {
|
if nw.Ipam.Driver != "" || len(nw.Ipam.Config) > 0 {
|
||||||
createOpts.IPAM = &networktypes.IPAM{}
|
createOpts.IPAM = &network.IPAM{}
|
||||||
}
|
}
|
||||||
|
|
||||||
if network.Ipam.Driver != "" {
|
if nw.Ipam.Driver != "" {
|
||||||
createOpts.IPAM.Driver = network.Ipam.Driver
|
createOpts.IPAM.Driver = nw.Ipam.Driver
|
||||||
}
|
}
|
||||||
for _, ipamConfig := range network.Ipam.Config {
|
for _, ipamConfig := range nw.Ipam.Config {
|
||||||
config := networktypes.IPAMConfig{
|
config := network.IPAMConfig{
|
||||||
Subnet: ipamConfig.Subnet,
|
Subnet: ipamConfig.Subnet,
|
||||||
}
|
}
|
||||||
createOpts.IPAM.Config = append(createOpts.IPAM.Config, config)
|
createOpts.IPAM.Config = append(createOpts.IPAM.Config, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
networkName := namespace.Scope(internalName)
|
networkName := namespace.Scope(internalName)
|
||||||
if network.Name != "" {
|
if nw.Name != "" {
|
||||||
networkName = network.Name
|
networkName = nw.Name
|
||||||
}
|
}
|
||||||
result[networkName] = createOpts
|
result[networkName] = createOpts
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
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/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
is "gotest.tools/v3/assert/cmp"
|
is "gotest.tools/v3/assert/cmp"
|
||||||
|
@ -77,7 +76,7 @@ func TestNetworks(t *testing.T) {
|
||||||
Name: "othername",
|
Name: "othername",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
expected := map[string]types.NetworkCreate{
|
expected := map[string]network.CreateOptions{
|
||||||
"foo_default": {
|
"foo_default": {
|
||||||
Labels: map[string]string{
|
Labels: map[string]string{
|
||||||
LabelNamespace: "foo",
|
LabelNamespace: "foo",
|
||||||
|
|
|
@ -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.20240606182029-00f18ef7a455+incompatible // master (v27.0.0-dev)
|
github.com/docker/docker v26.1.1-0.20240607121412-59996a493cfc+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
|
||||||
|
|
|
@ -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.20240606182029-00f18ef7a455+incompatible h1:6OR7f7LuvJU27W400ctN0mxeAGDnPc0Fg2IGQhltKb0=
|
github.com/docker/docker v26.1.1-0.20240607121412-59996a493cfc+incompatible h1:MQR7fZxS7agfjACehtep/M6Bvz7/pFvbOcFvtTmvKlg=
|
||||||
github.com/docker/docker v26.1.1-0.20240606182029-00f18ef7a455+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
github.com/docker/docker v26.1.1-0.20240607121412-59996a493cfc+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=
|
||||||
|
|
|
@ -4741,6 +4741,12 @@ definitions:
|
||||||
properties:
|
properties:
|
||||||
NetworkMode:
|
NetworkMode:
|
||||||
type: "string"
|
type: "string"
|
||||||
|
Annotations:
|
||||||
|
description: "Arbitrary key-value metadata attached to container"
|
||||||
|
type: "object"
|
||||||
|
x-nullable: true
|
||||||
|
additionalProperties:
|
||||||
|
type: "string"
|
||||||
NetworkSettings:
|
NetworkSettings:
|
||||||
description: "A summary of the container's network settings"
|
description: "A summary of the container's network settings"
|
||||||
type: "object"
|
type: "object"
|
||||||
|
@ -6390,6 +6396,8 @@ paths:
|
||||||
SizeRootFs: 0
|
SizeRootFs: 0
|
||||||
HostConfig:
|
HostConfig:
|
||||||
NetworkMode: "default"
|
NetworkMode: "default"
|
||||||
|
Annotations:
|
||||||
|
io.kubernetes.docker.type: "container"
|
||||||
NetworkSettings:
|
NetworkSettings:
|
||||||
Networks:
|
Networks:
|
||||||
bridge:
|
bridge:
|
||||||
|
@ -6425,6 +6433,9 @@ paths:
|
||||||
SizeRootFs: 0
|
SizeRootFs: 0
|
||||||
HostConfig:
|
HostConfig:
|
||||||
NetworkMode: "default"
|
NetworkMode: "default"
|
||||||
|
Annotations:
|
||||||
|
io.kubernetes.docker.type: "container"
|
||||||
|
io.kubernetes.sandbox.id: "3befe639bed0fd6afdd65fd1fa84506756f59360ec4adc270b0fdac9be22b4d3"
|
||||||
NetworkSettings:
|
NetworkSettings:
|
||||||
Networks:
|
Networks:
|
||||||
bridge:
|
bridge:
|
||||||
|
@ -6453,6 +6464,9 @@ paths:
|
||||||
SizeRootFs: 0
|
SizeRootFs: 0
|
||||||
HostConfig:
|
HostConfig:
|
||||||
NetworkMode: "default"
|
NetworkMode: "default"
|
||||||
|
Annotations:
|
||||||
|
io.kubernetes.image.id: "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82"
|
||||||
|
io.kubernetes.image.name: "ubuntu:latest"
|
||||||
NetworkSettings:
|
NetworkSettings:
|
||||||
Networks:
|
Networks:
|
||||||
bridge:
|
bridge:
|
||||||
|
@ -6481,6 +6495,8 @@ paths:
|
||||||
SizeRootFs: 0
|
SizeRootFs: 0
|
||||||
HostConfig:
|
HostConfig:
|
||||||
NetworkMode: "default"
|
NetworkMode: "default"
|
||||||
|
Annotations:
|
||||||
|
io.kubernetes.config.source: "api"
|
||||||
NetworkSettings:
|
NetworkSettings:
|
||||||
Networks:
|
Networks:
|
||||||
bridge:
|
bridge:
|
||||||
|
@ -10197,11 +10213,6 @@ paths:
|
||||||
description: "The network's name."
|
description: "The network's name."
|
||||||
type: "string"
|
type: "string"
|
||||||
example: "my_network"
|
example: "my_network"
|
||||||
CheckDuplicate:
|
|
||||||
description: |
|
|
||||||
Deprecated: CheckDuplicate is now always enabled.
|
|
||||||
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"
|
||||||
|
|
|
@ -19,6 +19,31 @@ const (
|
||||||
NetworkNat = "nat"
|
NetworkNat = "nat"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 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 {
|
||||||
|
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).
|
||||||
|
EnableIPv6 *bool `json:",omitempty"` // EnableIPv6 represents whether to enable IPv6.
|
||||||
|
IPAM *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 *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.
|
||||||
|
}
|
||||||
|
|
||||||
// ListOptions holds parameters to filter the list of networks with.
|
// ListOptions holds parameters to filter the list of networks with.
|
||||||
type ListOptions struct {
|
type ListOptions struct {
|
||||||
Filters filters.Args
|
Filters filters.Args
|
||||||
|
@ -133,3 +158,9 @@ var acceptedFilters = map[string]bool{
|
||||||
func ValidateFilters(filter filters.Args) error {
|
func ValidateFilters(filter filters.Args) error {
|
||||||
return filter.Validate(acceptedFilters)
|
return filter.Validate(acceptedFilters)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PruneReport contains the response for Engine API:
|
||||||
|
// POST "/networks/prune"
|
||||||
|
type PruneReport struct {
|
||||||
|
NetworksDeleted []string
|
||||||
|
}
|
||||||
|
|
|
@ -155,7 +155,8 @@ type Container struct {
|
||||||
State string
|
State string
|
||||||
Status string
|
Status string
|
||||||
HostConfig struct {
|
HostConfig struct {
|
||||||
NetworkMode string `json:",omitempty"`
|
NetworkMode string `json:",omitempty"`
|
||||||
|
Annotations map[string]string `json:",omitempty"`
|
||||||
}
|
}
|
||||||
NetworkSettings *SummaryNetworkSettings
|
NetworkSettings *SummaryNetworkSettings
|
||||||
Mounts []MountPoint
|
Mounts []MountPoint
|
||||||
|
@ -423,30 +424,6 @@ type MountPoint struct {
|
||||||
Propagation mount.Propagation
|
Propagation mount.Propagation
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetworkCreate is the expected body of the "create network" http request message
|
|
||||||
type NetworkCreate struct {
|
|
||||||
// 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"`
|
|
||||||
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).
|
|
||||||
EnableIPv6 *bool `json:",omitempty"` // 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 [NetworkCreate.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.
|
|
||||||
}
|
|
||||||
|
|
||||||
// NetworkCreateRequest is the request message sent to the server for network create call.
|
|
||||||
type NetworkCreateRequest struct {
|
|
||||||
NetworkCreate
|
|
||||||
Name string // Name is the requested name of the network.
|
|
||||||
}
|
|
||||||
|
|
||||||
// DiskUsageObject represents an object type used for disk usage query filtering.
|
// DiskUsageObject represents an object type used for disk usage query filtering.
|
||||||
type DiskUsageObject string
|
type DiskUsageObject string
|
||||||
|
|
||||||
|
@ -507,12 +484,6 @@ type BuildCachePruneReport struct {
|
||||||
SpaceReclaimed uint64
|
SpaceReclaimed uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetworksPruneReport contains the response for Engine API:
|
|
||||||
// POST "/networks/prune"
|
|
||||||
type NetworksPruneReport struct {
|
|
||||||
NetworksDeleted []string
|
|
||||||
}
|
|
||||||
|
|
||||||
// SecretCreateResponse contains the information returned to a client
|
// SecretCreateResponse contains the information returned to a client
|
||||||
// on the creation of a new secret.
|
// on the creation of a new secret.
|
||||||
type SecretCreateResponse struct {
|
type SecretCreateResponse struct {
|
||||||
|
|
|
@ -4,6 +4,16 @@ import (
|
||||||
"github.com/docker/docker/api/types/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// NetworkCreateRequest is the request message sent to the server for network create call.
|
||||||
|
//
|
||||||
|
// Deprecated: use [network.CreateRequest].
|
||||||
|
type NetworkCreateRequest = network.CreateRequest
|
||||||
|
|
||||||
|
// NetworkCreate is the expected body of the "create network" http request message
|
||||||
|
//
|
||||||
|
// Deprecated: use [network.CreateOptions].
|
||||||
|
type NetworkCreate = network.CreateOptions
|
||||||
|
|
||||||
// NetworkListOptions holds parameters to filter the list of networks with.
|
// NetworkListOptions holds parameters to filter the list of networks with.
|
||||||
//
|
//
|
||||||
// Deprecated: use [network.ListOptions].
|
// Deprecated: use [network.ListOptions].
|
||||||
|
@ -38,3 +48,9 @@ type EndpointResource = network.EndpointResource
|
||||||
//
|
//
|
||||||
// Deprecated: use [network.Inspect] or [network.Summary] (for list operations).
|
// Deprecated: use [network.Inspect] or [network.Summary] (for list operations).
|
||||||
type NetworkResource = network.Inspect
|
type NetworkResource = network.Inspect
|
||||||
|
|
||||||
|
// NetworksPruneReport contains the response for Engine API:
|
||||||
|
// POST "/networks/prune"
|
||||||
|
//
|
||||||
|
// Deprecated: use [network.PruneReport].
|
||||||
|
type NetworksPruneReport = network.PruneReport
|
||||||
|
|
|
@ -108,13 +108,13 @@ 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) (network.CreateResponse, error)
|
NetworkCreate(ctx context.Context, name string, options network.CreateOptions) (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 network.InspectOptions) (network.Inspect, error)
|
NetworkInspect(ctx context.Context, network string, options network.InspectOptions) (network.Inspect, error)
|
||||||
NetworkInspectWithRaw(ctx context.Context, network string, options network.InspectOptions) (network.Inspect, []byte, error)
|
NetworkInspectWithRaw(ctx context.Context, network string, options network.InspectOptions) (network.Inspect, []byte, error)
|
||||||
NetworkList(ctx context.Context, options network.ListOptions) ([]network.Summary, error)
|
NetworkList(ctx context.Context, options network.ListOptions) ([]network.Summary, 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) (network.PruneReport, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NodeAPIClient defines API client methods for the nodes
|
// NodeAPIClient defines API client methods for the nodes
|
||||||
|
|
|
@ -4,13 +4,12 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/network"
|
"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) (network.CreateResponse, error) {
|
func (cli *Client) NetworkCreate(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error) {
|
||||||
var response network.CreateResponse
|
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),
|
||||||
|
@ -22,12 +21,13 @@ func (cli *Client) NetworkCreate(ctx context.Context, name string, options types
|
||||||
return response, err
|
return response, err
|
||||||
}
|
}
|
||||||
|
|
||||||
networkCreateRequest := types.NetworkCreateRequest{
|
networkCreateRequest := network.CreateRequest{
|
||||||
NetworkCreate: options,
|
CreateOptions: options,
|
||||||
Name: name,
|
Name: name,
|
||||||
}
|
}
|
||||||
if versions.LessThan(cli.version, "1.44") {
|
if versions.LessThan(cli.version, "1.44") {
|
||||||
networkCreateRequest.CheckDuplicate = true //nolint:staticcheck // ignore SA1019: CheckDuplicate is deprecated since API v1.44.
|
enabled := true
|
||||||
|
networkCreateRequest.CheckDuplicate = &enabled //nolint:staticcheck // ignore SA1019: CheckDuplicate is deprecated since API v1.44.
|
||||||
}
|
}
|
||||||
|
|
||||||
serverResp, err := cli.post(ctx, "/networks/create", nil, networkCreateRequest, nil)
|
serverResp, err := cli.post(ctx, "/networks/create", nil, networkCreateRequest, nil)
|
||||||
|
|
|
@ -5,13 +5,13 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
|
"github.com/docker/docker/api/types/network"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NetworksPrune requests the daemon to delete unused networks
|
// NetworksPrune requests the daemon to delete unused networks
|
||||||
func (cli *Client) NetworksPrune(ctx context.Context, pruneFilters filters.Args) (types.NetworksPruneReport, error) {
|
func (cli *Client) NetworksPrune(ctx context.Context, pruneFilters filters.Args) (network.PruneReport, error) {
|
||||||
var report types.NetworksPruneReport
|
var report network.PruneReport
|
||||||
|
|
||||||
if err := cli.NewVersionError(ctx, "1.25", "network prune"); err != nil {
|
if err := cli.NewVersionError(ctx, "1.25", "network prune"); err != nil {
|
||||||
return report, err
|
return report, err
|
||||||
|
|
|
@ -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.20240606182029-00f18ef7a455+incompatible
|
# github.com/docker/docker v26.1.1-0.20240607121412-59996a493cfc+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
|
||||||
|
|
Loading…
Reference in New Issue