vendor: github.com/docker/docker c6aaabc9fc82 (master / v27.0.0-dev)

- api: move more network-related types to api/types/network

full diff: cd3804655a...c6aaabc9fc

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2024-06-05 16:28:24 +02:00
parent de4ab4bd06
commit 23148220ec
27 changed files with 133 additions and 159 deletions

View File

@ -15,9 +15,9 @@ type fakeClient struct {
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) ([]types.NetworkResource, error)
networkListFunc func(ctx context.Context, options network.ListOptions) ([]network.Summary, error)
networkPruneFunc func(ctx context.Context, pruneFilters filters.Args) (types.NetworksPruneReport, error)
networkInspectFunc func(ctx context.Context, networkID string, options network.InspectOptions) (types.NetworkResource, []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) {
@ -41,11 +41,11 @@ func (c *fakeClient) NetworkDisconnect(ctx context.Context, networkID, container
return nil
}
func (c *fakeClient) NetworkList(ctx context.Context, options network.ListOptions) ([]types.NetworkResource, error) {
func (c *fakeClient) NetworkList(ctx context.Context, options network.ListOptions) ([]network.Summary, error) {
if c.networkListFunc != nil {
return c.networkListFunc(ctx, options)
}
return []types.NetworkResource{}, nil
return []network.Inspect{}, nil
}
func (c *fakeClient) NetworkRemove(ctx context.Context, networkID string) error {
@ -55,11 +55,11 @@ func (c *fakeClient) NetworkRemove(ctx context.Context, networkID string) error
return nil
}
func (c *fakeClient) NetworkInspectWithRaw(ctx context.Context, networkID string, opts network.InspectOptions) (types.NetworkResource, []byte, error) {
func (c *fakeClient) NetworkInspectWithRaw(ctx context.Context, networkID string, opts network.InspectOptions) (network.Inspect, []byte, error) {
if c.networkInspectFunc != nil {
return c.networkInspectFunc(ctx, networkID, opts)
}
return types.NetworkResource{}, nil, nil
return network.Inspect{}, nil, nil
}
func (c *fakeClient) NetworksPrune(ctx context.Context, pruneFilter filters.Args) (types.NetworksPruneReport, error) {

View File

@ -5,7 +5,7 @@ import (
"strings"
"github.com/docker/cli/cli/command/formatter"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/pkg/stringid"
)
@ -35,10 +35,10 @@ func NewFormat(source string, quiet bool) formatter.Format {
}
// FormatWrite writes the context
func FormatWrite(ctx formatter.Context, networks []types.NetworkResource) error {
func FormatWrite(ctx formatter.Context, networks []network.Summary) error {
render := func(format func(subContext formatter.SubContext) error) error {
for _, network := range networks {
networkCtx := &networkContext{trunc: ctx.Trunc, n: network}
for _, nw := range networks {
networkCtx := &networkContext{trunc: ctx.Trunc, n: nw}
if err := format(networkCtx); err != nil {
return err
}
@ -62,7 +62,7 @@ func FormatWrite(ctx formatter.Context, networks []types.NetworkResource) error
type networkContext struct {
formatter.HeaderContext
trunc bool
n types.NetworkResource
n network.Summary
}
func (c *networkContext) MarshalJSON() ([]byte, error) {

View File

@ -13,7 +13,7 @@ import (
"github.com/docker/cli/cli/command/formatter"
"github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/pkg/stringid"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
@ -29,36 +29,36 @@ func TestNetworkContext(t *testing.T) {
call func() string
}{
{networkContext{
n: types.NetworkResource{ID: networkID},
n: network.Summary{ID: networkID},
trunc: false,
}, networkID, ctx.ID},
{networkContext{
n: types.NetworkResource{ID: networkID},
n: network.Summary{ID: networkID},
trunc: true,
}, stringid.TruncateID(networkID), ctx.ID},
{networkContext{
n: types.NetworkResource{Name: "network_name"},
n: network.Summary{Name: "network_name"},
}, "network_name", ctx.Name},
{networkContext{
n: types.NetworkResource{Driver: "driver_name"},
n: network.Summary{Driver: "driver_name"},
}, "driver_name", ctx.Driver},
{networkContext{
n: types.NetworkResource{EnableIPv6: true},
n: network.Summary{EnableIPv6: true},
}, "true", ctx.IPv6},
{networkContext{
n: types.NetworkResource{EnableIPv6: false},
n: network.Summary{EnableIPv6: false},
}, "false", ctx.IPv6},
{networkContext{
n: types.NetworkResource{Internal: true},
n: network.Summary{Internal: true},
}, "true", ctx.Internal},
{networkContext{
n: types.NetworkResource{Internal: false},
n: network.Summary{Internal: false},
}, "false", ctx.Internal},
{networkContext{
n: types.NetworkResource{},
n: network.Summary{},
}, "", ctx.Labels},
{networkContext{
n: types.NetworkResource{Labels: map[string]string{"label1": "value1", "label2": "value2"}},
n: network.Summary{Labels: map[string]string{"label1": "value1", "label2": "value2"}},
}, "label1=value1,label2=value2", ctx.Labels},
}
@ -155,7 +155,7 @@ foobar_bar 2017-01-01 00:00:00 +0000 UTC
timestamp1, _ := time.Parse("2006-01-02", "2016-01-01")
timestamp2, _ := time.Parse("2006-01-02", "2017-01-01")
networks := []types.NetworkResource{
networks := []network.Summary{
{ID: "networkID1", Name: "foobar_baz", Driver: "foo", Scope: "local", Created: timestamp1},
{ID: "networkID2", Name: "foobar_bar", Driver: "bar", Scope: "local", Created: timestamp2},
}
@ -176,7 +176,7 @@ foobar_bar 2017-01-01 00:00:00 +0000 UTC
}
func TestNetworkContextWriteJSON(t *testing.T) {
networks := []types.NetworkResource{
networks := []network.Summary{
{ID: "networkID1", Name: "foobar_baz"},
{ID: "networkID2", Name: "foobar_bar"},
}
@ -200,7 +200,7 @@ func TestNetworkContextWriteJSON(t *testing.T) {
}
func TestNetworkContextWriteJSONField(t *testing.T) {
networks := []types.NetworkResource{
networks := []network.Summary{
{ID: "networkID1", Name: "foobar_baz"},
{ID: "networkID2", Name: "foobar_bar"},
}

View File

@ -7,7 +7,6 @@ import (
"github.com/docker/cli/internal/test"
"github.com/docker/cli/internal/test/builders"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/network"
"github.com/google/go-cmp/cmp"
@ -19,12 +18,12 @@ import (
func TestNetworkListErrors(t *testing.T) {
testCases := []struct {
networkListFunc func(ctx context.Context, options network.ListOptions) ([]types.NetworkResource, error)
networkListFunc func(ctx context.Context, options network.ListOptions) ([]network.Summary, error)
expectedError string
}{
{
networkListFunc: func(ctx context.Context, options network.ListOptions) ([]types.NetworkResource, error) {
return []types.NetworkResource{}, errors.Errorf("error creating network")
networkListFunc: func(ctx context.Context, options network.ListOptions) ([]network.Summary, error) {
return []network.Summary{}, errors.Errorf("error creating network")
},
expectedError: "error creating network",
},
@ -44,7 +43,7 @@ func TestNetworkListErrors(t *testing.T) {
func TestNetworkList(t *testing.T) {
testCases := []struct {
doc string
networkListFunc func(ctx context.Context, options network.ListOptions) ([]types.NetworkResource, error)
networkListFunc func(ctx context.Context, options network.ListOptions) ([]network.Summary, error)
flags map[string]string
golden string
}{
@ -54,13 +53,13 @@ func TestNetworkList(t *testing.T) {
"filter": "image.name=ubuntu",
},
golden: "network-list.golden",
networkListFunc: func(ctx context.Context, options network.ListOptions) ([]types.NetworkResource, error) {
networkListFunc: func(ctx context.Context, options network.ListOptions) ([]network.Summary, error) {
expectedOpts := network.ListOptions{
Filters: filters.NewArgs(filters.Arg("image.name", "ubuntu")),
}
assert.Check(t, is.DeepEqual(expectedOpts, options, cmp.AllowUnexported(filters.Args{})))
return []types.NetworkResource{*builders.NetworkResource(builders.NetworkResourceID("123454321"),
return []network.Summary{*builders.NetworkResource(builders.NetworkResourceID("123454321"),
builders.NetworkResourceName("network_1"),
builders.NetworkResourceDriver("09.7.01"),
builders.NetworkResourceScope("global"))}, nil
@ -72,8 +71,8 @@ func TestNetworkList(t *testing.T) {
"format": "{{ .Name }}",
},
golden: "network-list-sort.golden",
networkListFunc: func(ctx context.Context, options network.ListOptions) ([]types.NetworkResource, error) {
return []types.NetworkResource{
networkListFunc: func(ctx context.Context, options network.ListOptions) ([]network.Summary, error) {
return []network.Summary{
*builders.NetworkResource(builders.NetworkResourceName("network-2-foo")),
*builders.NetworkResource(builders.NetworkResourceName("network-1-foo")),
*builders.NetworkResource(builders.NetworkResourceName("network-10-foo")),

View File

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