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

@ -29,7 +29,7 @@ type fakeClient struct {
removedConfigs []string
serviceListFunc func(options types.ServiceListOptions) ([]swarm.Service, error)
networkListFunc func(options network.ListOptions) ([]types.NetworkResource, error)
networkListFunc func(options network.ListOptions) ([]network.Summary, error)
secretListFunc func(options types.SecretListOptions) ([]swarm.Secret, error)
configListFunc func(options types.ConfigListOptions) ([]swarm.Config, error)
nodeListFunc func(options types.NodeListOptions) ([]swarm.Node, error)
@ -70,13 +70,13 @@ func (cli *fakeClient) ServiceList(_ context.Context, options types.ServiceListO
return servicesList, nil
}
func (cli *fakeClient) NetworkList(_ context.Context, options network.ListOptions) ([]types.NetworkResource, error) {
func (cli *fakeClient) NetworkList(_ context.Context, options network.ListOptions) ([]network.Summary, error) {
if cli.networkListFunc != nil {
return cli.networkListFunc(options)
}
namespace := namespaceFromFilters(options.Filters)
networksList := []types.NetworkResource{}
networksList := []network.Summary{}
for _, name := range cli.networks {
if belongToNamespace(name, namespace) {
networksList = append(networksList, networkFromName(name))
@ -200,8 +200,8 @@ func serviceFromName(name string) swarm.Service {
}
}
func networkFromName(name string) types.NetworkResource {
return types.NetworkResource{
func networkFromName(name string) network.Summary {
return network.Summary{
ID: "ID-" + name,
Name: name,
}

View File

@ -29,7 +29,7 @@ type fakeClient struct {
removedConfigs []string
serviceListFunc func(options types.ServiceListOptions) ([]swarm.Service, error)
networkListFunc func(options network.ListOptions) ([]types.NetworkResource, error)
networkListFunc func(options network.ListOptions) ([]network.Summary, error)
secretListFunc func(options types.SecretListOptions) ([]swarm.Secret, error)
configListFunc func(options types.ConfigListOptions) ([]swarm.Config, error)
nodeListFunc func(options types.NodeListOptions) ([]swarm.Node, error)
@ -70,13 +70,13 @@ func (cli *fakeClient) ServiceList(_ context.Context, options types.ServiceListO
return servicesList, nil
}
func (cli *fakeClient) NetworkList(_ context.Context, options network.ListOptions) ([]types.NetworkResource, error) {
func (cli *fakeClient) NetworkList(_ context.Context, options network.ListOptions) ([]network.Summary, error) {
if cli.networkListFunc != nil {
return cli.networkListFunc(options)
}
namespace := namespaceFromFilters(options.Filters)
networksList := []types.NetworkResource{}
networksList := []network.Summary{}
for _, name := range cli.networks {
if belongToNamespace(name, namespace) {
networksList = append(networksList, networkFromName(name))
@ -189,8 +189,8 @@ func serviceFromName(name string) swarm.Service {
}
}
func networkFromName(name string) types.NetworkResource {
return types.NetworkResource{
func networkFromName(name string) network.Summary {
return network.Summary{
ID: "ID-" + name,
Name: name,
}

View File

@ -34,7 +34,7 @@ func getStackServices(ctx context.Context, apiclient client.APIClient, namespace
return apiclient.ServiceList(ctx, types.ServiceListOptions{Filters: getStackFilter(namespace)})
}
func getStackNetworks(ctx context.Context, apiclient client.APIClient, namespace string) ([]types.NetworkResource, error) {
func getStackNetworks(ctx context.Context, apiclient client.APIClient, namespace string) ([]network.Summary, error) {
return apiclient.NetworkList(ctx, network.ListOptions{Filters: getStackFilter(namespace)})
}

View File

@ -165,7 +165,7 @@ func createNetworks(ctx context.Context, dockerCli command.Cli, namespace conver
return err
}
existingNetworkMap := make(map[string]types.NetworkResource)
existingNetworkMap := make(map[string]network.Summary)
for _, nw := range existingNetworks {
existingNetworkMap[nw.Name] = nw
}

View File

@ -5,7 +5,6 @@ import (
"testing"
"github.com/docker/cli/internal/test/network"
"github.com/docker/docker/api/types"
networktypes "github.com/docker/docker/api/types/network"
"github.com/pkg/errors"
"gotest.tools/v3/assert"
@ -19,7 +18,7 @@ func (n notFound) NotFound() {}
func TestValidateExternalNetworks(t *testing.T) {
testcases := []struct {
inspectResponse types.NetworkResource
inspectResponse networktypes.Inspect
inspectError error
expectedMsg string
network string
@ -45,13 +44,13 @@ func TestValidateExternalNetworks(t *testing.T) {
},
{
network: "user",
inspectResponse: types.NetworkResource{Scope: "swarm"},
inspectResponse: networktypes.Inspect{Scope: "swarm"},
},
}
for _, testcase := range testcases {
fakeClient := &network.FakeClient{
NetworkInspectFunc: func(_ context.Context, _ string, _ networktypes.InspectOptions) (types.NetworkResource, error) {
NetworkInspectFunc: func(_ context.Context, _ string, _ networktypes.InspectOptions) (networktypes.Inspect, error) {
return testcase.inspectResponse, testcase.inspectError
},
}

View File

@ -8,7 +8,7 @@ import (
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/stack/options"
"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/versions"
apiclient "github.com/docker/docker/client"
@ -102,14 +102,14 @@ func removeServices(
func removeNetworks(
ctx context.Context,
dockerCli command.Cli,
networks []types.NetworkResource,
networks []network.Summary,
) bool {
var hasError bool
for _, network := range networks {
fmt.Fprintf(dockerCli.Out(), "Removing network %s\n", network.Name)
if err := dockerCli.Client().NetworkRemove(ctx, network.ID); err != nil {
for _, nw := range networks {
fmt.Fprintf(dockerCli.Out(), "Removing network %s\n", nw.Name)
if err := dockerCli.Client().NetworkRemove(ctx, nw.ID); err != nil {
hasError = true
fmt.Fprintf(dockerCli.Err(), "Failed to remove network %s: %s", network.ID, err)
fmt.Fprintf(dockerCli.Err(), "Failed to remove network %s: %s", nw.ID, err)
}
}
return hasError