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

full diff: e622cea556...cd3804655a

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2024-06-04 09:17:20 +02:00
parent 05c7d4b319
commit b6a3ce4167
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
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) {

View File

@ -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

View File

@ -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=

View File

@ -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}

View File

@ -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

View File

@ -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].

View File

@ -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)
}

View File

@ -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
}

View File

@ -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

View File

@ -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()
}
}

2
vendor/modules.txt vendored
View File

@ -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