Merge pull request #5110 from thaJeztah/bump_engine

vendor: github.com/docker/docker cd3804655a25 (master / v27.0.0-dev)
This commit is contained in:
Sebastiaan van Stijn
2024-06-04 10:34:15 +02:00
committed by GitHub
17 changed files with 60 additions and 53 deletions

View File

@ -8,6 +8,7 @@ import (
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/image"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/volume"
"github.com/spf13/cobra"
)
@ -23,8 +24,8 @@ func ImageNames(dockerCli command.Cli) ValidArgsFn {
return nil, cobra.ShellCompDirectiveError
}
var names []string
for _, image := range list {
names = append(names, image.RepoTags...)
for _, img := range list {
names = append(names, img.RepoTags...)
}
return names, cobra.ShellCompDirectiveNoFileComp
}
@ -45,10 +46,10 @@ func ContainerNames(dockerCli command.Cli, all bool, filters ...func(types.Conta
showContainerIDs := os.Getenv("DOCKER_COMPLETION_SHOW_CONTAINER_IDS") == "yes"
var names []string
for _, container := range list {
for _, ctr := range list {
skip := false
for _, fn := range filters {
if !fn(container) {
if !fn(ctr) {
skip = true
break
}
@ -57,9 +58,9 @@ func ContainerNames(dockerCli command.Cli, all bool, filters ...func(types.Conta
continue
}
if showContainerIDs {
names = append(names, container.ID)
names = append(names, ctr.ID)
}
names = append(names, formatter.StripNamePrefix(container.Names)...)
names = append(names, formatter.StripNamePrefix(ctr.Names)...)
}
return names, cobra.ShellCompDirectiveNoFileComp
}
@ -83,19 +84,19 @@ func VolumeNames(dockerCli command.Cli) ValidArgsFn {
// NetworkNames offers completion for networks
func NetworkNames(dockerCli command.Cli) ValidArgsFn {
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
list, err := dockerCli.Client().NetworkList(cmd.Context(), types.NetworkListOptions{})
list, err := dockerCli.Client().NetworkList(cmd.Context(), network.ListOptions{})
if err != nil {
return nil, cobra.ShellCompDirectiveError
}
var names []string
for _, network := range list {
names = append(names, network.Name)
for _, nw := range list {
names = append(names, nw.Name)
}
return names, cobra.ShellCompDirectiveNoFileComp
}
}
// NoComplete is used for commands where there's no relevant completion
func NoComplete(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {
func NoComplete(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
return nil, cobra.ShellCompDirectiveNoFileComp
}

View File

@ -15,7 +15,7 @@ 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 types.NetworkListOptions) ([]types.NetworkResource, error)
networkListFunc func(ctx context.Context, options network.ListOptions) ([]types.NetworkResource, 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)
}
@ -41,7 +41,7 @@ func (c *fakeClient) NetworkDisconnect(ctx context.Context, networkID, container
return nil
}
func (c *fakeClient) NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) {
func (c *fakeClient) NetworkList(ctx context.Context, options network.ListOptions) ([]types.NetworkResource, error) {
if c.networkListFunc != nil {
return c.networkListFunc(ctx, options)
}

View File

@ -10,7 +10,7 @@ import (
"github.com/docker/cli/cli/command/formatter"
flagsHelper "github.com/docker/cli/cli/flags"
"github.com/docker/cli/opts"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/network"
"github.com/fvbommel/sortorder"
"github.com/spf13/cobra"
)
@ -47,8 +47,7 @@ func newListCommand(dockerCli command.Cli) *cobra.Command {
func runList(ctx context.Context, dockerCli command.Cli, options listOptions) error {
client := dockerCli.Client()
listOptions := types.NetworkListOptions{Filters: options.filter.Value()}
networkResources, err := client.NetworkList(ctx, listOptions)
networkResources, err := client.NetworkList(ctx, network.ListOptions{Filters: options.filter.Value()})
if err != nil {
return err
}

View File

@ -9,6 +9,7 @@ import (
"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"
"github.com/pkg/errors"
"gotest.tools/v3/assert"
@ -18,11 +19,11 @@ import (
func TestNetworkListErrors(t *testing.T) {
testCases := []struct {
networkListFunc func(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error)
networkListFunc func(ctx context.Context, options network.ListOptions) ([]types.NetworkResource, error)
expectedError string
}{
{
networkListFunc: func(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) {
networkListFunc: func(ctx context.Context, options network.ListOptions) ([]types.NetworkResource, error) {
return []types.NetworkResource{}, errors.Errorf("error creating network")
},
expectedError: "error creating network",
@ -43,7 +44,7 @@ func TestNetworkListErrors(t *testing.T) {
func TestNetworkList(t *testing.T) {
testCases := []struct {
doc string
networkListFunc func(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error)
networkListFunc func(ctx context.Context, options network.ListOptions) ([]types.NetworkResource, error)
flags map[string]string
golden string
}{
@ -53,8 +54,8 @@ func TestNetworkList(t *testing.T) {
"filter": "image.name=ubuntu",
},
golden: "network-list.golden",
networkListFunc: func(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) {
expectedOpts := types.NetworkListOptions{
networkListFunc: func(ctx context.Context, options network.ListOptions) ([]types.NetworkResource, error) {
expectedOpts := network.ListOptions{
Filters: filters.NewArgs(filters.Arg("image.name", "ubuntu")),
}
assert.Check(t, is.DeepEqual(expectedOpts, options, cmp.AllowUnexported(filters.Args{})))
@ -71,7 +72,7 @@ func TestNetworkList(t *testing.T) {
"format": "{{ .Name }}",
},
golden: "network-list-sort.golden",
networkListFunc: func(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) {
networkListFunc: func(ctx context.Context, options network.ListOptions) ([]types.NetworkResource, error) {
return []types.NetworkResource{
*builders.NetworkResource(builders.NetworkResourceName("network-2-foo")),
*builders.NetworkResource(builders.NetworkResourceName("network-1-foo")),

View File

@ -8,6 +8,7 @@ import (
"github.com/docker/docker/api"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/client"
)
@ -28,7 +29,7 @@ type fakeClient struct {
removedConfigs []string
serviceListFunc func(options types.ServiceListOptions) ([]swarm.Service, error)
networkListFunc func(options types.NetworkListOptions) ([]types.NetworkResource, error)
networkListFunc func(options network.ListOptions) ([]types.NetworkResource, 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)
@ -69,7 +70,7 @@ func (cli *fakeClient) ServiceList(_ context.Context, options types.ServiceListO
return servicesList, nil
}
func (cli *fakeClient) NetworkList(_ context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) {
func (cli *fakeClient) NetworkList(_ context.Context, options network.ListOptions) ([]types.NetworkResource, error) {
if cli.networkListFunc != nil {
return cli.networkListFunc(options)
}

View File

@ -8,6 +8,7 @@ import (
"github.com/docker/docker/api"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/client"
)
@ -28,7 +29,7 @@ type fakeClient struct {
removedConfigs []string
serviceListFunc func(options types.ServiceListOptions) ([]swarm.Service, error)
networkListFunc func(options types.NetworkListOptions) ([]types.NetworkResource, error)
networkListFunc func(options network.ListOptions) ([]types.NetworkResource, 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)
@ -69,7 +70,7 @@ func (cli *fakeClient) ServiceList(_ context.Context, options types.ServiceListO
return servicesList, nil
}
func (cli *fakeClient) NetworkList(_ context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) {
func (cli *fakeClient) NetworkList(_ context.Context, options network.ListOptions) ([]types.NetworkResource, error) {
if cli.networkListFunc != nil {
return cli.networkListFunc(options)
}

View File

@ -7,6 +7,7 @@ import (
"github.com/docker/cli/opts"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/client"
)
@ -34,7 +35,7 @@ func getStackServices(ctx context.Context, apiclient client.APIClient, namespace
}
func getStackNetworks(ctx context.Context, apiclient client.APIClient, namespace string) ([]types.NetworkResource, error) {
return apiclient.NetworkList(ctx, types.NetworkListOptions{Filters: getStackFilter(namespace)})
return apiclient.NetworkList(ctx, network.ListOptions{Filters: getStackFilter(namespace)})
}
func getStackSecrets(ctx context.Context, apiclient client.APIClient, namespace string) ([]swarm.Secret, error) {