Skip to content

Commit 7bce33e

Browse files
committed
api/types: move ContainerStartOptions to api/types/container
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 0f77875 commit 7bce33e

23 files changed

Lines changed: 60 additions & 64 deletions

api/types/client.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ type ContainerLogsOptions struct {
4343
Details bool
4444
}
4545

46-
// ContainerStartOptions holds parameters to start containers.
47-
type ContainerStartOptions struct {
48-
CheckpointID string
49-
CheckpointDir string
50-
}
51-
5246
// CopyToContainerOptions holds information
5347
// about files to copy into a container
5448
type CopyToContainerOptions struct {

api/types/container/options.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,9 @@ type RemoveOptions struct {
3434
RemoveLinks bool
3535
Force bool
3636
}
37+
38+
// StartOptions holds parameters to start containers.
39+
type StartOptions struct {
40+
CheckpointID string
41+
CheckpointDir string
42+
}

api/types/types_deprecated.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ type ServiceCreateResponse = swarm.ServiceCreateResponse
9292
// Deprecated: use [swarm.ServiceUpdateResponse].
9393
type ServiceUpdateResponse = swarm.ServiceUpdateResponse
9494

95+
// ContainerStartOptions holds parameters to start containers.
96+
//
97+
// Deprecated: use [container.StartOptions].
98+
type ContainerStartOptions = container.StartOptions
99+
95100
// ResizeOptions holds parameters to resize a TTY.
96101
// It can be used to resize container TTYs and
97102
// exec process TTYs too.

client/container_start.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import (
44
"context"
55
"net/url"
66

7-
"github.com/docker/docker/api/types"
7+
"github.com/docker/docker/api/types/container"
88
)
99

1010
// ContainerStart sends a request to the docker daemon to start a container.
11-
func (cli *Client) ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error {
11+
func (cli *Client) ContainerStart(ctx context.Context, containerID string, options container.StartOptions) error {
1212
query := url.Values{}
1313
if len(options.CheckpointID) != 0 {
1414
query.Set("checkpoint", options.CheckpointID)

client/container_start_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"strings"
1111
"testing"
1212

13-
"github.com/docker/docker/api/types"
13+
"github.com/docker/docker/api/types/container"
1414
"github.com/docker/docker/errdefs"
1515
"gotest.tools/v3/assert"
1616
is "gotest.tools/v3/assert/cmp"
@@ -20,7 +20,7 @@ func TestContainerStartError(t *testing.T) {
2020
client := &Client{
2121
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
2222
}
23-
err := client.ContainerStart(context.Background(), "nothing", types.ContainerStartOptions{})
23+
err := client.ContainerStart(context.Background(), "nothing", container.StartOptions{})
2424
assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
2525
}
2626

@@ -51,7 +51,7 @@ func TestContainerStart(t *testing.T) {
5151
}),
5252
}
5353

54-
err := client.ContainerStart(context.Background(), "container_id", types.ContainerStartOptions{CheckpointID: "checkpoint_id"})
54+
err := client.ContainerStart(context.Background(), "container_id", container.StartOptions{CheckpointID: "checkpoint_id"})
5555
if err != nil {
5656
t.Fatal(err)
5757
}

client/interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ type ContainerAPIClient interface {
6969
ContainerStatPath(ctx context.Context, container, path string) (types.ContainerPathStat, error)
7070
ContainerStats(ctx context.Context, container string, stream bool) (types.ContainerStats, error)
7171
ContainerStatsOneShot(ctx context.Context, container string) (types.ContainerStats, error)
72-
ContainerStart(ctx context.Context, container string, options types.ContainerStartOptions) error
72+
ContainerStart(ctx context.Context, container string, options container.StartOptions) error
7373
ContainerStop(ctx context.Context, container string, options container.StopOptions) error
7474
ContainerTop(ctx context.Context, container string, arguments []string) (container.ContainerTopOKBody, error)
7575
ContainerUnpause(ctx context.Context, container string) error

integration-cli/docker_api_containers_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -924,12 +924,12 @@ func (s *DockerAPISuite) TestContainerAPIStart(c *testing.T) {
924924
_, err = apiClient.ContainerCreate(testutil.GetContext(c), &config, &container.HostConfig{}, &network.NetworkingConfig{}, nil, name)
925925
assert.NilError(c, err)
926926

927-
err = apiClient.ContainerStart(testutil.GetContext(c), name, types.ContainerStartOptions{})
927+
err = apiClient.ContainerStart(testutil.GetContext(c), name, container.StartOptions{})
928928
assert.NilError(c, err)
929929

930930
// second call to start should give 304
931931
// maybe add ContainerStartWithRaw to test it
932-
err = apiClient.ContainerStart(testutil.GetContext(c), name, types.ContainerStartOptions{})
932+
err = apiClient.ContainerStart(testutil.GetContext(c), name, container.StartOptions{})
933933
assert.NilError(c, err)
934934

935935
// TODO(tibor): figure out why this doesn't work on windows
@@ -1572,7 +1572,7 @@ func (s *DockerAPISuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T)
15721572
_, err = apiClient.ContainerCreate(testutil.GetContext(c), &config, &container.HostConfig{}, &network.NetworkingConfig{}, nil, name)
15731573
assert.NilError(c, err)
15741574

1575-
err = apiClient.ContainerStart(testutil.GetContext(c), name, types.ContainerStartOptions{})
1575+
err = apiClient.ContainerStart(testutil.GetContext(c), name, container.StartOptions{})
15761576
assert.NilError(c, err)
15771577

15781578
assert.Assert(c, waitRun(name) == nil)
@@ -2112,7 +2112,7 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsCreate(c *testing.T) {
21122112
assert.Check(c, is.Equal(x.expected.Mode, mountPoint.Mode))
21132113
assert.Check(c, is.Equal(x.expected.Destination, mountPoint.Destination))
21142114

2115-
err = apiclient.ContainerStart(ctx, ctr.ID, types.ContainerStartOptions{})
2115+
err = apiclient.ContainerStart(ctx, ctr.ID, container.StartOptions{})
21162116
assert.NilError(c, err)
21172117
poll.WaitOn(c, containerExit(ctx, apiclient, ctr.ID), poll.WithDelay(time.Second))
21182118

integration-cli/docker_api_containers_windows_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"testing"
1111

1212
winio "github.com/Microsoft/go-winio"
13-
"github.com/docker/docker/api/types"
1413
"github.com/docker/docker/api/types/container"
1514
"github.com/docker/docker/api/types/mount"
1615
"github.com/docker/docker/testutil"
@@ -66,7 +65,7 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsBindNamedPipe(c *testing.T
6665
nil, nil, name)
6766
assert.NilError(c, err)
6867

69-
err = client.ContainerStart(ctx, name, types.ContainerStartOptions{})
68+
err = client.ContainerStart(ctx, name, container.StartOptions{})
7069
assert.NilError(c, err)
7170

7271
err = <-ch

integration/container/checkpoint_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"testing"
99
"time"
1010

11-
"github.com/docker/docker/api/types"
1211
"github.com/docker/docker/api/types/checkpoint"
12+
containertypes "github.com/docker/docker/api/types/container"
1313
mounttypes "github.com/docker/docker/api/types/mount"
1414
"github.com/docker/docker/client"
1515
"github.com/docker/docker/integration/internal/container"
@@ -128,7 +128,7 @@ func TestCheckpoint(t *testing.T) {
128128

129129
// Restore the container from a second checkpoint.
130130
t.Log("Restore the container")
131-
err = apiClient.ContainerStart(ctx, cID, types.ContainerStartOptions{
131+
err = apiClient.ContainerStart(ctx, cID, containertypes.StartOptions{
132132
CheckpointID: "test2",
133133
})
134134
assert.NilError(t, err)

integration/container/create_test.go

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ import (
88
"testing"
99
"time"
1010

11-
"github.com/docker/docker/api/types"
1211
"github.com/docker/docker/api/types/container"
13-
containertypes "github.com/docker/docker/api/types/container"
1412
"github.com/docker/docker/api/types/network"
1513
"github.com/docker/docker/api/types/versions"
1614
"github.com/docker/docker/client"
@@ -253,7 +251,7 @@ func TestCreateWithCustomMaskedPaths(t *testing.T) {
253251
checkInspect(t, ctx, name, tc.expected)
254252

255253
// Start the container.
256-
err = apiClient.ContainerStart(ctx, c.ID, types.ContainerStartOptions{})
254+
err = apiClient.ContainerStart(ctx, c.ID, container.StartOptions{})
257255
assert.NilError(t, err)
258256

259257
poll.WaitOn(t, ctr.IsInState(ctx, apiClient, c.ID, "exited"), poll.WithDelay(100*time.Millisecond))
@@ -331,7 +329,7 @@ func TestCreateWithCustomReadonlyPaths(t *testing.T) {
331329
checkInspect(t, ctx, name, tc.expected)
332330

333331
// Start the container.
334-
err = apiClient.ContainerStart(ctx, c.ID, types.ContainerStartOptions{})
332+
err = apiClient.ContainerStart(ctx, c.ID, container.StartOptions{})
335333
assert.NilError(t, err)
336334

337335
poll.WaitOn(t, ctr.IsInState(ctx, apiClient, c.ID, "exited"), poll.WithDelay(100*time.Millisecond))
@@ -436,7 +434,7 @@ func TestCreateTmpfsOverrideAnonymousVolume(t *testing.T) {
436434
)
437435

438436
defer func() {
439-
err := apiClient.ContainerRemove(ctx, id, containertypes.RemoveOptions{Force: true})
437+
err := apiClient.ContainerRemove(ctx, id, container.RemoveOptions{Force: true})
440438
assert.NilError(t, err)
441439
}()
442440

@@ -447,7 +445,7 @@ func TestCreateTmpfsOverrideAnonymousVolume(t *testing.T) {
447445
assert.Assert(t, is.Len(inspect.Mounts, 0))
448446

449447
chWait, chErr := apiClient.ContainerWait(ctx, id, container.WaitConditionNextExit)
450-
assert.NilError(t, apiClient.ContainerStart(ctx, id, types.ContainerStartOptions{}))
448+
assert.NilError(t, apiClient.ContainerStart(ctx, id, container.StartOptions{}))
451449

452450
timeout := time.NewTimer(30 * time.Second)
453451
defer timeout.Stop()
@@ -483,7 +481,7 @@ func TestCreateDifferentPlatform(t *testing.T) {
483481
Architecture: img.Architecture,
484482
Variant: img.Variant,
485483
}
486-
_, err := apiClient.ContainerCreate(ctx, &containertypes.Config{Image: "busybox:latest"}, &containertypes.HostConfig{}, nil, &p, "")
484+
_, err := apiClient.ContainerCreate(ctx, &container.Config{Image: "busybox:latest"}, &container.HostConfig{}, nil, &p, "")
487485
assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
488486
})
489487
t.Run("different cpu arch", func(t *testing.T) {
@@ -493,7 +491,7 @@ func TestCreateDifferentPlatform(t *testing.T) {
493491
Architecture: img.Architecture + "DifferentArch",
494492
Variant: img.Variant,
495493
}
496-
_, err := apiClient.ContainerCreate(ctx, &containertypes.Config{Image: "busybox:latest"}, &containertypes.HostConfig{}, nil, &p, "")
494+
_, err := apiClient.ContainerCreate(ctx, &container.Config{Image: "busybox:latest"}, &container.HostConfig{}, nil, &p, "")
497495
assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
498496
})
499497
}
@@ -541,32 +539,32 @@ func TestCreateInvalidHostConfig(t *testing.T) {
541539

542540
testCases := []struct {
543541
doc string
544-
hc containertypes.HostConfig
542+
hc container.HostConfig
545543
expectedErr string
546544
}{
547545
{
548546
doc: "invalid IpcMode",
549-
hc: containertypes.HostConfig{IpcMode: "invalid"},
547+
hc: container.HostConfig{IpcMode: "invalid"},
550548
expectedErr: "Error response from daemon: invalid IPC mode: invalid",
551549
},
552550
{
553551
doc: "invalid PidMode",
554-
hc: containertypes.HostConfig{PidMode: "invalid"},
552+
hc: container.HostConfig{PidMode: "invalid"},
555553
expectedErr: "Error response from daemon: invalid PID mode: invalid",
556554
},
557555
{
558556
doc: "invalid PidMode without container ID",
559-
hc: containertypes.HostConfig{PidMode: "container"},
557+
hc: container.HostConfig{PidMode: "container"},
560558
expectedErr: "Error response from daemon: invalid PID mode: container",
561559
},
562560
{
563561
doc: "invalid UTSMode",
564-
hc: containertypes.HostConfig{UTSMode: "invalid"},
562+
hc: container.HostConfig{UTSMode: "invalid"},
565563
expectedErr: "Error response from daemon: invalid UTS mode: invalid",
566564
},
567565
{
568566
doc: "invalid Annotations",
569-
hc: containertypes.HostConfig{Annotations: map[string]string{"": "a"}},
567+
hc: container.HostConfig{Annotations: map[string]string{"": "a"}},
570568
expectedErr: "Error response from daemon: invalid Annotations: the empty string is not permitted as an annotation key",
571569
},
572570
}

0 commit comments

Comments
 (0)