From b6a3ce41672bd4d01e82bdcb3101fe4fab2437fa Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 4 Jun 2024 09:17:20 +0200 Subject: [PATCH] vendor: github.com/docker/docker cd3804655a25 (master / v27.0.0-dev) full diff: https://github.com/docker/docker/compare/e622cea55698e824ed6e362effe1701fd1e1552f...cd3804655a252117742a2987df15630a61ce334e Signed-off-by: Sebastiaan van Stijn --- cli/command/completion/functions.go | 21 ++++++++++--------- cli/command/network/client_test.go | 4 ++-- cli/command/network/list.go | 5 ++--- cli/command/network/list_test.go | 13 ++++++------ cli/command/stack/client_test.go | 5 +++-- cli/command/stack/swarm/client_test.go | 5 +++-- cli/command/stack/swarm/common.go | 3 ++- vendor.mod | 2 +- vendor.sum | 4 ++-- .../docker/docker/api/types/client.go | 5 ----- .../docker/api/types/network/network.go | 5 +++++ .../docker/api/types/types_deprecated.go | 5 +++++ .../docker/docker/client/interface.go | 2 +- .../docker/docker/client/network_inspect.go | 21 ++++++++----------- .../docker/docker/client/network_list.go | 3 ++- .../docker/docker/client/request.go | 8 +++---- vendor/modules.txt | 2 +- 17 files changed, 60 insertions(+), 53 deletions(-) diff --git a/cli/command/completion/functions.go b/cli/command/completion/functions.go index ae79f811fe..7cebeac921 100644 --- a/cli/command/completion/functions.go +++ b/cli/command/completion/functions.go @@ -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 } diff --git a/cli/command/network/client_test.go b/cli/command/network/client_test.go index 7bd08de773..a25738857c 100644 --- a/cli/command/network/client_test.go +++ b/cli/command/network/client_test.go @@ -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) } diff --git a/cli/command/network/list.go b/cli/command/network/list.go index 8bbc0a1002..0fb3934103 100644 --- a/cli/command/network/list.go +++ b/cli/command/network/list.go @@ -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 } diff --git a/cli/command/network/list_test.go b/cli/command/network/list_test.go index 2834aa125d..02cdafd551 100644 --- a/cli/command/network/list_test.go +++ b/cli/command/network/list_test.go @@ -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")), diff --git a/cli/command/stack/client_test.go b/cli/command/stack/client_test.go index 4cb8a3b5db..13ad22fd36 100644 --- a/cli/command/stack/client_test.go +++ b/cli/command/stack/client_test.go @@ -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) } diff --git a/cli/command/stack/swarm/client_test.go b/cli/command/stack/swarm/client_test.go index afb93458f0..b86cd356c3 100644 --- a/cli/command/stack/swarm/client_test.go +++ b/cli/command/stack/swarm/client_test.go @@ -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) } diff --git a/cli/command/stack/swarm/common.go b/cli/command/stack/swarm/common.go index a7485f2e18..12df37e9db 100644 --- a/cli/command/stack/swarm/common.go +++ b/cli/command/stack/swarm/common.go @@ -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) { diff --git a/vendor.mod b/vendor.mod index 42c17bba99..a8a3965118 100644 --- a/vendor.mod +++ b/vendor.mod @@ -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.20240530195642-e622cea55698+incompatible // master (v27.0.0-dev) + github.com/docker/docker v26.1.1-0.20240603220541-cd3804655a25+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 diff --git a/vendor.sum b/vendor.sum index d03f37a8e4..60a8dbfa6c 100644 --- a/vendor.sum +++ b/vendor.sum @@ -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.20240530195642-e622cea55698+incompatible h1:ri3VMs8K77n+rXEESbkIW3L2x9h0jsOoJp7Um6x1KUE= -github.com/docker/docker v26.1.1-0.20240530195642-e622cea55698+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v26.1.1-0.20240603220541-cd3804655a25+incompatible h1:mzBHld522snTZ7BoMQiw0RXTdraVMr380QGZzGsPRqI= +github.com/docker/docker v26.1.1-0.20240603220541-cd3804655a25+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= diff --git a/vendor/github.com/docker/docker/api/types/client.go b/vendor/github.com/docker/docker/api/types/client.go index 3c75f73c5f..7ad40f2b02 100644 --- a/vendor/github.com/docker/docker/api/types/client.go +++ b/vendor/github.com/docker/docker/api/types/client.go @@ -35,11 +35,6 @@ type EventsOptions struct { Filters filters.Args } -// NetworkListOptions holds parameters to filter the list of networks with. -type NetworkListOptions struct { - Filters filters.Args -} - // NewHijackedResponse intializes a HijackedResponse type func NewHijackedResponse(conn net.Conn, mediaType string) HijackedResponse { return HijackedResponse{Conn: conn, Reader: bufio.NewReader(conn), mediaType: mediaType} diff --git a/vendor/github.com/docker/docker/api/types/network/network.go b/vendor/github.com/docker/docker/api/types/network/network.go index dc07cdf091..7ac78cbe51 100644 --- a/vendor/github.com/docker/docker/api/types/network/network.go +++ b/vendor/github.com/docker/docker/api/types/network/network.go @@ -17,6 +17,11 @@ const ( NetworkNat = "nat" ) +// ListOptions holds parameters to filter the list of networks with. +type ListOptions struct { + Filters filters.Args +} + // InspectOptions holds parameters to inspect network. type InspectOptions struct { Scope string diff --git a/vendor/github.com/docker/docker/api/types/types_deprecated.go b/vendor/github.com/docker/docker/api/types/types_deprecated.go index 433feb820d..b336930750 100644 --- a/vendor/github.com/docker/docker/api/types/types_deprecated.go +++ b/vendor/github.com/docker/docker/api/types/types_deprecated.go @@ -35,6 +35,11 @@ type ImageListOptions = image.ListOptions // Deprecated: use [image.RemoveOptions]. type ImageRemoveOptions = image.RemoveOptions +// NetworkListOptions holds parameters to filter the list of networks with. +// +// Deprecated: use [network.ListOptions]. +type NetworkListOptions = network.ListOptions + // NetworkCreateResponse is the response message sent by the server for network create call. // // Deprecated: use [network.CreateResponse]. diff --git a/vendor/github.com/docker/docker/client/interface.go b/vendor/github.com/docker/docker/client/interface.go index 4479a287e2..fc907d444d 100644 --- a/vendor/github.com/docker/docker/client/interface.go +++ b/vendor/github.com/docker/docker/client/interface.go @@ -112,7 +112,7 @@ type NetworkAPIClient interface { NetworkDisconnect(ctx context.Context, network, container string, force bool) error NetworkInspect(ctx context.Context, network string, options network.InspectOptions) (types.NetworkResource, error) NetworkInspectWithRaw(ctx context.Context, network string, options network.InspectOptions) (types.NetworkResource, []byte, error) - NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) + NetworkList(ctx context.Context, options network.ListOptions) ([]types.NetworkResource, error) NetworkRemove(ctx context.Context, network string) error NetworksPrune(ctx context.Context, pruneFilter filters.Args) (types.NetworksPruneReport, error) } diff --git a/vendor/github.com/docker/docker/client/network_inspect.go b/vendor/github.com/docker/docker/client/network_inspect.go index 34e326aaa9..4e344cc91f 100644 --- a/vendor/github.com/docker/docker/client/network_inspect.go +++ b/vendor/github.com/docker/docker/client/network_inspect.go @@ -22,11 +22,6 @@ func (cli *Client) NetworkInspectWithRaw(ctx context.Context, networkID string, if networkID == "" { return types.NetworkResource{}, nil, objectNotFoundError{object: "network", id: networkID} } - var ( - networkResource types.NetworkResource - resp serverResponse - err error - ) query := url.Values{} if options.Verbose { query.Set("verbose", "true") @@ -34,17 +29,19 @@ func (cli *Client) NetworkInspectWithRaw(ctx context.Context, networkID string, if options.Scope != "" { query.Set("scope", options.Scope) } - resp, err = cli.get(ctx, "/networks/"+networkID, query, nil) + + resp, err := cli.get(ctx, "/networks/"+networkID, query, nil) defer ensureReaderClosed(resp) if err != nil { - return networkResource, nil, err + return types.NetworkResource{}, nil, err } - body, err := io.ReadAll(resp.body) + raw, err := io.ReadAll(resp.body) if err != nil { - return networkResource, nil, err + return types.NetworkResource{}, nil, err } - rdr := bytes.NewReader(body) - err = json.NewDecoder(rdr).Decode(&networkResource) - return networkResource, body, err + + var nw types.NetworkResource + err = json.NewDecoder(bytes.NewReader(raw)).Decode(&nw) + return nw, raw, err } diff --git a/vendor/github.com/docker/docker/client/network_list.go b/vendor/github.com/docker/docker/client/network_list.go index ed2acb5571..f7ea5c812f 100644 --- a/vendor/github.com/docker/docker/client/network_list.go +++ b/vendor/github.com/docker/docker/client/network_list.go @@ -7,10 +7,11 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/api/types/network" ) // NetworkList returns the list of networks configured in the docker host. -func (cli *Client) NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) { +func (cli *Client) NetworkList(ctx context.Context, options network.ListOptions) ([]types.NetworkResource, error) { query := url.Values{} if options.Filters.Len() > 0 { //nolint:staticcheck // ignore SA1019 for old code diff --git a/vendor/github.com/docker/docker/client/request.go b/vendor/github.com/docker/docker/client/request.go index 50e213b50a..6eea9b4e4f 100644 --- a/vendor/github.com/docker/docker/client/request.go +++ b/vendor/github.com/docker/docker/client/request.go @@ -184,10 +184,10 @@ func (cli *Client) doRequest(req *http.Request) (serverResponse, error) { // `open //./pipe/docker_engine: Le fichier spécifié est introuvable.` if strings.Contains(err.Error(), `open //./pipe/docker_engine`) { // Checks if client is running with elevated privileges - if f, elevatedErr := os.Open("\\\\.\\PHYSICALDRIVE0"); elevatedErr == nil { + if f, elevatedErr := os.Open(`\\.\PHYSICALDRIVE0`); elevatedErr != nil { err = errors.Wrap(err, "in the default daemon configuration on Windows, the docker client must be run with elevated privileges to connect") } else { - f.Close() + _ = f.Close() err = errors.Wrap(err, "this error may indicate that the docker daemon is not running") } } @@ -278,7 +278,7 @@ func encodeData(data interface{}) (*bytes.Buffer, error) { func ensureReaderClosed(response serverResponse) { if response.body != nil { // Drain up to 512 bytes and close the body to let the Transport reuse the connection - io.CopyN(io.Discard, response.body, 512) - response.body.Close() + _, _ = io.CopyN(io.Discard, response.body, 512) + _ = response.body.Close() } } diff --git a/vendor/modules.txt b/vendor/modules.txt index b1440f5952..951ed16fe4 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -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/memory github.com/docker/distribution/uuid -# github.com/docker/docker v26.1.1-0.20240530195642-e622cea55698+incompatible +# github.com/docker/docker v26.1.1-0.20240603220541-cd3804655a25+incompatible ## explicit github.com/docker/docker/api github.com/docker/docker/api/types