Skip to content

Commit

Permalink
vendor: github.com/docker/docker 59996a493cfc (v27.0.0-dev)
Browse files Browse the repository at this point in the history
full diff: moby/moby@181e70c...59996a4

Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
thaJeztah committed Jun 7, 2024
1 parent 482bf86 commit 97b7746
Show file tree
Hide file tree
Showing 19 changed files with 123 additions and 97 deletions.
11 changes: 5 additions & 6 deletions cli/command/network/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,23 @@ package network
import (
"context"

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/client"
)

type fakeClient struct {
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
networkDisconnectFunc func(ctx context.Context, networkID, container string, force bool) error
networkRemoveFunc func(ctx context.Context, networkID string) 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)
}

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 {
return c.networkCreateFunc(ctx, name, options)
}
Expand Down Expand Up @@ -62,9 +61,9 @@ func (c *fakeClient) NetworkInspectWithRaw(ctx context.Context, networkID string
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 {
return c.networkPruneFunc(ctx, pruneFilter)
}
return types.NetworksPruneReport{}, nil
return network.PruneReport{}, nil
}
3 changes: 1 addition & 2 deletions cli/command/network/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/completion"
"github.com/docker/cli/opts"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/network"
"github.com/pkg/errors"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -104,7 +103,7 @@ func runCreate(ctx context.Context, dockerCli command.Cli, options createOptions
Network: options.configFrom,
}
}
resp, err := client.NetworkCreate(ctx, options.name, types.NetworkCreate{
resp, err := client.NetworkCreate(ctx, options.name, network.CreateOptions{
Driver: options.driver,
Options: options.driverOpts.GetAll(),
IPAM: &network.IPAM{
Expand Down
13 changes: 6 additions & 7 deletions cli/command/network/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"testing"

"github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/network"
"github.com/pkg/errors"
"gotest.tools/v3/assert"
Expand All @@ -18,15 +17,15 @@ func TestNetworkCreateErrors(t *testing.T) {
testCases := []struct {
args []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: "exactly 1 argument",
},
{
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")
},
expectedError: "error creating network",
Expand Down Expand Up @@ -153,9 +152,9 @@ func TestNetworkCreateWithFlags(t *testing.T) {
},
}
cli := test.NewFakeCli(&fakeClient{
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.DeepEqual(expectedOpts, createBody.IPAM.Config), "not expected driver error")
networkCreateFunc: func(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error) {
assert.Check(t, is.Equal(expectedDriver, options.Driver), "not expected driver error")
assert.Check(t, is.DeepEqual(expectedOpts, options.IPAM.Config), "not expected driver error")
return network.CreateResponse{
ID: name,
}, nil
Expand Down Expand Up @@ -212,7 +211,7 @@ func TestNetworkCreateIPv6(t *testing.T) {
tc := tc
t.Run(tc.doc, func(t *testing.T) {
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))
return network.CreateResponse{ID: name}, nil
},
Expand Down
6 changes: 3 additions & 3 deletions cli/command/network/prune_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"testing"

"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/network"
"github.com/pkg/errors"
)

Expand All @@ -15,8 +15,8 @@ func TestNetworkPrunePromptTermination(t *testing.T) {
t.Cleanup(cancel)

cli := test.NewFakeCli(&fakeClient{
networkPruneFunc: func(ctx context.Context, pruneFilters filters.Args) (types.NetworksPruneReport, error) {
return types.NetworksPruneReport{}, errors.New("fakeClient networkPruneFunc should not be called")
networkPruneFunc: func(ctx context.Context, pruneFilters filters.Args) (network.PruneReport, error) {
return network.PruneReport{}, errors.New("fakeClient networkPruneFunc should not be called")
},
})
cmd := NewPruneCommand(cli)
Expand Down
2 changes: 1 addition & 1 deletion cli/command/stack/swarm/deploy_composefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func createConfigs(ctx context.Context, dockerCli command.Cli, configs []swarm.C
return nil
}

func createNetworks(ctx context.Context, dockerCli command.Cli, namespace convert.Namespace, networks map[string]types.NetworkCreate) error {
func createNetworks(ctx context.Context, dockerCli command.Cli, namespace convert.Namespace, networks map[string]network.CreateOptions) error {
client := dockerCli.Client()

existingNetworks, err := getStackNetworks(ctx, client, namespace.Name())
Expand Down
7 changes: 4 additions & 3 deletions cli/command/system/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/events"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/client"
)

Expand All @@ -16,7 +17,7 @@ type fakeClient struct {
serverVersion func(ctx context.Context) (types.Version, error)
eventsFn func(context.Context, types.EventsOptions) (<-chan events.Message, <-chan 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) {
Expand All @@ -38,9 +39,9 @@ func (cli *fakeClient) ContainersPrune(ctx context.Context, pruneFilters filters
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 {
return cli.networkPruneFunc(ctx, pruneFilter)
}
return types.NetworksPruneReport{}, nil
return network.PruneReport{}, nil
}
5 changes: 3 additions & 2 deletions cli/command/system/prune_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"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/network"
"github.com/pkg/errors"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
Expand Down Expand Up @@ -62,8 +63,8 @@ func TestSystemPrunePromptTermination(t *testing.T) {
containerPruneFunc: func(ctx context.Context, pruneFilters filters.Args) (types.ContainersPruneReport, error) {
return types.ContainersPruneReport{}, errors.New("fakeClient containerPruneFunc should not be called")
},
networkPruneFunc: func(ctx context.Context, pruneFilters filters.Args) (types.NetworksPruneReport, error) {
return types.NetworksPruneReport{}, errors.New("fakeClient networkPruneFunc should not be called")
networkPruneFunc: func(ctx context.Context, pruneFilters filters.Args) (network.PruneReport, error) {
return network.PruneReport{}, errors.New("fakeClient networkPruneFunc should not be called")
},
})

Expand Down
41 changes: 20 additions & 21 deletions cli/compose/convert/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import (
"strings"

composetypes "github.com/docker/cli/cli/compose/types"
"github.com/docker/docker/api/types"
networktypes "github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/swarm"
)

Expand Down Expand Up @@ -52,45 +51,45 @@ func AddStackLabel(namespace Namespace, labels map[string]string) map[string]str
type networkMap map[string]composetypes.NetworkConfig

// Networks from the compose-file type to the engine API type
func Networks(namespace Namespace, networks networkMap, servicesNetworks map[string]struct{}) (map[string]types.NetworkCreate, []string) {
func Networks(namespace Namespace, networks networkMap, servicesNetworks map[string]struct{}) (map[string]network.CreateOptions, []string) {
if networks == nil {
networks = make(map[string]composetypes.NetworkConfig)
}

externalNetworks := []string{}
result := make(map[string]types.NetworkCreate)
result := make(map[string]network.CreateOptions)
for internalName := range servicesNetworks {
network := networks[internalName]
if network.External.External {
externalNetworks = append(externalNetworks, network.Name)
nw := networks[internalName]
if nw.External.External {
externalNetworks = append(externalNetworks, nw.Name)
continue
}

createOpts := types.NetworkCreate{
Labels: AddStackLabel(namespace, network.Labels),
Driver: network.Driver,
Options: network.DriverOpts,
Internal: network.Internal,
Attachable: network.Attachable,
createOpts := network.CreateOptions{
Labels: AddStackLabel(namespace, nw.Labels),
Driver: nw.Driver,
Options: nw.DriverOpts,
Internal: nw.Internal,
Attachable: nw.Attachable,
}

if network.Ipam.Driver != "" || len(network.Ipam.Config) > 0 {
createOpts.IPAM = &networktypes.IPAM{}
if nw.Ipam.Driver != "" || len(nw.Ipam.Config) > 0 {
createOpts.IPAM = &network.IPAM{}
}

if network.Ipam.Driver != "" {
createOpts.IPAM.Driver = network.Ipam.Driver
if nw.Ipam.Driver != "" {
createOpts.IPAM.Driver = nw.Ipam.Driver
}
for _, ipamConfig := range network.Ipam.Config {
config := networktypes.IPAMConfig{
for _, ipamConfig := range nw.Ipam.Config {
config := network.IPAMConfig{
Subnet: ipamConfig.Subnet,
}
createOpts.IPAM.Config = append(createOpts.IPAM.Config, config)
}

networkName := namespace.Scope(internalName)
if network.Name != "" {
networkName = network.Name
if nw.Name != "" {
networkName = nw.Name
}
result[networkName] = createOpts
}
Expand Down
3 changes: 1 addition & 2 deletions cli/compose/convert/compose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"testing"

composetypes "github.com/docker/cli/cli/compose/types"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/network"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
Expand Down Expand Up @@ -77,7 +76,7 @@ func TestNetworks(t *testing.T) {
Name: "othername",
},
}
expected := map[string]types.NetworkCreate{
expected := map[string]network.CreateOptions{
"foo_default": {
Labels: map[string]string{
LabelNamespace: "foo",
Expand Down
2 changes: 1 addition & 1 deletion vendor.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/creack/pty v1.1.21
github.com/distribution/reference v0.5.0
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/go-connections v0.5.0
github.com/docker/go-units v0.5.0
Expand Down
4 changes: 2 additions & 2 deletions vendor.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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.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/docker v26.1.1-0.20240606182029-00f18ef7a455+incompatible h1:6OR7f7LuvJU27W400ctN0mxeAGDnPc0Fg2IGQhltKb0=
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 h1:MQR7fZxS7agfjACehtep/M6Bvz7/pFvbOcFvtTmvKlg=
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/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M=
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0=
Expand Down
21 changes: 16 additions & 5 deletions vendor/github.com/docker/docker/api/swagger.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions vendor/github.com/docker/docker/api/types/network/network.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 97b7746

Please sign in to comment.