1
0
mirror of https://github.com/docker/cli.git synced 2026-01-13 18:22:35 +03:00

vendor: github.com/moby/moby/api, github.com/moby/moby/client master

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-08-27 16:35:41 +02:00
parent f40caed86c
commit cdf705ce66
20 changed files with 96 additions and 85 deletions

View File

@@ -32,10 +32,8 @@ func TestNewAttachCommandErrors(t *testing.T) {
expectedError: "cannot attach to a stopped container",
containerInspectFunc: func(containerID string) (container.InspectResponse, error) {
return container.InspectResponse{
ContainerJSONBase: &container.ContainerJSONBase{
State: &container.State{
Running: false,
},
State: &container.State{
Running: false,
},
}, nil
},
@@ -46,11 +44,9 @@ func TestNewAttachCommandErrors(t *testing.T) {
expectedError: "cannot attach to a paused container",
containerInspectFunc: func(containerID string) (container.InspectResponse, error) {
return container.InspectResponse{
ContainerJSONBase: &container.ContainerJSONBase{
State: &container.State{
Running: true,
Paused: true,
},
State: &container.State{
Running: true,
Paused: true,
},
}, nil
},
@@ -61,12 +57,10 @@ func TestNewAttachCommandErrors(t *testing.T) {
expectedError: "cannot attach to a restarting container",
containerInspectFunc: func(containerID string) (container.InspectResponse, error) {
return container.InspectResponse{
ContainerJSONBase: &container.ContainerJSONBase{
State: &container.State{
Running: true,
Paused: false,
Restarting: true,
},
State: &container.State{
Running: true,
Paused: false,
Restarting: true,
},
}, nil
},

View File

@@ -21,8 +21,8 @@ var logFn = func(expectedOut string) func(string, container.LogsOptions) (io.Rea
func TestRunLogs(t *testing.T) {
inspectFn := func(containerID string) (container.InspectResponse, error) {
return container.InspectResponse{
Config: &container.Config{Tty: true},
ContainerJSONBase: &container.ContainerJSONBase{State: &container.State{Running: false}},
Config: &container.Config{Tty: true},
State: &container.State{Running: false},
}, nil
}

View File

@@ -10,7 +10,7 @@ import (
type fakeClient struct {
client.Client
networkCreateFunc func(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error)
networkCreateFunc func(ctx context.Context, name string, options client.NetworkCreateOptions) (network.CreateResponse, error)
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
@@ -19,7 +19,7 @@ type fakeClient struct {
networkInspectFunc func(ctx context.Context, networkID string, options client.NetworkInspectOptions) (network.Inspect, []byte, error)
}
func (c *fakeClient) NetworkCreate(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error) {
func (c *fakeClient) NetworkCreate(ctx context.Context, name string, options client.NetworkCreateOptions) (network.CreateResponse, error) {
if c.networkCreateFunc != nil {
return c.networkCreateFunc(ctx, name, options)
}

View File

@@ -113,7 +113,7 @@ func runCreate(ctx context.Context, apiClient client.NetworkAPIClient, output io
Network: options.configFrom,
}
}
resp, err := apiClient.NetworkCreate(ctx, options.name, network.CreateOptions{
resp, err := apiClient.NetworkCreate(ctx, options.name, client.NetworkCreateOptions{
Driver: options.driver,
Options: options.driverOpts.GetAll(),
IPAM: ipamCfg,

View File

@@ -9,6 +9,7 @@ import (
"github.com/docker/cli/internal/test"
"github.com/moby/moby/api/types/network"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
)
@@ -17,7 +18,7 @@ func TestNetworkCreateErrors(t *testing.T) {
testCases := []struct {
args []string
flags map[string]string
networkCreateFunc func(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error)
networkCreateFunc func(ctx context.Context, name string, options client.NetworkCreateOptions) (network.CreateResponse, error)
expectedError string
}{
{
@@ -25,7 +26,7 @@ func TestNetworkCreateErrors(t *testing.T) {
},
{
args: []string{"toto"},
networkCreateFunc: func(ctx context.Context, name string, createBody network.CreateOptions) (network.CreateResponse, error) {
networkCreateFunc: func(ctx context.Context, name string, createBody client.NetworkCreateOptions) (network.CreateResponse, error) {
return network.CreateResponse{}, errors.New("error creating network")
},
expectedError: "error creating network",
@@ -162,7 +163,7 @@ func TestNetworkCreateWithFlags(t *testing.T) {
},
}
cli := test.NewFakeCli(&fakeClient{
networkCreateFunc: func(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error) {
networkCreateFunc: func(ctx context.Context, name string, options client.NetworkCreateOptions) (network.CreateResponse, error) {
assert.Check(t, is.Equal(expectedDriver, options.Driver), "not expected driver error")
assert.Check(t, is.DeepEqual(expectedOpts, options.IPAM.Config), "not expected driver error")
return network.CreateResponse{
@@ -220,7 +221,7 @@ func TestNetworkCreateIPv4(t *testing.T) {
for _, tc := range tests {
t.Run(tc.doc, func(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{
networkCreateFunc: func(ctx context.Context, name string, createBody network.CreateOptions) (network.CreateResponse, error) {
networkCreateFunc: func(ctx context.Context, name string, createBody client.NetworkCreateOptions) (network.CreateResponse, error) {
assert.Check(t, is.DeepEqual(createBody.EnableIPv4, tc.expected))
return network.CreateResponse{ID: name}, nil
},
@@ -274,7 +275,7 @@ func TestNetworkCreateIPv6(t *testing.T) {
for _, tc := range tests {
t.Run(tc.doc, func(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{
networkCreateFunc: func(ctx context.Context, name string, createBody network.CreateOptions) (network.CreateResponse, error) {
networkCreateFunc: func(ctx context.Context, name string, createBody client.NetworkCreateOptions) (network.CreateResponse, error) {
assert.Check(t, is.DeepEqual(tc.expected, createBody.EnableIPv6))
return network.CreateResponse{ID: name}, nil
},

View File

@@ -156,7 +156,7 @@ func createConfigs(ctx context.Context, dockerCLI command.Cli, configs []swarm.C
return nil
}
func createNetworks(ctx context.Context, dockerCLI command.Cli, namespace convert.Namespace, networks map[string]network.CreateOptions) error {
func createNetworks(ctx context.Context, dockerCLI command.Cli, namespace convert.Namespace, networks map[string]client.NetworkCreateOptions) error {
apiClient := dockerCLI.Client()
existingNetworks, err := getStackNetworks(ctx, apiClient, namespace.Name())