Add option- and output structs for;
- Client.ContainerKill
- Client.ContainerPause
- Client.ContainerRemove
- Client.ContainerResize
- Client.ContainerRestart
- Client.ContainerStart
- Client.ContainerStop
- Client.ContainerUnpause
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -64,20 +64,20 @@ type ContainerAPIClient interface {
|
| 64 | 64 |
ExecAPIClient |
| 65 | 65 |
ContainerExport(ctx context.Context, container string) (io.ReadCloser, error) |
| 66 | 66 |
ContainerInspect(ctx context.Context, container string, options ContainerInspectOptions) (ContainerInspectResult, error) |
| 67 |
- ContainerKill(ctx context.Context, container, signal string) error |
|
| 67 |
+ ContainerKill(ctx context.Context, container string, options ContainerKillOptions) (ContainerKillResult, error) |
|
| 68 | 68 |
ContainerList(ctx context.Context, options ContainerListOptions) ([]container.Summary, error) |
| 69 | 69 |
ContainerLogs(ctx context.Context, container string, options ContainerLogsOptions) (io.ReadCloser, error) |
| 70 |
- ContainerPause(ctx context.Context, container string) error |
|
| 71 |
- ContainerRemove(ctx context.Context, container string, options ContainerRemoveOptions) error |
|
| 70 |
+ ContainerPause(ctx context.Context, container string, options ContainerPauseOptions) (ContainerPauseResult, error) |
|
| 71 |
+ ContainerRemove(ctx context.Context, container string, options ContainerRemoveOptions) (ContainerRemoveResult, error) |
|
| 72 | 72 |
ContainerRename(ctx context.Context, container, newContainerName string) error |
| 73 |
- ContainerResize(ctx context.Context, container string, options ContainerResizeOptions) error |
|
| 74 |
- ContainerRestart(ctx context.Context, container string, options ContainerStopOptions) error |
|
| 73 |
+ ContainerResize(ctx context.Context, container string, options ContainerResizeOptions) (ContainerResizeResult, error) |
|
| 74 |
+ ContainerRestart(ctx context.Context, container string, options ContainerRestartOptions) (ContainerRestartResult, error) |
|
| 75 | 75 |
ContainerStatPath(ctx context.Context, container, path string) (container.PathStat, error) |
| 76 | 76 |
ContainerStats(ctx context.Context, container string, options ContainerStatsOptions) (ContainerStatsResult, error) |
| 77 |
- ContainerStart(ctx context.Context, container string, options ContainerStartOptions) error |
|
| 78 |
- ContainerStop(ctx context.Context, container string, options ContainerStopOptions) error |
|
| 77 |
+ ContainerStart(ctx context.Context, container string, options ContainerStartOptions) (ContainerStartResult, error) |
|
| 78 |
+ ContainerStop(ctx context.Context, container string, options ContainerStopOptions) (ContainerStopResult, error) |
|
| 79 | 79 |
ContainerTop(ctx context.Context, container string, arguments []string) (container.TopResponse, error) |
| 80 |
- ContainerUnpause(ctx context.Context, container string) error |
|
| 80 |
+ ContainerUnpause(ctx context.Context, container string, options ContainerUnPauseOptions) (ContainerUnPauseResult, error) |
|
| 81 | 81 |
ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (container.UpdateResponse, error) |
| 82 | 82 |
ContainerWait(ctx context.Context, container string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error) |
| 83 | 83 |
CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, container.PathStat, error) |
| ... | ... |
@@ -5,19 +5,35 @@ import ( |
| 5 | 5 |
"net/url" |
| 6 | 6 |
) |
| 7 | 7 |
|
| 8 |
+// ContainerKillOptions holds options for [Client.ContainerKill]. |
|
| 9 |
+type ContainerKillOptions struct {
|
|
| 10 |
+ // Signal (optional) is the signal to send to the container to (gracefully) |
|
| 11 |
+ // stop it before forcibly terminating the container with SIGKILL after a |
|
| 12 |
+ // timeout. If no value is set, the default (SIGKILL) is used. |
|
| 13 |
+ Signal string `json:",omitempty"` |
|
| 14 |
+} |
|
| 15 |
+ |
|
| 16 |
+// ContainerKillResult holds the result of [Client.ContainerKill], |
|
| 17 |
+type ContainerKillResult struct {
|
|
| 18 |
+ // Add future fields here. |
|
| 19 |
+} |
|
| 20 |
+ |
|
| 8 | 21 |
// ContainerKill terminates the container process but does not remove the container from the docker host. |
| 9 |
-func (cli *Client) ContainerKill(ctx context.Context, containerID, signal string) error {
|
|
| 22 |
+func (cli *Client) ContainerKill(ctx context.Context, containerID string, options ContainerKillOptions) (ContainerKillResult, error) {
|
|
| 10 | 23 |
containerID, err := trimID("container", containerID)
|
| 11 | 24 |
if err != nil {
|
| 12 |
- return err |
|
| 25 |
+ return ContainerKillResult{}, err
|
|
| 13 | 26 |
} |
| 14 | 27 |
|
| 15 | 28 |
query := url.Values{}
|
| 16 |
- if signal != "" {
|
|
| 17 |
- query.Set("signal", signal)
|
|
| 29 |
+ if options.Signal != "" {
|
|
| 30 |
+ query.Set("signal", options.Signal)
|
|
| 18 | 31 |
} |
| 19 | 32 |
|
| 20 | 33 |
resp, err := cli.post(ctx, "/containers/"+containerID+"/kill", query, nil, nil) |
| 21 | 34 |
defer ensureReaderClosed(resp) |
| 22 |
- return err |
|
| 35 |
+ if err != nil {
|
|
| 36 |
+ return ContainerKillResult{}, err
|
|
| 37 |
+ } |
|
| 38 |
+ return ContainerKillResult{}, nil
|
|
| 23 | 39 |
} |
| ... | ... |
@@ -1,7 +1,6 @@ |
| 1 | 1 |
package client |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "context" |
|
| 5 | 4 |
"fmt" |
| 6 | 5 |
"net/http" |
| 7 | 6 |
"testing" |
| ... | ... |
@@ -17,34 +16,39 @@ func TestContainerKillError(t *testing.T) {
|
| 17 | 17 |
) |
| 18 | 18 |
assert.NilError(t, err) |
| 19 | 19 |
|
| 20 |
- err = client.ContainerKill(context.Background(), "nothing", "SIGKILL") |
|
| 20 |
+ _, err = client.ContainerKill(t.Context(), "nothing", ContainerKillOptions{
|
|
| 21 |
+ Signal: "SIGKILL", |
|
| 22 |
+ }) |
|
| 21 | 23 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) |
| 22 | 24 |
|
| 23 |
- err = client.ContainerKill(context.Background(), "", "") |
|
| 25 |
+ _, err = client.ContainerKill(t.Context(), "", ContainerKillOptions{})
|
|
| 24 | 26 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument)) |
| 25 | 27 |
assert.Check(t, is.ErrorContains(err, "value is empty")) |
| 26 | 28 |
|
| 27 |
- err = client.ContainerKill(context.Background(), " ", "") |
|
| 29 |
+ _, err = client.ContainerKill(t.Context(), " ", ContainerKillOptions{})
|
|
| 28 | 30 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument)) |
| 29 | 31 |
assert.Check(t, is.ErrorContains(err, "value is empty")) |
| 30 | 32 |
} |
| 31 | 33 |
|
| 32 | 34 |
func TestContainerKill(t *testing.T) {
|
| 33 | 35 |
const expectedURL = "/containers/container_id/kill" |
| 36 |
+ const expectedSignal = "SIG_SOMETHING" |
|
| 34 | 37 |
client, err := NewClientWithOpts( |
| 35 | 38 |
WithMockClient(func(req *http.Request) (*http.Response, error) {
|
| 36 | 39 |
if err := assertRequest(req, http.MethodPost, expectedURL); err != nil {
|
| 37 | 40 |
return nil, err |
| 38 | 41 |
} |
| 39 | 42 |
signal := req.URL.Query().Get("signal")
|
| 40 |
- if signal != "SIGKILL" {
|
|
| 41 |
- return nil, fmt.Errorf("signal not set in URL query properly. Expected 'SIGKILL', got %s", signal)
|
|
| 43 |
+ if signal != expectedSignal {
|
|
| 44 |
+ return nil, fmt.Errorf("signal not set in URL query properly. Expected '%s', got %s", expectedSignal, signal)
|
|
| 42 | 45 |
} |
| 43 | 46 |
return mockResponse(http.StatusOK, nil, "")(req) |
| 44 | 47 |
}), |
| 45 | 48 |
) |
| 46 | 49 |
assert.NilError(t, err) |
| 47 | 50 |
|
| 48 |
- err = client.ContainerKill(context.Background(), "container_id", "SIGKILL") |
|
| 51 |
+ _, err = client.ContainerKill(t.Context(), "container_id", ContainerKillOptions{
|
|
| 52 |
+ Signal: expectedSignal, |
|
| 53 |
+ }) |
|
| 49 | 54 |
assert.NilError(t, err) |
| 50 | 55 |
} |
| ... | ... |
@@ -2,14 +2,27 @@ package client |
| 2 | 2 |
|
| 3 | 3 |
import "context" |
| 4 | 4 |
|
| 5 |
+// ContainerPauseOptions holds options for [Client.ContainerPause]. |
|
| 6 |
+type ContainerPauseOptions struct {
|
|
| 7 |
+ // Add future optional parameters here. |
|
| 8 |
+} |
|
| 9 |
+ |
|
| 10 |
+// ContainerPauseResult holds the result of [Client.ContainerPause], |
|
| 11 |
+type ContainerPauseResult struct {
|
|
| 12 |
+ // Add future fields here. |
|
| 13 |
+} |
|
| 14 |
+ |
|
| 5 | 15 |
// ContainerPause pauses the main process of a given container without terminating it. |
| 6 |
-func (cli *Client) ContainerPause(ctx context.Context, containerID string) error {
|
|
| 16 |
+func (cli *Client) ContainerPause(ctx context.Context, containerID string, options ContainerPauseOptions) (ContainerPauseResult, error) {
|
|
| 7 | 17 |
containerID, err := trimID("container", containerID)
|
| 8 | 18 |
if err != nil {
|
| 9 |
- return err |
|
| 19 |
+ return ContainerPauseResult{}, err
|
|
| 10 | 20 |
} |
| 11 | 21 |
|
| 12 | 22 |
resp, err := cli.post(ctx, "/containers/"+containerID+"/pause", nil, nil, nil) |
| 13 | 23 |
defer ensureReaderClosed(resp) |
| 14 |
- return err |
|
| 24 |
+ if err != nil {
|
|
| 25 |
+ return ContainerPauseResult{}, err
|
|
| 26 |
+ } |
|
| 27 |
+ return ContainerPauseResult{}, nil
|
|
| 15 | 28 |
} |
| ... | ... |
@@ -1,7 +1,6 @@ |
| 1 | 1 |
package client |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "context" |
|
| 5 | 4 |
"net/http" |
| 6 | 5 |
"testing" |
| 7 | 6 |
|
| ... | ... |
@@ -16,7 +15,7 @@ func TestContainerPauseError(t *testing.T) {
|
| 16 | 16 |
) |
| 17 | 17 |
assert.NilError(t, err) |
| 18 | 18 |
|
| 19 |
- err = client.ContainerPause(context.Background(), "nothing") |
|
| 19 |
+ _, err = client.ContainerPause(t.Context(), "nothing", ContainerPauseOptions{})
|
|
| 20 | 20 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) |
| 21 | 21 |
} |
| 22 | 22 |
|
| ... | ... |
@@ -32,6 +31,6 @@ func TestContainerPause(t *testing.T) {
|
| 32 | 32 |
) |
| 33 | 33 |
assert.NilError(t, err) |
| 34 | 34 |
|
| 35 |
- err = client.ContainerPause(context.Background(), "container_id") |
|
| 35 |
+ _, err = client.ContainerPause(t.Context(), "container_id", ContainerPauseOptions{})
|
|
| 36 | 36 |
assert.NilError(t, err) |
| 37 | 37 |
} |
| ... | ... |
@@ -12,11 +12,16 @@ type ContainerRemoveOptions struct {
|
| 12 | 12 |
Force bool |
| 13 | 13 |
} |
| 14 | 14 |
|
| 15 |
+// ContainerRemoveResult holds the result of [Client.ContainerRemove], |
|
| 16 |
+type ContainerRemoveResult struct {
|
|
| 17 |
+ // Add future fields here. |
|
| 18 |
+} |
|
| 19 |
+ |
|
| 15 | 20 |
// ContainerRemove kills and removes a container from the docker host. |
| 16 |
-func (cli *Client) ContainerRemove(ctx context.Context, containerID string, options ContainerRemoveOptions) error {
|
|
| 21 |
+func (cli *Client) ContainerRemove(ctx context.Context, containerID string, options ContainerRemoveOptions) (ContainerRemoveResult, error) {
|
|
| 17 | 22 |
containerID, err := trimID("container", containerID)
|
| 18 | 23 |
if err != nil {
|
| 19 |
- return err |
|
| 24 |
+ return ContainerRemoveResult{}, err
|
|
| 20 | 25 |
} |
| 21 | 26 |
|
| 22 | 27 |
query := url.Values{}
|
| ... | ... |
@@ -33,5 +38,8 @@ func (cli *Client) ContainerRemove(ctx context.Context, containerID string, opti |
| 33 | 33 |
|
| 34 | 34 |
resp, err := cli.delete(ctx, "/containers/"+containerID, query, nil) |
| 35 | 35 |
defer ensureReaderClosed(resp) |
| 36 |
- return err |
|
| 36 |
+ if err != nil {
|
|
| 37 |
+ return ContainerRemoveResult{}, err
|
|
| 38 |
+ } |
|
| 39 |
+ return ContainerRemoveResult{}, nil
|
|
| 37 | 40 |
} |
| ... | ... |
@@ -1,7 +1,6 @@ |
| 1 | 1 |
package client |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "context" |
|
| 5 | 4 |
"fmt" |
| 6 | 5 |
"net/http" |
| 7 | 6 |
"testing" |
| ... | ... |
@@ -14,14 +13,14 @@ import ( |
| 14 | 14 |
func TestContainerRemoveError(t *testing.T) {
|
| 15 | 15 |
client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error"))) |
| 16 | 16 |
assert.NilError(t, err) |
| 17 |
- err = client.ContainerRemove(context.Background(), "container_id", ContainerRemoveOptions{})
|
|
| 17 |
+ _, err = client.ContainerRemove(t.Context(), "container_id", ContainerRemoveOptions{})
|
|
| 18 | 18 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) |
| 19 | 19 |
|
| 20 |
- err = client.ContainerRemove(context.Background(), "", ContainerRemoveOptions{})
|
|
| 20 |
+ _, err = client.ContainerRemove(t.Context(), "", ContainerRemoveOptions{})
|
|
| 21 | 21 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument)) |
| 22 | 22 |
assert.Check(t, is.ErrorContains(err, "value is empty")) |
| 23 | 23 |
|
| 24 |
- err = client.ContainerRemove(context.Background(), " ", ContainerRemoveOptions{})
|
|
| 24 |
+ _, err = client.ContainerRemove(t.Context(), " ", ContainerRemoveOptions{})
|
|
| 25 | 25 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument)) |
| 26 | 26 |
assert.Check(t, is.ErrorContains(err, "value is empty")) |
| 27 | 27 |
} |
| ... | ... |
@@ -29,7 +28,7 @@ func TestContainerRemoveError(t *testing.T) {
|
| 29 | 29 |
func TestContainerRemoveNotFoundError(t *testing.T) {
|
| 30 | 30 |
client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusNotFound, "no such container: container_id"))) |
| 31 | 31 |
assert.NilError(t, err) |
| 32 |
- err = client.ContainerRemove(context.Background(), "container_id", ContainerRemoveOptions{})
|
|
| 32 |
+ _, err = client.ContainerRemove(t.Context(), "container_id", ContainerRemoveOptions{})
|
|
| 33 | 33 |
assert.Check(t, is.ErrorContains(err, "no such container: container_id")) |
| 34 | 34 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound)) |
| 35 | 35 |
} |
| ... | ... |
@@ -57,7 +56,7 @@ func TestContainerRemove(t *testing.T) {
|
| 57 | 57 |
})) |
| 58 | 58 |
assert.NilError(t, err) |
| 59 | 59 |
|
| 60 |
- err = client.ContainerRemove(context.Background(), "container_id", ContainerRemoveOptions{
|
|
| 60 |
+ _, err = client.ContainerRemove(t.Context(), "container_id", ContainerRemoveOptions{
|
|
| 61 | 61 |
RemoveVolumes: true, |
| 62 | 62 |
Force: true, |
| 63 | 63 |
}) |
| ... | ... |
@@ -14,13 +14,28 @@ type ContainerResizeOptions struct {
|
| 14 | 14 |
Width uint |
| 15 | 15 |
} |
| 16 | 16 |
|
| 17 |
+// ContainerResizeResult holds the result of [Client.ContainerResize], |
|
| 18 |
+type ContainerResizeResult struct {
|
|
| 19 |
+ // Add future fields here. |
|
| 20 |
+} |
|
| 21 |
+ |
|
| 17 | 22 |
// ContainerResize changes the size of the pseudo-TTY for a container. |
| 18 |
-func (cli *Client) ContainerResize(ctx context.Context, containerID string, options ContainerResizeOptions) error {
|
|
| 23 |
+func (cli *Client) ContainerResize(ctx context.Context, containerID string, options ContainerResizeOptions) (ContainerResizeResult, error) {
|
|
| 19 | 24 |
containerID, err := trimID("container", containerID)
|
| 20 | 25 |
if err != nil {
|
| 21 |
- return err |
|
| 26 |
+ return ContainerResizeResult{}, err
|
|
| 27 |
+ } |
|
| 28 |
+ // FIXME(thaJeztah): the API / backend accepts uint32, but container.ResizeOptions uses uint. |
|
| 29 |
+ query := url.Values{}
|
|
| 30 |
+ query.Set("h", strconv.FormatUint(uint64(options.Height), 10))
|
|
| 31 |
+ query.Set("w", strconv.FormatUint(uint64(options.Width), 10))
|
|
| 32 |
+ |
|
| 33 |
+ resp, err := cli.post(ctx, "/containers/"+containerID+"/resize", query, nil, nil) |
|
| 34 |
+ defer ensureReaderClosed(resp) |
|
| 35 |
+ if err != nil {
|
|
| 36 |
+ return ContainerResizeResult{}, err
|
|
| 22 | 37 |
} |
| 23 |
- return cli.resize(ctx, "/containers/"+containerID, options.Height, options.Width) |
|
| 38 |
+ return ContainerResizeResult{}, nil
|
|
| 24 | 39 |
} |
| 25 | 40 |
|
| 26 | 41 |
// ExecResizeOptions holds options for resizing a container exec TTY. |
| ... | ... |
@@ -36,17 +51,16 @@ func (cli *Client) ExecResize(ctx context.Context, execID string, options ExecRe |
| 36 | 36 |
if err != nil {
|
| 37 | 37 |
return ExecResizeResult{}, err
|
| 38 | 38 |
} |
| 39 |
- err = cli.resize(ctx, "/exec/"+execID, options.Height, options.Width) |
|
| 40 |
- return ExecResizeResult{}, err
|
|
| 41 |
-} |
|
| 42 |
- |
|
| 43 |
-func (cli *Client) resize(ctx context.Context, basePath string, height, width uint) error {
|
|
| 44 | 39 |
// FIXME(thaJeztah): the API / backend accepts uint32, but container.ResizeOptions uses uint. |
| 45 | 40 |
query := url.Values{}
|
| 46 |
- query.Set("h", strconv.FormatUint(uint64(height), 10))
|
|
| 47 |
- query.Set("w", strconv.FormatUint(uint64(width), 10))
|
|
| 41 |
+ query.Set("h", strconv.FormatUint(uint64(options.Height), 10))
|
|
| 42 |
+ query.Set("w", strconv.FormatUint(uint64(options.Width), 10))
|
|
| 48 | 43 |
|
| 49 |
- resp, err := cli.post(ctx, basePath+"/resize", query, nil, nil) |
|
| 44 |
+ resp, err := cli.post(ctx, "/exec/"+execID+"/resize", query, nil, nil) |
|
| 50 | 45 |
defer ensureReaderClosed(resp) |
| 51 |
- return err |
|
| 46 |
+ if err != nil {
|
|
| 47 |
+ return ExecResizeResult{}, err
|
|
| 48 |
+ } |
|
| 49 |
+ return ExecResizeResult{}, nil
|
|
| 50 |
+ |
|
| 52 | 51 |
} |
| ... | ... |
@@ -1,7 +1,6 @@ |
| 1 | 1 |
package client |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "context" |
|
| 5 | 4 |
"math" |
| 6 | 5 |
"net/http" |
| 7 | 6 |
"testing" |
| ... | ... |
@@ -14,14 +13,14 @@ import ( |
| 14 | 14 |
func TestContainerResizeError(t *testing.T) {
|
| 15 | 15 |
client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error"))) |
| 16 | 16 |
assert.NilError(t, err) |
| 17 |
- err = client.ContainerResize(context.Background(), "container_id", ContainerResizeOptions{})
|
|
| 17 |
+ _, err = client.ContainerResize(t.Context(), "container_id", ContainerResizeOptions{})
|
|
| 18 | 18 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) |
| 19 | 19 |
|
| 20 |
- err = client.ContainerResize(context.Background(), "", ContainerResizeOptions{})
|
|
| 20 |
+ _, err = client.ContainerResize(t.Context(), "", ContainerResizeOptions{})
|
|
| 21 | 21 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument)) |
| 22 | 22 |
assert.Check(t, is.ErrorContains(err, "value is empty")) |
| 23 | 23 |
|
| 24 |
- err = client.ContainerResize(context.Background(), " ", ContainerResizeOptions{})
|
|
| 24 |
+ _, err = client.ContainerResize(t.Context(), " ", ContainerResizeOptions{})
|
|
| 25 | 25 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument)) |
| 26 | 26 |
assert.Check(t, is.ErrorContains(err, "value is empty")) |
| 27 | 27 |
} |
| ... | ... |
@@ -29,7 +28,7 @@ func TestContainerResizeError(t *testing.T) {
|
| 29 | 29 |
func TestExecResizeError(t *testing.T) {
|
| 30 | 30 |
client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error"))) |
| 31 | 31 |
assert.NilError(t, err) |
| 32 |
- _, err = client.ExecResize(context.Background(), "exec_id", ExecResizeOptions{})
|
|
| 32 |
+ _, err = client.ExecResize(t.Context(), "exec_id", ExecResizeOptions{})
|
|
| 33 | 33 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) |
| 34 | 34 |
} |
| 35 | 35 |
|
| ... | ... |
@@ -70,7 +69,7 @@ func TestContainerResize(t *testing.T) {
|
| 70 | 70 |
t.Run(tc.doc, func(t *testing.T) {
|
| 71 | 71 |
client, err := NewClientWithOpts(WithMockClient(resizeTransport(t, expectedURL, tc.expectedHeight, tc.expectedWidth))) |
| 72 | 72 |
assert.NilError(t, err) |
| 73 |
- err = client.ContainerResize(context.Background(), "container_id", tc.opts) |
|
| 73 |
+ _, err = client.ContainerResize(t.Context(), "container_id", tc.opts) |
|
| 74 | 74 |
assert.NilError(t, err) |
| 75 | 75 |
}) |
| 76 | 76 |
} |
| ... | ... |
@@ -112,7 +111,7 @@ func TestExecResize(t *testing.T) {
|
| 112 | 112 |
t.Run(tc.doc, func(t *testing.T) {
|
| 113 | 113 |
client, err := NewClientWithOpts(WithMockClient(resizeTransport(t, expectedURL, tc.expectedHeight, tc.expectedWidth))) |
| 114 | 114 |
assert.NilError(t, err) |
| 115 |
- _, err = client.ExecResize(context.Background(), "exec_id", tc.opts) |
|
| 115 |
+ _, err = client.ExecResize(t.Context(), "exec_id", tc.opts) |
|
| 116 | 116 |
assert.NilError(t, err) |
| 117 | 117 |
}) |
| 118 | 118 |
} |
| ... | ... |
@@ -6,13 +6,36 @@ import ( |
| 6 | 6 |
"strconv" |
| 7 | 7 |
) |
| 8 | 8 |
|
| 9 |
+// ContainerRestartOptions holds options for [Client.ContainerRestart]. |
|
| 10 |
+type ContainerRestartOptions struct {
|
|
| 11 |
+ // Signal (optional) is the signal to send to the container to (gracefully) |
|
| 12 |
+ // stop it before forcibly terminating the container with SIGKILL after the |
|
| 13 |
+ // timeout expires. If no value is set, the default (SIGTERM) is used. |
|
| 14 |
+ Signal string `json:",omitempty"` |
|
| 15 |
+ |
|
| 16 |
+ // Timeout (optional) is the timeout (in seconds) to wait for the container |
|
| 17 |
+ // to stop gracefully before forcibly terminating it with SIGKILL. |
|
| 18 |
+ // |
|
| 19 |
+ // - Use nil to use the default timeout (10 seconds). |
|
| 20 |
+ // - Use '-1' to wait indefinitely. |
|
| 21 |
+ // - Use '0' to not wait for the container to exit gracefully, and |
|
| 22 |
+ // immediately proceeds to forcibly terminating the container. |
|
| 23 |
+ // - Other positive values are used as timeout (in seconds). |
|
| 24 |
+ Timeout *int `json:",omitempty"` |
|
| 25 |
+} |
|
| 26 |
+ |
|
| 27 |
+// ContainerRestartResult holds the result of [Client.ContainerRestart], |
|
| 28 |
+type ContainerRestartResult struct {
|
|
| 29 |
+ // Add future fields here. |
|
| 30 |
+} |
|
| 31 |
+ |
|
| 9 | 32 |
// ContainerRestart stops, and starts a container again. |
| 10 | 33 |
// It makes the daemon wait for the container to be up again for |
| 11 | 34 |
// a specific amount of time, given the timeout. |
| 12 |
-func (cli *Client) ContainerRestart(ctx context.Context, containerID string, options ContainerStopOptions) error {
|
|
| 35 |
+func (cli *Client) ContainerRestart(ctx context.Context, containerID string, options ContainerRestartOptions) (ContainerRestartResult, error) {
|
|
| 13 | 36 |
containerID, err := trimID("container", containerID)
|
| 14 | 37 |
if err != nil {
|
| 15 |
- return err |
|
| 38 |
+ return ContainerRestartResult{}, err
|
|
| 16 | 39 |
} |
| 17 | 40 |
|
| 18 | 41 |
query := url.Values{}
|
| ... | ... |
@@ -24,5 +47,8 @@ func (cli *Client) ContainerRestart(ctx context.Context, containerID string, opt |
| 24 | 24 |
} |
| 25 | 25 |
resp, err := cli.post(ctx, "/containers/"+containerID+"/restart", query, nil, nil) |
| 26 | 26 |
defer ensureReaderClosed(resp) |
| 27 |
- return err |
|
| 27 |
+ if err != nil {
|
|
| 28 |
+ return ContainerRestartResult{}, err
|
|
| 29 |
+ } |
|
| 30 |
+ return ContainerRestartResult{}, nil
|
|
| 28 | 31 |
} |
| ... | ... |
@@ -1,7 +1,6 @@ |
| 1 | 1 |
package client |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "context" |
|
| 5 | 4 |
"fmt" |
| 6 | 5 |
"net/http" |
| 7 | 6 |
"testing" |
| ... | ... |
@@ -14,14 +13,14 @@ import ( |
| 14 | 14 |
func TestContainerRestartError(t *testing.T) {
|
| 15 | 15 |
client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error"))) |
| 16 | 16 |
assert.NilError(t, err) |
| 17 |
- err = client.ContainerRestart(context.Background(), "nothing", ContainerStopOptions{})
|
|
| 17 |
+ _, err = client.ContainerRestart(t.Context(), "nothing", ContainerRestartOptions{})
|
|
| 18 | 18 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) |
| 19 | 19 |
|
| 20 |
- err = client.ContainerRestart(context.Background(), "", ContainerStopOptions{})
|
|
| 20 |
+ _, err = client.ContainerRestart(t.Context(), "", ContainerRestartOptions{})
|
|
| 21 | 21 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument)) |
| 22 | 22 |
assert.Check(t, is.ErrorContains(err, "value is empty")) |
| 23 | 23 |
|
| 24 |
- err = client.ContainerRestart(context.Background(), " ", ContainerStopOptions{})
|
|
| 24 |
+ _, err = client.ContainerRestart(t.Context(), " ", ContainerRestartOptions{})
|
|
| 25 | 25 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument)) |
| 26 | 26 |
assert.Check(t, is.ErrorContains(err, "value is empty")) |
| 27 | 27 |
} |
| ... | ... |
@@ -34,7 +33,7 @@ func TestContainerRestartConnectionError(t *testing.T) {
|
| 34 | 34 |
client, err := NewClientWithOpts(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid"))
|
| 35 | 35 |
assert.NilError(t, err) |
| 36 | 36 |
|
| 37 |
- err = client.ContainerRestart(context.Background(), "nothing", ContainerStopOptions{})
|
|
| 37 |
+ _, err = client.ContainerRestart(t.Context(), "nothing", ContainerRestartOptions{})
|
|
| 38 | 38 |
assert.Check(t, is.ErrorType(err, IsErrConnectionFailed)) |
| 39 | 39 |
} |
| 40 | 40 |
|
| ... | ... |
@@ -56,7 +55,7 @@ func TestContainerRestart(t *testing.T) {
|
| 56 | 56 |
})) |
| 57 | 57 |
assert.NilError(t, err) |
| 58 | 58 |
timeout := 100 |
| 59 |
- err = client.ContainerRestart(context.Background(), "container_id", ContainerStopOptions{
|
|
| 59 |
+ _, err = client.ContainerRestart(t.Context(), "container_id", ContainerRestartOptions{
|
|
| 60 | 60 |
Signal: "SIGKILL", |
| 61 | 61 |
Timeout: &timeout, |
| 62 | 62 |
}) |
| ... | ... |
@@ -5,17 +5,22 @@ import ( |
| 5 | 5 |
"net/url" |
| 6 | 6 |
) |
| 7 | 7 |
|
| 8 |
-// ContainerStartOptions holds parameters to start containers. |
|
| 8 |
+// ContainerStartOptions holds options for [Client.ContainerStart]. |
|
| 9 | 9 |
type ContainerStartOptions struct {
|
| 10 | 10 |
CheckpointID string |
| 11 | 11 |
CheckpointDir string |
| 12 | 12 |
} |
| 13 | 13 |
|
| 14 |
+// ContainerStartResult holds the result of [Client.ContainerStart], |
|
| 15 |
+type ContainerStartResult struct {
|
|
| 16 |
+ // Add future fields here. |
|
| 17 |
+} |
|
| 18 |
+ |
|
| 14 | 19 |
// ContainerStart sends a request to the docker daemon to start a container. |
| 15 |
-func (cli *Client) ContainerStart(ctx context.Context, containerID string, options ContainerStartOptions) error {
|
|
| 20 |
+func (cli *Client) ContainerStart(ctx context.Context, containerID string, options ContainerStartOptions) (ContainerStartResult, error) {
|
|
| 16 | 21 |
containerID, err := trimID("container", containerID)
|
| 17 | 22 |
if err != nil {
|
| 18 |
- return err |
|
| 23 |
+ return ContainerStartResult{}, err
|
|
| 19 | 24 |
} |
| 20 | 25 |
|
| 21 | 26 |
query := url.Values{}
|
| ... | ... |
@@ -28,5 +33,8 @@ func (cli *Client) ContainerStart(ctx context.Context, containerID string, optio |
| 28 | 28 |
|
| 29 | 29 |
resp, err := cli.post(ctx, "/containers/"+containerID+"/start", query, nil, nil) |
| 30 | 30 |
defer ensureReaderClosed(resp) |
| 31 |
- return err |
|
| 31 |
+ if err != nil {
|
|
| 32 |
+ return ContainerStartResult{}, err
|
|
| 33 |
+ } |
|
| 34 |
+ return ContainerStartResult{}, nil
|
|
| 32 | 35 |
} |
| ... | ... |
@@ -1,7 +1,6 @@ |
| 1 | 1 |
package client |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "context" |
|
| 5 | 4 |
"encoding/json" |
| 6 | 5 |
"fmt" |
| 7 | 6 |
"net/http" |
| ... | ... |
@@ -15,14 +14,14 @@ import ( |
| 15 | 15 |
func TestContainerStartError(t *testing.T) {
|
| 16 | 16 |
client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error"))) |
| 17 | 17 |
assert.NilError(t, err) |
| 18 |
- err = client.ContainerStart(context.Background(), "nothing", ContainerStartOptions{})
|
|
| 18 |
+ _, err = client.ContainerStart(t.Context(), "nothing", ContainerStartOptions{})
|
|
| 19 | 19 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) |
| 20 | 20 |
|
| 21 |
- err = client.ContainerStart(context.Background(), "", ContainerStartOptions{})
|
|
| 21 |
+ _, err = client.ContainerStart(t.Context(), "", ContainerStartOptions{})
|
|
| 22 | 22 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument)) |
| 23 | 23 |
assert.Check(t, is.ErrorContains(err, "value is empty")) |
| 24 | 24 |
|
| 25 |
- err = client.ContainerStart(context.Background(), " ", ContainerStartOptions{})
|
|
| 25 |
+ _, err = client.ContainerStart(t.Context(), " ", ContainerStartOptions{})
|
|
| 26 | 26 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument)) |
| 27 | 27 |
assert.Check(t, is.ErrorContains(err, "value is empty")) |
| 28 | 28 |
} |
| ... | ... |
@@ -49,6 +48,6 @@ func TestContainerStart(t *testing.T) {
|
| 49 | 49 |
})) |
| 50 | 50 |
assert.NilError(t, err) |
| 51 | 51 |
|
| 52 |
- err = client.ContainerStart(context.Background(), "container_id", ContainerStartOptions{CheckpointID: "checkpoint_id"})
|
|
| 52 |
+ _, err = client.ContainerStart(t.Context(), "container_id", ContainerStartOptions{CheckpointID: "checkpoint_id"})
|
|
| 53 | 53 |
assert.NilError(t, err) |
| 54 | 54 |
} |
| ... | ... |
@@ -6,11 +6,11 @@ import ( |
| 6 | 6 |
"strconv" |
| 7 | 7 |
) |
| 8 | 8 |
|
| 9 |
-// ContainerStopOptions holds the options to stop or restart a container. |
|
| 9 |
+// ContainerStopOptions holds the options for [Client.ContainerStop]. |
|
| 10 | 10 |
type ContainerStopOptions struct {
|
| 11 | 11 |
// Signal (optional) is the signal to send to the container to (gracefully) |
| 12 | 12 |
// stop it before forcibly terminating the container with SIGKILL after the |
| 13 |
- // timeout expires. If not value is set, the default (SIGTERM) is used. |
|
| 13 |
+ // timeout expires. If no value is set, the default (SIGTERM) is used. |
|
| 14 | 14 |
Signal string `json:",omitempty"` |
| 15 | 15 |
|
| 16 | 16 |
// Timeout (optional) is the timeout (in seconds) to wait for the container |
| ... | ... |
@@ -24,6 +24,11 @@ type ContainerStopOptions struct {
|
| 24 | 24 |
Timeout *int `json:",omitempty"` |
| 25 | 25 |
} |
| 26 | 26 |
|
| 27 |
+// ContainerStopResult holds the result of [Client.ContainerStop], |
|
| 28 |
+type ContainerStopResult struct {
|
|
| 29 |
+ // Add future fields here. |
|
| 30 |
+} |
|
| 31 |
+ |
|
| 27 | 32 |
// ContainerStop stops a container. In case the container fails to stop |
| 28 | 33 |
// gracefully within a time frame specified by the timeout argument, |
| 29 | 34 |
// it is forcefully terminated (killed). |
| ... | ... |
@@ -31,10 +36,10 @@ type ContainerStopOptions struct {
|
| 31 | 31 |
// If the timeout is nil, the container's StopTimeout value is used, if set, |
| 32 | 32 |
// otherwise the engine default. A negative timeout value can be specified, |
| 33 | 33 |
// meaning no timeout, i.e. no forceful termination is performed. |
| 34 |
-func (cli *Client) ContainerStop(ctx context.Context, containerID string, options ContainerStopOptions) error {
|
|
| 34 |
+func (cli *Client) ContainerStop(ctx context.Context, containerID string, options ContainerStopOptions) (ContainerStopResult, error) {
|
|
| 35 | 35 |
containerID, err := trimID("container", containerID)
|
| 36 | 36 |
if err != nil {
|
| 37 |
- return err |
|
| 37 |
+ return ContainerStopResult{}, err
|
|
| 38 | 38 |
} |
| 39 | 39 |
|
| 40 | 40 |
query := url.Values{}
|
| ... | ... |
@@ -46,5 +51,8 @@ func (cli *Client) ContainerStop(ctx context.Context, containerID string, option |
| 46 | 46 |
} |
| 47 | 47 |
resp, err := cli.post(ctx, "/containers/"+containerID+"/stop", query, nil, nil) |
| 48 | 48 |
defer ensureReaderClosed(resp) |
| 49 |
- return err |
|
| 49 |
+ if err != nil {
|
|
| 50 |
+ return ContainerStopResult{}, err
|
|
| 51 |
+ } |
|
| 52 |
+ return ContainerStopResult{}, nil
|
|
| 50 | 53 |
} |
| ... | ... |
@@ -1,7 +1,6 @@ |
| 1 | 1 |
package client |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "context" |
|
| 5 | 4 |
"fmt" |
| 6 | 5 |
"net/http" |
| 7 | 6 |
"testing" |
| ... | ... |
@@ -14,14 +13,14 @@ import ( |
| 14 | 14 |
func TestContainerStopError(t *testing.T) {
|
| 15 | 15 |
client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error"))) |
| 16 | 16 |
assert.NilError(t, err) |
| 17 |
- err = client.ContainerStop(context.Background(), "container_id", ContainerStopOptions{})
|
|
| 17 |
+ _, err = client.ContainerStop(t.Context(), "container_id", ContainerStopOptions{})
|
|
| 18 | 18 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) |
| 19 | 19 |
|
| 20 |
- err = client.ContainerStop(context.Background(), "", ContainerStopOptions{})
|
|
| 20 |
+ _, err = client.ContainerStop(t.Context(), "", ContainerStopOptions{})
|
|
| 21 | 21 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument)) |
| 22 | 22 |
assert.Check(t, is.ErrorContains(err, "value is empty")) |
| 23 | 23 |
|
| 24 |
- err = client.ContainerStop(context.Background(), " ", ContainerStopOptions{})
|
|
| 24 |
+ _, err = client.ContainerStop(t.Context(), " ", ContainerStopOptions{})
|
|
| 25 | 25 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument)) |
| 26 | 26 |
assert.Check(t, is.ErrorContains(err, "value is empty")) |
| 27 | 27 |
} |
| ... | ... |
@@ -34,7 +33,7 @@ func TestContainerStopConnectionError(t *testing.T) {
|
| 34 | 34 |
client, err := NewClientWithOpts(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid"))
|
| 35 | 35 |
assert.NilError(t, err) |
| 36 | 36 |
|
| 37 |
- err = client.ContainerStop(context.Background(), "container_id", ContainerStopOptions{})
|
|
| 37 |
+ _, err = client.ContainerStop(t.Context(), "container_id", ContainerStopOptions{})
|
|
| 38 | 38 |
assert.Check(t, is.ErrorType(err, IsErrConnectionFailed)) |
| 39 | 39 |
} |
| 40 | 40 |
|
| ... | ... |
@@ -56,7 +55,7 @@ func TestContainerStop(t *testing.T) {
|
| 56 | 56 |
})) |
| 57 | 57 |
assert.NilError(t, err) |
| 58 | 58 |
timeout := 100 |
| 59 |
- err = client.ContainerStop(context.Background(), "container_id", ContainerStopOptions{
|
|
| 59 |
+ _, err = client.ContainerStop(t.Context(), "container_id", ContainerStopOptions{
|
|
| 60 | 60 |
Signal: "SIGKILL", |
| 61 | 61 |
Timeout: &timeout, |
| 62 | 62 |
}) |
| ... | ... |
@@ -2,14 +2,27 @@ package client |
| 2 | 2 |
|
| 3 | 3 |
import "context" |
| 4 | 4 |
|
| 5 |
+// ContainerUnPauseOptions holds options for [Client.ContainerUnpause]. |
|
| 6 |
+type ContainerUnPauseOptions struct {
|
|
| 7 |
+ // Add future optional parameters here. |
|
| 8 |
+} |
|
| 9 |
+ |
|
| 10 |
+// ContainerUnPauseResult holds the result of [Client.ContainerUnpause], |
|
| 11 |
+type ContainerUnPauseResult struct {
|
|
| 12 |
+ // Add future fields here. |
|
| 13 |
+} |
|
| 14 |
+ |
|
| 5 | 15 |
// ContainerUnpause resumes the process execution within a container. |
| 6 |
-func (cli *Client) ContainerUnpause(ctx context.Context, containerID string) error {
|
|
| 16 |
+func (cli *Client) ContainerUnpause(ctx context.Context, containerID string, options ContainerUnPauseOptions) (ContainerUnPauseResult, error) {
|
|
| 7 | 17 |
containerID, err := trimID("container", containerID)
|
| 8 | 18 |
if err != nil {
|
| 9 |
- return err |
|
| 19 |
+ return ContainerUnPauseResult{}, err
|
|
| 10 | 20 |
} |
| 11 | 21 |
|
| 12 | 22 |
resp, err := cli.post(ctx, "/containers/"+containerID+"/unpause", nil, nil, nil) |
| 13 | 23 |
defer ensureReaderClosed(resp) |
| 14 |
- return err |
|
| 24 |
+ if err != nil {
|
|
| 25 |
+ return ContainerUnPauseResult{}, err
|
|
| 26 |
+ } |
|
| 27 |
+ return ContainerUnPauseResult{}, nil
|
|
| 15 | 28 |
} |
| ... | ... |
@@ -1,7 +1,6 @@ |
| 1 | 1 |
package client |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "context" |
|
| 5 | 4 |
"net/http" |
| 6 | 5 |
"testing" |
| 7 | 6 |
|
| ... | ... |
@@ -13,14 +12,14 @@ import ( |
| 13 | 13 |
func TestContainerUnpauseError(t *testing.T) {
|
| 14 | 14 |
client, err := NewClientWithOpts(WithMockClient(errorMock(http.StatusInternalServerError, "Server error"))) |
| 15 | 15 |
assert.NilError(t, err) |
| 16 |
- err = client.ContainerUnpause(context.Background(), "nothing") |
|
| 16 |
+ _, err = client.ContainerUnpause(t.Context(), "nothing", ContainerUnPauseOptions{})
|
|
| 17 | 17 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) |
| 18 | 18 |
|
| 19 |
- err = client.ContainerUnpause(context.Background(), "") |
|
| 19 |
+ _, err = client.ContainerUnpause(t.Context(), "", ContainerUnPauseOptions{})
|
|
| 20 | 20 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument)) |
| 21 | 21 |
assert.Check(t, is.ErrorContains(err, "value is empty")) |
| 22 | 22 |
|
| 23 |
- err = client.ContainerUnpause(context.Background(), " ") |
|
| 23 |
+ _, err = client.ContainerUnpause(t.Context(), " ", ContainerUnPauseOptions{})
|
|
| 24 | 24 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument)) |
| 25 | 25 |
assert.Check(t, is.ErrorContains(err, "value is empty")) |
| 26 | 26 |
} |
| ... | ... |
@@ -34,6 +33,6 @@ func TestContainerUnpause(t *testing.T) {
|
| 34 | 34 |
return mockResponse(http.StatusOK, nil, "")(req) |
| 35 | 35 |
})) |
| 36 | 36 |
assert.NilError(t, err) |
| 37 |
- err = client.ContainerUnpause(context.Background(), "container_id") |
|
| 37 |
+ _, err = client.ContainerUnpause(t.Context(), "container_id", ContainerUnPauseOptions{})
|
|
| 38 | 38 |
assert.NilError(t, err) |
| 39 | 39 |
} |
| ... | ... |
@@ -145,8 +145,10 @@ func (daemon *Daemon) CreateImageFromContainer(ctx context.Context, name string, |
| 145 | 145 |
} |
| 146 | 146 |
|
| 147 | 147 |
if !c.NoPause && !container.State.IsPaused() {
|
| 148 |
- daemon.containerPause(container) |
|
| 149 |
- defer daemon.containerUnpause(container) |
|
| 148 |
+ _ = daemon.containerPause(container) |
|
| 149 |
+ defer func() {
|
|
| 150 |
+ _ = daemon.containerUnpause(container) |
|
| 151 |
+ }() |
|
| 150 | 152 |
} |
| 151 | 153 |
|
| 152 | 154 |
if c.Config == nil {
|
| ... | ... |
@@ -366,7 +366,7 @@ func (s *DockerAPISuite) TestContainerAPIPause(c *testing.T) {
|
| 366 | 366 |
assert.NilError(c, err) |
| 367 | 367 |
defer apiClient.Close() |
| 368 | 368 |
|
| 369 |
- err = apiClient.ContainerPause(testutil.GetContext(c), ContainerID) |
|
| 369 |
+ _, err = apiClient.ContainerPause(testutil.GetContext(c), ContainerID, client.ContainerPauseOptions{})
|
|
| 370 | 370 |
assert.NilError(c, err) |
| 371 | 371 |
|
| 372 | 372 |
pausedContainers := getPaused(c) |
| ... | ... |
@@ -375,7 +375,7 @@ func (s *DockerAPISuite) TestContainerAPIPause(c *testing.T) {
|
| 375 | 375 |
c.Fatalf("there should be one paused container and not %d", len(pausedContainers))
|
| 376 | 376 |
} |
| 377 | 377 |
|
| 378 |
- err = apiClient.ContainerUnpause(testutil.GetContext(c), ContainerID) |
|
| 378 |
+ _, err = apiClient.ContainerUnpause(testutil.GetContext(c), ContainerID, client.ContainerUnPauseOptions{})
|
|
| 379 | 379 |
assert.NilError(c, err) |
| 380 | 380 |
|
| 381 | 381 |
pausedContainers = getPaused(c) |
| ... | ... |
@@ -713,7 +713,9 @@ func (s *DockerAPISuite) TestContainerAPIKill(c *testing.T) {
|
| 713 | 713 |
assert.NilError(c, err) |
| 714 | 714 |
defer apiClient.Close() |
| 715 | 715 |
|
| 716 |
- err = apiClient.ContainerKill(testutil.GetContext(c), name, "SIGKILL") |
|
| 716 |
+ _, err = apiClient.ContainerKill(testutil.GetContext(c), name, client.ContainerKillOptions{
|
|
| 717 |
+ Signal: "SIGKILL", |
|
| 718 |
+ }) |
|
| 717 | 719 |
assert.NilError(c, err) |
| 718 | 720 |
|
| 719 | 721 |
state := inspectField(c, name, "State.Running") |
| ... | ... |
@@ -728,7 +730,9 @@ func (s *DockerAPISuite) TestContainerAPIRestart(c *testing.T) {
|
| 728 | 728 |
defer apiClient.Close() |
| 729 | 729 |
|
| 730 | 730 |
timeout := 1 |
| 731 |
- err = apiClient.ContainerRestart(testutil.GetContext(c), name, client.ContainerStopOptions{Timeout: &timeout})
|
|
| 731 |
+ _, err = apiClient.ContainerRestart(testutil.GetContext(c), name, client.ContainerRestartOptions{
|
|
| 732 |
+ Timeout: &timeout, |
|
| 733 |
+ }) |
|
| 732 | 734 |
assert.NilError(c, err) |
| 733 | 735 |
|
| 734 | 736 |
assert.NilError(c, waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 15*time.Second))
|
| ... | ... |
@@ -743,7 +747,7 @@ func (s *DockerAPISuite) TestContainerAPIRestartNotimeoutParam(c *testing.T) {
|
| 743 | 743 |
assert.NilError(c, err) |
| 744 | 744 |
defer apiClient.Close() |
| 745 | 745 |
|
| 746 |
- err = apiClient.ContainerRestart(testutil.GetContext(c), name, client.ContainerStopOptions{})
|
|
| 746 |
+ _, err = apiClient.ContainerRestart(testutil.GetContext(c), name, client.ContainerRestartOptions{})
|
|
| 747 | 747 |
assert.NilError(c, err) |
| 748 | 748 |
|
| 749 | 749 |
assert.NilError(c, waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 15*time.Second))
|
| ... | ... |
@@ -769,12 +773,12 @@ func (s *DockerAPISuite) TestContainerAPIStart(c *testing.T) {
|
| 769 | 769 |
}) |
| 770 | 770 |
assert.NilError(c, err) |
| 771 | 771 |
|
| 772 |
- err = apiClient.ContainerStart(testutil.GetContext(c), name, client.ContainerStartOptions{})
|
|
| 772 |
+ _, err = apiClient.ContainerStart(testutil.GetContext(c), name, client.ContainerStartOptions{})
|
|
| 773 | 773 |
assert.NilError(c, err) |
| 774 | 774 |
|
| 775 | 775 |
// second call to start should give 304 |
| 776 | 776 |
// maybe add ContainerStartWithRaw to test it |
| 777 |
- err = apiClient.ContainerStart(testutil.GetContext(c), name, client.ContainerStartOptions{})
|
|
| 777 |
+ _, err = apiClient.ContainerStart(testutil.GetContext(c), name, client.ContainerStartOptions{})
|
|
| 778 | 778 |
assert.NilError(c, err) |
| 779 | 779 |
|
| 780 | 780 |
// TODO(tibor): figure out why this doesn't work on windows |
| ... | ... |
@@ -789,7 +793,7 @@ func (s *DockerAPISuite) TestContainerAPIStop(c *testing.T) {
|
| 789 | 789 |
assert.NilError(c, err) |
| 790 | 790 |
defer apiClient.Close() |
| 791 | 791 |
|
| 792 |
- err = apiClient.ContainerStop(testutil.GetContext(c), name, client.ContainerStopOptions{
|
|
| 792 |
+ _, err = apiClient.ContainerStop(testutil.GetContext(c), name, client.ContainerStopOptions{
|
|
| 793 | 793 |
Timeout: &timeout, |
| 794 | 794 |
}) |
| 795 | 795 |
assert.NilError(c, err) |
| ... | ... |
@@ -797,7 +801,7 @@ func (s *DockerAPISuite) TestContainerAPIStop(c *testing.T) {
|
| 797 | 797 |
|
| 798 | 798 |
// second call to start should give 304 |
| 799 | 799 |
// maybe add ContainerStartWithRaw to test it |
| 800 |
- err = apiClient.ContainerStop(testutil.GetContext(c), name, client.ContainerStopOptions{
|
|
| 800 |
+ _, err = apiClient.ContainerStop(testutil.GetContext(c), name, client.ContainerStopOptions{
|
|
| 801 | 801 |
Timeout: &timeout, |
| 802 | 802 |
}) |
| 803 | 803 |
assert.NilError(c, err) |
| ... | ... |
@@ -835,7 +839,7 @@ func (s *DockerAPISuite) TestContainerAPIDelete(c *testing.T) {
|
| 835 | 835 |
assert.NilError(c, err) |
| 836 | 836 |
defer apiClient.Close() |
| 837 | 837 |
|
| 838 |
- err = apiClient.ContainerRemove(testutil.GetContext(c), id, client.ContainerRemoveOptions{})
|
|
| 838 |
+ _, err = apiClient.ContainerRemove(testutil.GetContext(c), id, client.ContainerRemoveOptions{})
|
|
| 839 | 839 |
assert.NilError(c, err) |
| 840 | 840 |
} |
| 841 | 841 |
|
| ... | ... |
@@ -844,7 +848,7 @@ func (s *DockerAPISuite) TestContainerAPIDeleteNotExist(c *testing.T) {
|
| 844 | 844 |
assert.NilError(c, err) |
| 845 | 845 |
defer apiClient.Close() |
| 846 | 846 |
|
| 847 |
- err = apiClient.ContainerRemove(testutil.GetContext(c), "doesnotexist", client.ContainerRemoveOptions{})
|
|
| 847 |
+ _, err = apiClient.ContainerRemove(testutil.GetContext(c), "doesnotexist", client.ContainerRemoveOptions{})
|
|
| 848 | 848 |
assert.ErrorContains(c, err, "No such container: doesnotexist") |
| 849 | 849 |
} |
| 850 | 850 |
|
| ... | ... |
@@ -860,7 +864,7 @@ func (s *DockerAPISuite) TestContainerAPIDeleteForce(c *testing.T) {
|
| 860 | 860 |
assert.NilError(c, err) |
| 861 | 861 |
defer apiClient.Close() |
| 862 | 862 |
|
| 863 |
- err = apiClient.ContainerRemove(testutil.GetContext(c), id, removeOptions) |
|
| 863 |
+ _, err = apiClient.ContainerRemove(testutil.GetContext(c), id, removeOptions) |
|
| 864 | 864 |
assert.NilError(c, err) |
| 865 | 865 |
} |
| 866 | 866 |
|
| ... | ... |
@@ -886,7 +890,7 @@ func (s *DockerAPISuite) TestContainerAPIDeleteRemoveLinks(c *testing.T) {
|
| 886 | 886 |
assert.NilError(c, err) |
| 887 | 887 |
defer apiClient.Close() |
| 888 | 888 |
|
| 889 |
- err = apiClient.ContainerRemove(testutil.GetContext(c), "tlink2/tlink1", removeOptions) |
|
| 889 |
+ _, err = apiClient.ContainerRemove(testutil.GetContext(c), "tlink2/tlink1", removeOptions) |
|
| 890 | 890 |
assert.NilError(c, err) |
| 891 | 891 |
|
| 892 | 892 |
linksPostRm := inspectFieldJSON(c, id2, "HostConfig.Links") |
| ... | ... |
@@ -922,7 +926,7 @@ func (s *DockerAPISuite) TestContainerAPIDeleteRemoveVolume(c *testing.T) {
|
| 922 | 922 |
RemoveVolumes: true, |
| 923 | 923 |
} |
| 924 | 924 |
|
| 925 |
- err = apiClient.ContainerRemove(testutil.GetContext(c), id, removeOptions) |
|
| 925 |
+ _, err = apiClient.ContainerRemove(testutil.GetContext(c), id, removeOptions) |
|
| 926 | 926 |
assert.NilError(c, err) |
| 927 | 927 |
|
| 928 | 928 |
_, err = os.Stat(mnt.Source) |
| ... | ... |
@@ -957,7 +961,7 @@ func (s *DockerAPISuite) TestContainerAPIPostContainerStop(c *testing.T) {
|
| 957 | 957 |
assert.NilError(c, err) |
| 958 | 958 |
defer apiClient.Close() |
| 959 | 959 |
|
| 960 |
- err = apiClient.ContainerStop(testutil.GetContext(c), containerID, client.ContainerStopOptions{})
|
|
| 960 |
+ _, err = apiClient.ContainerStop(testutil.GetContext(c), containerID, client.ContainerStopOptions{})
|
|
| 961 | 961 |
assert.NilError(c, err) |
| 962 | 962 |
assert.NilError(c, waitInspect(containerID, "{{ .State.Running }}", "false", 60*time.Second))
|
| 963 | 963 |
} |
| ... | ... |
@@ -1108,7 +1112,7 @@ func (s *DockerAPISuite) TestContainerAPIDeleteWithEmptyName(c *testing.T) {
|
| 1108 | 1108 |
assert.NilError(c, err) |
| 1109 | 1109 |
defer apiClient.Close() |
| 1110 | 1110 |
|
| 1111 |
- err = apiClient.ContainerRemove(testutil.GetContext(c), "", client.ContainerRemoveOptions{})
|
|
| 1111 |
+ _, err = apiClient.ContainerRemove(testutil.GetContext(c), "", client.ContainerRemoveOptions{})
|
|
| 1112 | 1112 |
assert.Check(c, is.ErrorType(err, cerrdefs.IsInvalidArgument)) |
| 1113 | 1113 |
assert.Check(c, is.ErrorContains(err, "value is empty")) |
| 1114 | 1114 |
} |
| ... | ... |
@@ -1138,7 +1142,7 @@ func (s *DockerAPISuite) TestContainerAPIStatsWithNetworkDisabled(c *testing.T) |
| 1138 | 1138 |
assert.NilError(c, err) |
| 1139 | 1139 |
defer cli.DockerCmd(c, "rm", "-f", name) |
| 1140 | 1140 |
|
| 1141 |
- err = apiClient.ContainerStart(testutil.GetContext(c), ctr.ID, client.ContainerStartOptions{})
|
|
| 1141 |
+ _, err = apiClient.ContainerStart(testutil.GetContext(c), ctr.ID, client.ContainerStartOptions{})
|
|
| 1142 | 1142 |
assert.NilError(c, err) |
| 1143 | 1143 |
cli.WaitRun(c, ctr.ID) |
| 1144 | 1144 |
|
| ... | ... |
@@ -1672,11 +1676,11 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsCreate(c *testing.T) {
|
| 1672 | 1672 |
assert.Check(c, is.Equal(tc.expected.Mode, mountPoint.Mode)) |
| 1673 | 1673 |
assert.Check(c, is.Equal(tc.expected.Destination, mountPoint.Destination)) |
| 1674 | 1674 |
|
| 1675 |
- err = apiclient.ContainerStart(ctx, ctr.ID, client.ContainerStartOptions{})
|
|
| 1675 |
+ _, err = apiclient.ContainerStart(ctx, ctr.ID, client.ContainerStartOptions{})
|
|
| 1676 | 1676 |
assert.NilError(c, err) |
| 1677 | 1677 |
poll.WaitOn(c, containerExit(ctx, apiclient, ctr.ID), poll.WithDelay(time.Second)) |
| 1678 | 1678 |
|
| 1679 |
- err = apiclient.ContainerRemove(ctx, ctr.ID, client.ContainerRemoveOptions{
|
|
| 1679 |
+ _, err = apiclient.ContainerRemove(ctx, ctr.ID, client.ContainerRemoveOptions{
|
|
| 1680 | 1680 |
RemoveVolumes: true, |
| 1681 | 1681 |
Force: true, |
| 1682 | 1682 |
}) |
| ... | ... |
@@ -65,13 +65,14 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsBindNamedPipe(c *testing.T |
| 65 | 65 |
Target: containerPipeName, |
| 66 | 66 |
}, |
| 67 | 67 |
}, |
| 68 |
+ }, |
|
| 69 |
+ NetworkingConfig: &network.NetworkingConfig{},
|
|
| 70 |
+ Name: name, |
|
| 68 | 71 |
}, |
| 69 |
- NetworkingConfig: &network.NetworkingConfig{},
|
|
| 70 |
- Name: name, |
|
| 71 |
- }) |
|
| 72 |
+ ) |
|
| 72 | 73 |
assert.NilError(c, err) |
| 73 | 74 |
|
| 74 |
- err = apiClient.ContainerStart(ctx, name, client.ContainerStartOptions{})
|
|
| 75 |
+ _, err = apiClient.ContainerStart(ctx, name, client.ContainerStartOptions{})
|
|
| 75 | 76 |
assert.NilError(c, err) |
| 76 | 77 |
|
| 77 | 78 |
err = <-ch |
| ... | ... |
@@ -457,7 +457,7 @@ func (s *DockerCLIEventSuite) TestEventsResize(c *testing.T) {
|
| 457 | 457 |
Height: 80, |
| 458 | 458 |
Width: 24, |
| 459 | 459 |
} |
| 460 |
- err = apiClient.ContainerResize(testutil.GetContext(c), cID, options) |
|
| 460 |
+ _, err = apiClient.ContainerResize(testutil.GetContext(c), cID, options) |
|
| 461 | 461 |
assert.NilError(c, err) |
| 462 | 462 |
|
| 463 | 463 |
cli.DockerCmd(c, "stop", cID) |
| ... | ... |
@@ -116,7 +116,7 @@ func TestCheckpoint(t *testing.T) {
|
| 116 | 116 |
|
| 117 | 117 |
// Restore the container from a second checkpoint. |
| 118 | 118 |
t.Log("Restore the container")
|
| 119 |
- err = apiClient.ContainerStart(ctx, cID, client.ContainerStartOptions{
|
|
| 119 |
+ _, err = apiClient.ContainerStart(ctx, cID, client.ContainerStartOptions{
|
|
| 120 | 120 |
CheckpointID: "test2", |
| 121 | 121 |
}) |
| 122 | 122 |
assert.NilError(t, err) |
| ... | ... |
@@ -135,7 +135,7 @@ func TestCreateByImageID(t *testing.T) {
|
| 135 | 135 |
assert.Check(t, resp.ID != "") |
| 136 | 136 |
} |
| 137 | 137 |
// cleanup the container if one was created. |
| 138 |
- _ = apiClient.ContainerRemove(ctx, resp.ID, client.ContainerRemoveOptions{Force: true})
|
|
| 138 |
+ _, _ = apiClient.ContainerRemove(ctx, resp.ID, client.ContainerRemoveOptions{Force: true})
|
|
| 139 | 139 |
}) |
| 140 | 140 |
} |
| 141 | 141 |
} |
| ... | ... |
@@ -300,11 +300,11 @@ func TestCreateWithCustomMaskedPaths(t *testing.T) {
|
| 300 | 300 |
assert.DeepEqual(t, inspect.Container.HostConfig.MaskedPaths, tc.expected) |
| 301 | 301 |
|
| 302 | 302 |
// Start the container. |
| 303 |
- err = apiClient.ContainerStart(ctx, ctr.ID, client.ContainerStartOptions{})
|
|
| 303 |
+ _, err = apiClient.ContainerStart(ctx, ctr.ID, client.ContainerStartOptions{})
|
|
| 304 | 304 |
assert.NilError(t, err) |
| 305 | 305 |
|
| 306 | 306 |
// It should die down by itself, but stop it to be sure. |
| 307 |
- err = apiClient.ContainerStop(ctx, ctr.ID, client.ContainerStopOptions{})
|
|
| 307 |
+ _, err = apiClient.ContainerStop(ctx, ctr.ID, client.ContainerStopOptions{})
|
|
| 308 | 308 |
assert.NilError(t, err) |
| 309 | 309 |
|
| 310 | 310 |
inspect, err = apiClient.ContainerInspect(ctx, ctr.ID, client.ContainerInspectOptions{})
|
| ... | ... |
@@ -371,11 +371,11 @@ func TestCreateWithCustomReadonlyPaths(t *testing.T) {
|
| 371 | 371 |
assert.DeepEqual(t, ctrInspect.Container.HostConfig.ReadonlyPaths, tc.expected) |
| 372 | 372 |
|
| 373 | 373 |
// Start the container. |
| 374 |
- err = apiClient.ContainerStart(ctx, ctr.ID, client.ContainerStartOptions{})
|
|
| 374 |
+ _, err = apiClient.ContainerStart(ctx, ctr.ID, client.ContainerStartOptions{})
|
|
| 375 | 375 |
assert.NilError(t, err) |
| 376 | 376 |
|
| 377 | 377 |
// It should die down by itself, but stop it to be sure. |
| 378 |
- err = apiClient.ContainerStop(ctx, ctr.ID, client.ContainerStopOptions{})
|
|
| 378 |
+ _, err = apiClient.ContainerStop(ctx, ctr.ID, client.ContainerStopOptions{})
|
|
| 379 | 379 |
assert.NilError(t, err) |
| 380 | 380 |
|
| 381 | 381 |
ctrInspect, err = apiClient.ContainerInspect(ctx, ctr.ID, client.ContainerInspectOptions{})
|
| ... | ... |
@@ -488,7 +488,7 @@ func TestCreateTmpfsOverrideAnonymousVolume(t *testing.T) {
|
| 488 | 488 |
) |
| 489 | 489 |
|
| 490 | 490 |
defer func() {
|
| 491 |
- err := apiClient.ContainerRemove(ctx, id, client.ContainerRemoveOptions{Force: true})
|
|
| 491 |
+ _, err := apiClient.ContainerRemove(ctx, id, client.ContainerRemoveOptions{Force: true})
|
|
| 492 | 492 |
assert.NilError(t, err) |
| 493 | 493 |
}() |
| 494 | 494 |
|
| ... | ... |
@@ -499,7 +499,8 @@ func TestCreateTmpfsOverrideAnonymousVolume(t *testing.T) {
|
| 499 | 499 |
assert.Assert(t, is.Len(inspect.Container.Mounts, 0)) |
| 500 | 500 |
|
| 501 | 501 |
chWait, chErr := apiClient.ContainerWait(ctx, id, container.WaitConditionNextExit) |
| 502 |
- assert.NilError(t, apiClient.ContainerStart(ctx, id, client.ContainerStartOptions{}))
|
|
| 502 |
+ _, err = apiClient.ContainerStart(ctx, id, client.ContainerStartOptions{})
|
|
| 503 |
+ assert.NilError(t, err) |
|
| 503 | 504 |
|
| 504 | 505 |
timeout := time.NewTimer(30 * time.Second) |
| 505 | 506 |
defer timeout.Stop() |
| ... | ... |
@@ -49,7 +49,7 @@ func TestContainerStartOnDaemonRestart(t *testing.T) {
|
| 49 | 49 |
cID := container.Create(ctx, t, c) |
| 50 | 50 |
defer c.ContainerRemove(ctx, cID, client.ContainerRemoveOptions{Force: true})
|
| 51 | 51 |
|
| 52 |
- err := c.ContainerStart(ctx, cID, client.ContainerStartOptions{})
|
|
| 52 |
+ _, err := c.ContainerStart(ctx, cID, client.ContainerStartOptions{})
|
|
| 53 | 53 |
assert.Check(t, err, "error starting test container") |
| 54 | 54 |
|
| 55 | 55 |
inspect, err := c.ContainerInspect(ctx, cID, client.ContainerInspectOptions{})
|
| ... | ... |
@@ -68,7 +68,7 @@ func TestContainerStartOnDaemonRestart(t *testing.T) {
|
| 68 | 68 |
|
| 69 | 69 |
d.Start(t, "--iptables=false", "--ip6tables=false") |
| 70 | 70 |
|
| 71 |
- err = c.ContainerStart(ctx, cID, client.ContainerStartOptions{})
|
|
| 71 |
+ _, err = c.ContainerStart(ctx, cID, client.ContainerStartOptions{})
|
|
| 72 | 72 |
assert.Check(t, err, "failed to start test container") |
| 73 | 73 |
} |
| 74 | 74 |
|
| ... | ... |
@@ -291,6 +291,9 @@ func TestHardRestartWhenContainerIsRunning(t *testing.T) {
|
| 291 | 291 |
} |
| 292 | 292 |
|
| 293 | 293 |
stopTimeout := 0 |
| 294 |
- assert.Assert(t, apiClient.ContainerStop(ctx, onFailure, client.ContainerStopOptions{Timeout: &stopTimeout}))
|
|
| 294 |
+ _, err = apiClient.ContainerStop(ctx, onFailure, client.ContainerStopOptions{
|
|
| 295 |
+ Timeout: &stopTimeout, |
|
| 296 |
+ }) |
|
| 297 |
+ assert.NilError(t, err) |
|
| 295 | 298 |
}) |
| 296 | 299 |
} |
| ... | ... |
@@ -36,7 +36,7 @@ func TestContainerKillOnDaemonStart(t *testing.T) {
|
| 36 | 36 |
// Sadly this means the test will take longer, but at least this test can be parallelized. |
| 37 | 37 |
id := container.Run(ctx, t, apiClient, container.WithCmd("/bin/sh", "-c", "while true; do echo hello; sleep 1; done"))
|
| 38 | 38 |
defer func() {
|
| 39 |
- err := apiClient.ContainerRemove(ctx, id, client.ContainerRemoveOptions{Force: true})
|
|
| 39 |
+ _, err := apiClient.ContainerRemove(ctx, id, client.ContainerRemoveOptions{Force: true})
|
|
| 40 | 40 |
assert.NilError(t, err) |
| 41 | 41 |
}() |
| 42 | 42 |
|
| ... | ... |
@@ -80,7 +80,7 @@ func TestNetworkStateCleanupOnDaemonStart(t *testing.T) {
|
| 80 | 80 |
container.WithPortMap(network.PortMap{mappedPort: {{}}}),
|
| 81 | 81 |
container.WithCmd("/bin/sh", "-c", "while true; do echo hello; sleep 1; done"))
|
| 82 | 82 |
defer func() {
|
| 83 |
- err := apiClient.ContainerRemove(ctx, cid, client.ContainerRemoveOptions{Force: true})
|
|
| 83 |
+ _, err := apiClient.ContainerRemove(ctx, cid, client.ContainerRemoveOptions{Force: true})
|
|
| 84 | 84 |
assert.NilError(t, err) |
| 85 | 85 |
}() |
| 86 | 86 |
|
| ... | ... |
@@ -100,7 +100,7 @@ func TestWindowsDevices(t *testing.T) {
|
| 100 | 100 |
// remove this skip.If and validate the expected behaviour under Hyper-V. |
| 101 | 101 |
skip.If(t, d.isolation == containertypes.IsolationHyperV && !d.expectedStartFailure, "FIXME. HyperV isolation setup is probably incorrect in the test") |
| 102 | 102 |
|
| 103 |
- err := apiClient.ContainerStart(ctx, id, client.ContainerStartOptions{})
|
|
| 103 |
+ _, err := apiClient.ContainerStart(ctx, id, client.ContainerStartOptions{})
|
|
| 104 | 104 |
if d.expectedStartFailure {
|
| 105 | 105 |
assert.ErrorContains(t, err, d.expectedStartFailureMessage) |
| 106 | 106 |
return |
| ... | ... |
@@ -273,7 +273,7 @@ func TestExecResize(t *testing.T) {
|
| 273 | 273 |
// Error response from daemon: No such exec instance: cc728a332d3f594249fb7ee9adb3bb12a59a5d1776f8f6dedc56355364361711 |
| 274 | 274 |
skip.If(t, testEnv.DaemonInfo.OSType == "windows" && !testEnv.RuntimeIsWindowsContainerd(), "FIXME. Windows + builtin returns a NotFound instead of a Conflict error") |
| 275 | 275 |
|
| 276 |
- err := apiClient.ContainerKill(ctx, cID, "SIGKILL") |
|
| 276 |
+ _, err := apiClient.ContainerKill(ctx, cID, client.ContainerKillOptions{})
|
|
| 277 | 277 |
assert.NilError(t, err) |
| 278 | 278 |
|
| 279 | 279 |
_, err = apiClient.ExecResize(ctx, execID, client.ExecResizeOptions{
|
| ... | ... |
@@ -76,14 +76,18 @@ while true; do sleep 1; done |
| 76 | 76 |
defer cancel() |
| 77 | 77 |
poll.WaitOn(t, pollForHealthStatus(ctxPoll, apiClient, id, "healthy")) |
| 78 | 78 |
|
| 79 |
- err := apiClient.ContainerKill(ctx, id, "SIGUSR1") |
|
| 79 |
+ _, err := apiClient.ContainerKill(ctx, id, client.ContainerKillOptions{
|
|
| 80 |
+ Signal: "SIGUSR1", |
|
| 81 |
+ }) |
|
| 80 | 82 |
assert.NilError(t, err) |
| 81 | 83 |
|
| 82 | 84 |
ctxPoll, cancel = context.WithTimeout(ctx, 30*time.Second) |
| 83 | 85 |
defer cancel() |
| 84 | 86 |
poll.WaitOn(t, pollForHealthStatus(ctxPoll, apiClient, id, "unhealthy")) |
| 85 | 87 |
|
| 86 |
- err = apiClient.ContainerKill(ctx, id, "SIGUSR1") |
|
| 88 |
+ _, err = apiClient.ContainerKill(ctx, id, client.ContainerKillOptions{
|
|
| 89 |
+ Signal: "SIGUSR1", |
|
| 90 |
+ }) |
|
| 87 | 91 |
assert.NilError(t, err) |
| 88 | 92 |
|
| 89 | 93 |
ctxPoll, cancel = context.WithTimeout(ctx, 30*time.Second) |
| ... | ... |
@@ -71,7 +71,7 @@ func testIpcNonePrivateShareable(t *testing.T, mode string, mustBeMounted bool, |
| 71 | 71 |
assert.NilError(t, err) |
| 72 | 72 |
assert.Check(t, is.Equal(len(resp.Warnings), 0)) |
| 73 | 73 |
|
| 74 |
- err = apiClient.ContainerStart(ctx, resp.ID, client.ContainerStartOptions{})
|
|
| 74 |
+ _, err = apiClient.ContainerStart(ctx, resp.ID, client.ContainerStartOptions{})
|
|
| 75 | 75 |
assert.NilError(t, err) |
| 76 | 76 |
|
| 77 | 77 |
// get major:minor pair for /dev/shm from container's /proc/self/mountinfo |
| ... | ... |
@@ -146,7 +146,7 @@ func testIpcContainer(t *testing.T, donorMode string, mustWork bool) {
|
| 146 | 146 |
assert.Check(t, is.Equal(len(resp.Warnings), 0)) |
| 147 | 147 |
name1 := resp.ID |
| 148 | 148 |
|
| 149 |
- err = apiClient.ContainerStart(ctx, name1, client.ContainerStartOptions{})
|
|
| 149 |
+ _, err = apiClient.ContainerStart(ctx, name1, client.ContainerStartOptions{})
|
|
| 150 | 150 |
assert.NilError(t, err) |
| 151 | 151 |
|
| 152 | 152 |
// create and start the second container |
| ... | ... |
@@ -159,7 +159,7 @@ func testIpcContainer(t *testing.T, donorMode string, mustWork bool) {
|
| 159 | 159 |
assert.Check(t, is.Equal(len(resp.Warnings), 0)) |
| 160 | 160 |
name2 := resp.ID |
| 161 | 161 |
|
| 162 |
- err = apiClient.ContainerStart(ctx, name2, client.ContainerStartOptions{})
|
|
| 162 |
+ _, err = apiClient.ContainerStart(ctx, name2, client.ContainerStartOptions{})
|
|
| 163 | 163 |
if !mustWork {
|
| 164 | 164 |
// start should fail with a specific error |
| 165 | 165 |
assert.Check(t, is.ErrorContains(err, "non-shareable IPC")) |
| ... | ... |
@@ -218,7 +218,7 @@ func TestAPIIpcModeHost(t *testing.T) {
|
| 218 | 218 |
assert.Check(t, is.Equal(len(resp.Warnings), 0)) |
| 219 | 219 |
name := resp.ID |
| 220 | 220 |
|
| 221 |
- err = apiClient.ContainerStart(ctx, name, client.ContainerStartOptions{})
|
|
| 221 |
+ _, err = apiClient.ContainerStart(ctx, name, client.ContainerStartOptions{})
|
|
| 222 | 222 |
assert.NilError(t, err) |
| 223 | 223 |
|
| 224 | 224 |
// check that IPC is shared |
| ... | ... |
@@ -256,7 +256,7 @@ func testDaemonIpcPrivateShareable(t *testing.T, mustBeShared bool, arg ...strin |
| 256 | 256 |
assert.NilError(t, err) |
| 257 | 257 |
assert.Check(t, is.Equal(len(resp.Warnings), 0)) |
| 258 | 258 |
|
| 259 |
- err = c.ContainerStart(ctx, resp.ID, client.ContainerStartOptions{})
|
|
| 259 |
+ _, err = c.ContainerStart(ctx, resp.ID, client.ContainerStartOptions{})
|
|
| 260 | 260 |
assert.NilError(t, err) |
| 261 | 261 |
|
| 262 | 262 |
// get major:minor pair for /dev/shm from container's /proc/self/mountinfo |
| ... | ... |
@@ -20,12 +20,16 @@ func TestKillContainerInvalidSignal(t *testing.T) {
|
| 20 | 20 |
apiClient := testEnv.APIClient() |
| 21 | 21 |
id := container.Run(ctx, t, apiClient) |
| 22 | 22 |
|
| 23 |
- err := apiClient.ContainerKill(ctx, id, "0") |
|
| 23 |
+ _, err := apiClient.ContainerKill(ctx, id, client.ContainerKillOptions{
|
|
| 24 |
+ Signal: "0", |
|
| 25 |
+ }) |
|
| 24 | 26 |
assert.ErrorContains(t, err, "Error response from daemon:") |
| 25 | 27 |
assert.ErrorContains(t, err, "nvalid signal: 0") // match "(I|i)nvalid" case-insensitive to allow testing against older daemons. |
| 26 | 28 |
poll.WaitOn(t, container.IsInState(ctx, apiClient, id, containertypes.StateRunning)) |
| 27 | 29 |
|
| 28 |
- err = apiClient.ContainerKill(ctx, id, "SIG42") |
|
| 30 |
+ _, err = apiClient.ContainerKill(ctx, id, client.ContainerKillOptions{
|
|
| 31 |
+ Signal: "SIG42", |
|
| 32 |
+ }) |
|
| 29 | 33 |
assert.ErrorContains(t, err, "Error response from daemon:") |
| 30 | 34 |
assert.ErrorContains(t, err, "nvalid signal: SIG42") // match "(I|i)nvalid" case-insensitive to allow testing against older daemons. |
| 31 | 35 |
poll.WaitOn(t, container.IsInState(ctx, apiClient, id, containertypes.StateRunning)) |
| ... | ... |
@@ -71,7 +75,9 @@ func TestKillContainer(t *testing.T) {
|
| 71 | 71 |
skip.If(t, testEnv.DaemonInfo.OSType == tc.skipOs, "Windows does not support SIGWINCH") |
| 72 | 72 |
ctx := testutil.StartSpan(ctx, t) |
| 73 | 73 |
id := container.Run(ctx, t, apiClient) |
| 74 |
- err := apiClient.ContainerKill(ctx, id, tc.signal) |
|
| 74 |
+ _, err := apiClient.ContainerKill(ctx, id, client.ContainerKillOptions{
|
|
| 75 |
+ Signal: tc.signal, |
|
| 76 |
+ }) |
|
| 75 | 77 |
assert.NilError(t, err) |
| 76 | 78 |
|
| 77 | 79 |
poll.WaitOn(t, container.IsInState(ctx, apiClient, id, tc.status), pollOpts...) |
| ... | ... |
@@ -112,8 +118,11 @@ func TestKillWithStopSignalAndRestartPolicies(t *testing.T) {
|
| 112 | 112 |
container.WithRestartPolicy(containertypes.RestartPolicyAlways), |
| 113 | 113 |
func(c *container.TestContainerConfig) {
|
| 114 | 114 |
c.Config.StopSignal = tc.stopsignal |
| 115 |
- }) |
|
| 116 |
- err := apiClient.ContainerKill(ctx, id, "TERM") |
|
| 115 |
+ }, |
|
| 116 |
+ ) |
|
| 117 |
+ _, err := apiClient.ContainerKill(ctx, id, client.ContainerKillOptions{
|
|
| 118 |
+ Signal: "TERM", |
|
| 119 |
+ }) |
|
| 117 | 120 |
assert.NilError(t, err) |
| 118 | 121 |
|
| 119 | 122 |
poll.WaitOn(t, container.IsInState(ctx, apiClient, id, tc.status), pollOpts...) |
| ... | ... |
@@ -125,7 +134,7 @@ func TestKillStoppedContainer(t *testing.T) {
|
| 125 | 125 |
ctx := setupTest(t) |
| 126 | 126 |
apiClient := testEnv.APIClient() |
| 127 | 127 |
id := container.Create(ctx, t, apiClient) |
| 128 |
- err := apiClient.ContainerKill(ctx, id, "SIGKILL") |
|
| 128 |
+ _, err := apiClient.ContainerKill(ctx, id, client.ContainerKillOptions{})
|
|
| 129 | 129 |
assert.ErrorContains(t, err, "") |
| 130 | 130 |
assert.ErrorContains(t, err, "is not running") |
| 131 | 131 |
} |
| ... | ... |
@@ -141,7 +150,7 @@ func TestKillDifferentUserContainer(t *testing.T) {
|
| 141 | 141 |
c.Config.User = "daemon" |
| 142 | 142 |
}) |
| 143 | 143 |
|
| 144 |
- err := apiClient.ContainerKill(ctx, id, "SIGKILL") |
|
| 144 |
+ _, err := apiClient.ContainerKill(ctx, id, client.ContainerKillOptions{})
|
|
| 145 | 145 |
assert.NilError(t, err) |
| 146 | 146 |
poll.WaitOn(t, container.IsInState(ctx, apiClient, id, containertypes.StateExited)) |
| 147 | 147 |
} |
| ... | ... |
@@ -74,7 +74,7 @@ func TestContainerNetworkMountsNoChown(t *testing.T) {
|
| 74 | 74 |
}) |
| 75 | 75 |
assert.NilError(t, err) |
| 76 | 76 |
// container will exit immediately because of no tty, but we only need the start sequence to test the condition |
| 77 |
- err = cli.ContainerStart(ctx, ctrCreate.ID, client.ContainerStartOptions{})
|
|
| 77 |
+ _, err = cli.ContainerStart(ctx, ctrCreate.ID, client.ContainerStartOptions{})
|
|
| 78 | 78 |
assert.NilError(t, err) |
| 79 | 79 |
|
| 80 | 80 |
// Check that host-located bind mount network file did not change ownership when the container was started |
| ... | ... |
@@ -202,7 +202,7 @@ func TestMountDaemonRoot(t *testing.T) {
|
| 202 | 202 |
} |
| 203 | 203 |
|
| 204 | 204 |
defer func() {
|
| 205 |
- if err := apiClient.ContainerRemove(ctx, c.ID, client.ContainerRemoveOptions{Force: true}); err != nil {
|
|
| 205 |
+ if _, err := apiClient.ContainerRemove(ctx, c.ID, client.ContainerRemoveOptions{Force: true}); err != nil {
|
|
| 206 | 206 |
panic(err) |
| 207 | 207 |
} |
| 208 | 208 |
}() |
| ... | ... |
@@ -27,14 +27,14 @@ func TestPause(t *testing.T) {
|
| 27 | 27 |
|
| 28 | 28 |
since := request.DaemonUnixTime(ctx, t, apiClient, testEnv) |
| 29 | 29 |
|
| 30 |
- err := apiClient.ContainerPause(ctx, cID) |
|
| 30 |
+ _, err := apiClient.ContainerPause(ctx, cID, client.ContainerPauseOptions{})
|
|
| 31 | 31 |
assert.NilError(t, err) |
| 32 | 32 |
|
| 33 | 33 |
inspect, err := apiClient.ContainerInspect(ctx, cID, client.ContainerInspectOptions{})
|
| 34 | 34 |
assert.NilError(t, err) |
| 35 | 35 |
assert.Check(t, is.Equal(true, inspect.Container.State.Paused)) |
| 36 | 36 |
|
| 37 |
- err = apiClient.ContainerUnpause(ctx, cID) |
|
| 37 |
+ _, err = apiClient.ContainerUnpause(ctx, cID, client.ContainerUnPauseOptions{})
|
|
| 38 | 38 |
assert.NilError(t, err) |
| 39 | 39 |
|
| 40 | 40 |
until := request.DaemonUnixTime(ctx, t, apiClient, testEnv) |
| ... | ... |
@@ -54,7 +54,7 @@ func TestPauseFailsOnWindowsServerContainers(t *testing.T) {
|
| 54 | 54 |
apiClient := testEnv.APIClient() |
| 55 | 55 |
|
| 56 | 56 |
cID := container.Run(ctx, t, apiClient) |
| 57 |
- err := apiClient.ContainerPause(ctx, cID) |
|
| 57 |
+ _, err := apiClient.ContainerPause(ctx, cID, client.ContainerPauseOptions{})
|
|
| 58 | 58 |
assert.Check(t, is.ErrorContains(err, cerrdefs.ErrNotImplemented.Error())) |
| 59 | 59 |
} |
| 60 | 60 |
|
| ... | ... |
@@ -65,10 +65,10 @@ func TestPauseStopPausedContainer(t *testing.T) {
|
| 65 | 65 |
apiClient := testEnv.APIClient() |
| 66 | 66 |
|
| 67 | 67 |
cID := container.Run(ctx, t, apiClient) |
| 68 |
- err := apiClient.ContainerPause(ctx, cID) |
|
| 68 |
+ _, err := apiClient.ContainerPause(ctx, cID, client.ContainerPauseOptions{})
|
|
| 69 | 69 |
assert.NilError(t, err) |
| 70 | 70 |
|
| 71 |
- err = apiClient.ContainerStop(ctx, cID, client.ContainerStopOptions{})
|
|
| 71 |
+ _, err = apiClient.ContainerStop(ctx, cID, client.ContainerStopOptions{})
|
|
| 72 | 72 |
assert.NilError(t, err) |
| 73 | 73 |
|
| 74 | 74 |
poll.WaitOn(t, container.IsStopped(ctx, apiClient, cID)) |
| ... | ... |
@@ -50,7 +50,7 @@ func TestPIDModeContainer(t *testing.T) {
|
| 50 | 50 |
ctr, err := container.CreateFromConfig(ctx, apiClient, container.NewTestConfig(container.WithPIDMode("container:"+pidCtrName)))
|
| 51 | 51 |
assert.NilError(t, err, "should not produce an error when creating, only when starting") |
| 52 | 52 |
|
| 53 |
- err = apiClient.ContainerStart(ctx, ctr.ID, client.ContainerStartOptions{})
|
|
| 53 |
+ _, err = apiClient.ContainerStart(ctx, ctr.ID, client.ContainerStartOptions{})
|
|
| 54 | 54 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal), "should produce a System error when starting an existing container from an invalid state") |
| 55 | 55 |
assert.Check(t, is.ErrorContains(err, "failed to join PID namespace")) |
| 56 | 56 |
assert.Check(t, is.ErrorContains(err, cPIDContainerID+" is not running")) |
| ... | ... |
@@ -63,7 +63,7 @@ func TestPIDModeContainer(t *testing.T) {
|
| 63 | 63 |
ctr, err := container.CreateFromConfig(ctx, apiClient, container.NewTestConfig(container.WithPIDMode("container:"+pidCtrName)))
|
| 64 | 64 |
assert.NilError(t, err) |
| 65 | 65 |
|
| 66 |
- err = apiClient.ContainerStart(ctx, ctr.ID, client.ContainerStartOptions{})
|
|
| 66 |
+ _, err = apiClient.ContainerStart(ctx, ctr.ID, client.ContainerStartOptions{})
|
|
| 67 | 67 |
assert.Check(t, err) |
| 68 | 68 |
}) |
| 69 | 69 |
} |
| ... | ... |
@@ -39,7 +39,7 @@ func TestRemoveContainerWithRemovedVolume(t *testing.T) {
|
| 39 | 39 |
err := os.RemoveAll(tempDir.Path()) |
| 40 | 40 |
assert.NilError(t, err) |
| 41 | 41 |
|
| 42 |
- err = apiClient.ContainerRemove(ctx, cID, client.ContainerRemoveOptions{
|
|
| 42 |
+ _, err = apiClient.ContainerRemove(ctx, cID, client.ContainerRemoveOptions{
|
|
| 43 | 43 |
RemoveVolumes: true, |
| 44 | 44 |
}) |
| 45 | 45 |
assert.NilError(t, err) |
| ... | ... |
@@ -66,7 +66,7 @@ func TestRemoveContainerWithVolume(t *testing.T) {
|
| 66 | 66 |
_, err = apiClient.VolumeInspect(ctx, volName, client.VolumeInspectOptions{})
|
| 67 | 67 |
assert.NilError(t, err) |
| 68 | 68 |
|
| 69 |
- err = apiClient.ContainerRemove(ctx, cID, client.ContainerRemoveOptions{
|
|
| 69 |
+ _, err = apiClient.ContainerRemove(ctx, cID, client.ContainerRemoveOptions{
|
|
| 70 | 70 |
Force: true, |
| 71 | 71 |
RemoveVolumes: true, |
| 72 | 72 |
}) |
| ... | ... |
@@ -82,7 +82,7 @@ func TestRemoveContainerRunning(t *testing.T) {
|
| 82 | 82 |
|
| 83 | 83 |
cID := container.Run(ctx, t, apiClient) |
| 84 | 84 |
|
| 85 |
- err := apiClient.ContainerRemove(ctx, cID, client.ContainerRemoveOptions{})
|
|
| 85 |
+ _, err := apiClient.ContainerRemove(ctx, cID, client.ContainerRemoveOptions{})
|
|
| 86 | 86 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsConflict)) |
| 87 | 87 |
assert.Check(t, is.ErrorContains(err, "container is running")) |
| 88 | 88 |
} |
| ... | ... |
@@ -93,7 +93,7 @@ func TestRemoveContainerForceRemoveRunning(t *testing.T) {
|
| 93 | 93 |
|
| 94 | 94 |
cID := container.Run(ctx, t, apiClient) |
| 95 | 95 |
|
| 96 |
- err := apiClient.ContainerRemove(ctx, cID, client.ContainerRemoveOptions{
|
|
| 96 |
+ _, err := apiClient.ContainerRemove(ctx, cID, client.ContainerRemoveOptions{
|
|
| 97 | 97 |
Force: true, |
| 98 | 98 |
}) |
| 99 | 99 |
assert.NilError(t, err) |
| ... | ... |
@@ -103,7 +103,7 @@ func TestRemoveInvalidContainer(t *testing.T) {
|
| 103 | 103 |
ctx := setupTest(t) |
| 104 | 104 |
apiClient := testEnv.APIClient() |
| 105 | 105 |
|
| 106 |
- err := apiClient.ContainerRemove(ctx, "unknown", client.ContainerRemoveOptions{})
|
|
| 106 |
+ _, err := apiClient.ContainerRemove(ctx, "unknown", client.ContainerRemoveOptions{})
|
|
| 107 | 107 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound)) |
| 108 | 108 |
assert.Check(t, is.ErrorContains(err, "No such container")) |
| 109 | 109 |
} |
| ... | ... |
@@ -32,7 +32,7 @@ func TestRenameLinkedContainer(t *testing.T) {
|
| 32 | 32 |
|
| 33 | 33 |
container.Run(ctx, t, apiClient, container.WithName(aName)) |
| 34 | 34 |
|
| 35 |
- err = apiClient.ContainerRemove(ctx, bID, client.ContainerRemoveOptions{Force: true})
|
|
| 35 |
+ _, err = apiClient.ContainerRemove(ctx, bID, client.ContainerRemoveOptions{Force: true})
|
|
| 36 | 36 |
assert.NilError(t, err) |
| 37 | 37 |
|
| 38 | 38 |
bID = container.Run(ctx, t, apiClient, container.WithName(bName), container.WithLinks(aName)) |
| ... | ... |
@@ -129,9 +129,9 @@ func TestRenameAnonymousContainer(t *testing.T) {
|
| 129 | 129 |
assert.NilError(t, err) |
| 130 | 130 |
// Stop/Start the container to get registered |
| 131 | 131 |
// FIXME(vdemeester) this is a really weird behavior as it fails otherwise |
| 132 |
- err = apiClient.ContainerStop(ctx, container1Name, client.ContainerStopOptions{})
|
|
| 132 |
+ _, err = apiClient.ContainerStop(ctx, container1Name, client.ContainerStopOptions{})
|
|
| 133 | 133 |
assert.NilError(t, err) |
| 134 |
- err = apiClient.ContainerStart(ctx, container1Name, client.ContainerStartOptions{})
|
|
| 134 |
+ _, err = apiClient.ContainerStart(ctx, container1Name, client.ContainerStartOptions{})
|
|
| 135 | 135 |
assert.NilError(t, err) |
| 136 | 136 |
|
| 137 | 137 |
count := "-c" |
| ... | ... |
@@ -22,7 +22,7 @@ func TestResize(t *testing.T) {
|
| 22 | 22 |
t.Run("success", func(t *testing.T) {
|
| 23 | 23 |
cID := container.Run(ctx, t, apiClient, container.WithTty(true)) |
| 24 | 24 |
defer container.Remove(ctx, t, apiClient, cID, client.ContainerRemoveOptions{Force: true})
|
| 25 |
- err := apiClient.ContainerResize(ctx, cID, client.ContainerResizeOptions{
|
|
| 25 |
+ _, err := apiClient.ContainerResize(ctx, cID, client.ContainerResizeOptions{
|
|
| 26 | 26 |
Height: 40, |
| 27 | 27 |
Width: 40, |
| 28 | 28 |
}) |
| ... | ... |
@@ -129,7 +129,7 @@ func TestResize(t *testing.T) {
|
| 129 | 129 |
t.Run("invalid state", func(t *testing.T) {
|
| 130 | 130 |
cID := container.Create(ctx, t, apiClient, container.WithCmd("echo"))
|
| 131 | 131 |
defer container.Remove(ctx, t, apiClient, cID, client.ContainerRemoveOptions{Force: true})
|
| 132 |
- err := apiClient.ContainerResize(ctx, cID, client.ContainerResizeOptions{
|
|
| 132 |
+ _, err := apiClient.ContainerResize(ctx, cID, client.ContainerResizeOptions{
|
|
| 133 | 133 |
Height: 40, |
| 134 | 134 |
Width: 40, |
| 135 | 135 |
}) |
| ... | ... |
@@ -108,7 +108,7 @@ func TestDaemonRestartKillContainers(t *testing.T) {
|
| 108 | 108 |
defer apiClient.ContainerRemove(ctx, resp.ID, client.ContainerRemoveOptions{Force: true})
|
| 109 | 109 |
|
| 110 | 110 |
if tc.xStart {
|
| 111 |
- err = apiClient.ContainerStart(ctx, resp.ID, client.ContainerStartOptions{})
|
|
| 111 |
+ _, err = apiClient.ContainerStart(ctx, resp.ID, client.ContainerStartOptions{})
|
|
| 112 | 112 |
assert.NilError(t, err) |
| 113 | 113 |
if tc.xHealthCheck {
|
| 114 | 114 |
poll.WaitOn(t, pollForHealthStatus(ctx, apiClient, resp.ID, container.Healthy), poll.WithTimeout(30*time.Second)) |
| ... | ... |
@@ -176,13 +176,15 @@ func TestContainerWithAutoRemoveCanBeRestarted(t *testing.T) {
|
| 176 | 176 |
{
|
| 177 | 177 |
desc: "kill", |
| 178 | 178 |
doSth: func(ctx context.Context, containerID string) error {
|
| 179 |
- return apiClient.ContainerKill(ctx, containerID, "SIGKILL") |
|
| 179 |
+ _, err := apiClient.ContainerKill(ctx, containerID, client.ContainerKillOptions{})
|
|
| 180 |
+ return err |
|
| 180 | 181 |
}, |
| 181 | 182 |
}, |
| 182 | 183 |
{
|
| 183 | 184 |
desc: "stop", |
| 184 | 185 |
doSth: func(ctx context.Context, containerID string) error {
|
| 185 |
- return apiClient.ContainerStop(ctx, containerID, client.ContainerStopOptions{Timeout: &noWaitTimeout})
|
|
| 186 |
+ _, err := apiClient.ContainerStop(ctx, containerID, client.ContainerStopOptions{Timeout: &noWaitTimeout})
|
|
| 187 |
+ return err |
|
| 186 | 188 |
}, |
| 187 | 189 |
}, |
| 188 | 190 |
} {
|
| ... | ... |
@@ -193,13 +195,15 @@ func TestContainerWithAutoRemoveCanBeRestarted(t *testing.T) {
|
| 193 | 193 |
testContainer.WithAutoRemove, |
| 194 | 194 |
) |
| 195 | 195 |
defer func() {
|
| 196 |
- err := apiClient.ContainerRemove(ctx, cID, client.ContainerRemoveOptions{Force: true})
|
|
| 196 |
+ _, err := apiClient.ContainerRemove(ctx, cID, client.ContainerRemoveOptions{Force: true})
|
|
| 197 | 197 |
if t.Failed() && err != nil {
|
| 198 | 198 |
t.Logf("Cleaning up test container failed with error: %v", err)
|
| 199 | 199 |
} |
| 200 | 200 |
}() |
| 201 | 201 |
|
| 202 |
- err := apiClient.ContainerRestart(ctx, cID, client.ContainerStopOptions{Timeout: &noWaitTimeout})
|
|
| 202 |
+ _, err := apiClient.ContainerRestart(ctx, cID, client.ContainerRestartOptions{
|
|
| 203 |
+ Timeout: &noWaitTimeout, |
|
| 204 |
+ }) |
|
| 203 | 205 |
assert.NilError(t, err) |
| 204 | 206 |
|
| 205 | 207 |
inspect, err := apiClient.ContainerInspect(ctx, cID, client.ContainerInspectOptions{})
|
| ... | ... |
@@ -236,7 +240,7 @@ func TestContainerRestartWithCancelledRequest(t *testing.T) {
|
| 236 | 236 |
// taking place. |
| 237 | 237 |
cID := testContainer.Run(ctx, t, apiClient, testContainer.WithCmd("sh", "-c", "trap 'echo received TERM' TERM; while true; do usleep 10; done"))
|
| 238 | 238 |
defer func() {
|
| 239 |
- err := apiClient.ContainerRemove(ctx, cID, client.ContainerRemoveOptions{Force: true})
|
|
| 239 |
+ _, err := apiClient.ContainerRemove(ctx, cID, client.ContainerRemoveOptions{Force: true})
|
|
| 240 | 240 |
if t.Failed() && err != nil {
|
| 241 | 241 |
t.Logf("Cleaning up test container failed with error: %v", err)
|
| 242 | 242 |
} |
| ... | ... |
@@ -251,7 +255,7 @@ func TestContainerRestartWithCancelledRequest(t *testing.T) {
|
| 251 | 251 |
// is (forcibly) killed. |
| 252 | 252 |
ctx2, cancel := context.WithTimeout(ctx, 100*time.Millisecond) |
| 253 | 253 |
stopTimeout := 1 |
| 254 |
- err := apiClient.ContainerRestart(ctx2, cID, client.ContainerStopOptions{
|
|
| 254 |
+ _, err := apiClient.ContainerRestart(ctx2, cID, client.ContainerRestartOptions{
|
|
| 255 | 255 |
Timeout: &stopTimeout, |
| 256 | 256 |
}) |
| 257 | 257 |
assert.Check(t, is.ErrorIs(err, context.DeadlineExceeded)) |
| ... | ... |
@@ -288,7 +288,7 @@ func TestMacAddressIsAppliedToMainNetworkWithShortID(t *testing.T) {
|
| 288 | 288 |
} |
| 289 | 289 |
|
| 290 | 290 |
cid := createLegacyContainer(ctx, t, apiClient, "02:42:08:26:a9:55", opts...) |
| 291 |
- err := apiClient.ContainerStart(ctx, cid, client.ContainerStartOptions{})
|
|
| 291 |
+ _, err := apiClient.ContainerStart(ctx, cid, client.ContainerStartOptions{})
|
|
| 292 | 292 |
assert.NilError(t, err) |
| 293 | 293 |
|
| 294 | 294 |
defer container.Remove(ctx, t, apiClient, cid, client.ContainerRemoveOptions{Force: true})
|
| ... | ... |
@@ -473,7 +473,7 @@ func TestCgroupRW(t *testing.T) {
|
| 473 | 473 |
return |
| 474 | 474 |
} |
| 475 | 475 |
// TODO check if ro or not |
| 476 |
- err = apiClient.ContainerStart(ctx, resp.ID, client.ContainerStartOptions{})
|
|
| 476 |
+ _, err = apiClient.ContainerStart(ctx, resp.ID, client.ContainerStartOptions{})
|
|
| 477 | 477 |
assert.NilError(t, err) |
| 478 | 478 |
|
| 479 | 479 |
res, err := container.Exec(ctx, apiClient, resp.ID, []string{"sh", "-ec", `
|
| ... | ... |
@@ -38,7 +38,8 @@ func TestStopContainerWithTimeoutCancel(t *testing.T) {
|
| 38 | 38 |
stoppedCh := make(chan error) |
| 39 | 39 |
go func() {
|
| 40 | 40 |
sto := stopTimeout |
| 41 |
- stoppedCh <- apiClient.ContainerStop(ctxCancel, id, client.ContainerStopOptions{Timeout: &sto})
|
|
| 41 |
+ _, err := apiClient.ContainerStop(ctxCancel, id, client.ContainerStopOptions{Timeout: &sto})
|
|
| 42 |
+ stoppedCh <- err |
|
| 42 | 43 |
}() |
| 43 | 44 |
|
| 44 | 45 |
poll.WaitOn(t, logsContains(ctx, apiClient, id, "received TERM")) |
| ... | ... |
@@ -34,7 +34,7 @@ func TestStopContainerWithRestartPolicyAlways(t *testing.T) {
|
| 34 | 34 |
} |
| 35 | 35 |
|
| 36 | 36 |
for _, name := range names {
|
| 37 |
- err := apiClient.ContainerStop(ctx, name, client.ContainerStopOptions{})
|
|
| 37 |
+ _, err := apiClient.ContainerStop(ctx, name, client.ContainerStopOptions{})
|
|
| 38 | 38 |
assert.NilError(t, err) |
| 39 | 39 |
} |
| 40 | 40 |
|
| ... | ... |
@@ -100,7 +100,7 @@ func TestStopContainerWithTimeout(t *testing.T) {
|
| 100 | 100 |
// t.Parallel() |
| 101 | 101 |
id := container.Run(ctx, t, apiClient, testCmd) |
| 102 | 102 |
|
| 103 |
- err := apiClient.ContainerStop(ctx, id, client.ContainerStopOptions{Timeout: &tc.timeout})
|
|
| 103 |
+ _, err := apiClient.ContainerStop(ctx, id, client.ContainerStopOptions{Timeout: &tc.timeout})
|
|
| 104 | 104 |
assert.NilError(t, err) |
| 105 | 105 |
|
| 106 | 106 |
poll.WaitOn(t, container.IsStopped(ctx, apiClient, id), pollOpts...) |
| ... | ... |
@@ -87,7 +87,7 @@ func TestWaitBlocked(t *testing.T) {
|
| 87 | 87 |
containerID := container.Run(ctx, t, cli, container.WithCmd("sh", "-c", tc.cmd))
|
| 88 | 88 |
waitResC, errC := cli.ContainerWait(ctx, containerID, "") |
| 89 | 89 |
|
| 90 |
- err := cli.ContainerStop(ctx, containerID, client.ContainerStopOptions{})
|
|
| 90 |
+ _, err := cli.ContainerStop(ctx, containerID, client.ContainerStopOptions{})
|
|
| 91 | 91 |
assert.NilError(t, err) |
| 92 | 92 |
|
| 93 | 93 |
select {
|
| ... | ... |
@@ -148,7 +148,8 @@ func TestWaitConditions(t *testing.T) {
|
| 148 | 148 |
assert.NilError(t, err) |
| 149 | 149 |
defer streams.Close() |
| 150 | 150 |
|
| 151 |
- assert.NilError(t, cli.ContainerStart(ctx, containerID, client.ContainerStartOptions{}))
|
|
| 151 |
+ _, err = cli.ContainerStart(ctx, containerID, client.ContainerStartOptions{})
|
|
| 152 |
+ assert.NilError(t, err) |
|
| 152 | 153 |
waitResC, errC := cli.ContainerWait(ctx, containerID, tc.waitCond) |
| 153 | 154 |
select {
|
| 154 | 155 |
case err := <-errC: |
| ... | ... |
@@ -221,7 +222,10 @@ func TestWaitRestartedContainer(t *testing.T) {
|
| 221 | 221 |
timeout = 0 |
| 222 | 222 |
} |
| 223 | 223 |
|
| 224 |
- err := cli.ContainerRestart(ctx, containerID, client.ContainerStopOptions{Timeout: &timeout, Signal: "SIGTERM"})
|
|
| 224 |
+ _, err := cli.ContainerRestart(ctx, containerID, client.ContainerRestartOptions{
|
|
| 225 |
+ Timeout: &timeout, |
|
| 226 |
+ Signal: "SIGTERM", |
|
| 227 |
+ }) |
|
| 225 | 228 |
assert.NilError(t, err) |
| 226 | 229 |
|
| 227 | 230 |
select {
|
| ... | ... |
@@ -656,7 +656,7 @@ func testLiveRestoreVolumeReferences(t *testing.T) {
|
| 656 | 656 |
}) |
| 657 | 657 |
|
| 658 | 658 |
// Remove that container which should free the references in the volume |
| 659 |
- err = c.ContainerRemove(ctx, cID, client.ContainerRemoveOptions{Force: true})
|
|
| 659 |
+ _, err = c.ContainerRemove(ctx, cID, client.ContainerRemoveOptions{Force: true})
|
|
| 660 | 660 |
assert.NilError(t, err) |
| 661 | 661 |
|
| 662 | 662 |
// Now we should be able to remove the volume |
| ... | ... |
@@ -704,7 +704,7 @@ func testLiveRestoreVolumeReferences(t *testing.T) {
|
| 704 | 704 |
assert.ErrorContains(t, err, fmt.Sprintf("container %s is using its referenced image", cID[:12]))
|
| 705 | 705 |
|
| 706 | 706 |
// Remove that container which should free the references in the volume |
| 707 |
- err = c.ContainerRemove(ctx, cID, client.ContainerRemoveOptions{Force: true})
|
|
| 707 |
+ _, err = c.ContainerRemove(ctx, cID, client.ContainerRemoveOptions{Force: true})
|
|
| 708 | 708 |
assert.NilError(t, err) |
| 709 | 709 |
|
| 710 | 710 |
// Now we should be able to remove the volume |
| ... | ... |
@@ -727,7 +727,7 @@ func testLiveRestoreVolumeReferences(t *testing.T) {
|
| 727 | 727 |
|
| 728 | 728 |
d.Restart(t, "--live-restore", "--iptables=false", "--ip6tables=false") |
| 729 | 729 |
|
| 730 |
- err := c.ContainerRemove(ctx, cID, client.ContainerRemoveOptions{Force: true})
|
|
| 730 |
+ _, err := c.ContainerRemove(ctx, cID, client.ContainerRemoveOptions{Force: true})
|
|
| 731 | 731 |
assert.NilError(t, err) |
| 732 | 732 |
}) |
| 733 | 733 |
} |
| ... | ... |
@@ -146,7 +146,7 @@ func TestInspectGraphDriverAPIBC(t *testing.T) {
|
| 146 | 146 |
const testImage = "busybox:latest" |
| 147 | 147 |
ctr, err := c.ContainerCreate(ctx, client.ContainerCreateOptions{Image: testImage, Name: "test-container"})
|
| 148 | 148 |
assert.NilError(t, err) |
| 149 |
- defer func() { _ = c.ContainerRemove(ctx, ctr.ID, client.ContainerRemoveOptions{Force: true}) }()
|
|
| 149 |
+ defer func() { _, _ = c.ContainerRemove(ctx, ctr.ID, client.ContainerRemoveOptions{Force: true}) }()
|
|
| 150 | 150 |
|
| 151 | 151 |
if imageInspect, err := c.ImageInspect(ctx, testImage); assert.Check(t, err) {
|
| 152 | 152 |
if tc.expGraphDriver != "" {
|
| ... | ... |
@@ -396,7 +396,7 @@ func TestSaveRepoWithMultipleImages(t *testing.T) {
|
| 396 | 396 |
res, err := apiClient.ContainerCommit(ctx, id, client.ContainerCommitOptions{Reference: tag})
|
| 397 | 397 |
assert.NilError(t, err) |
| 398 | 398 |
|
| 399 |
- err = apiClient.ContainerRemove(ctx, id, client.ContainerRemoveOptions{Force: true})
|
|
| 399 |
+ _, err = apiClient.ContainerRemove(ctx, id, client.ContainerRemoveOptions{Force: true})
|
|
| 400 | 400 |
assert.NilError(t, err) |
| 401 | 401 |
|
| 402 | 402 |
return res.ID |
| ... | ... |
@@ -88,7 +88,7 @@ func Run(ctx context.Context, t *testing.T, apiClient client.APIClient, ops ...f |
| 88 | 88 |
t.Helper() |
| 89 | 89 |
id := Create(ctx, t, apiClient, ops...) |
| 90 | 90 |
|
| 91 |
- err := apiClient.ContainerStart(ctx, id, client.ContainerStartOptions{})
|
|
| 91 |
+ _, err := apiClient.ContainerStart(ctx, id, client.ContainerStartOptions{})
|
|
| 92 | 92 |
assert.NilError(t, err) |
| 93 | 93 |
|
| 94 | 94 |
return id |
| ... | ... |
@@ -117,7 +117,7 @@ func RunAttach(ctx context.Context, t *testing.T, apiClient client.APIClient, op |
| 117 | 117 |
}) |
| 118 | 118 |
assert.NilError(t, err) |
| 119 | 119 |
|
| 120 |
- err = apiClient.ContainerStart(ctx, id, client.ContainerStartOptions{})
|
|
| 120 |
+ _, err = apiClient.ContainerStart(ctx, id, client.ContainerStartOptions{})
|
|
| 121 | 121 |
assert.NilError(t, err) |
| 122 | 122 |
|
| 123 | 123 |
s, err := demultiplexStreams(ctx, aresp.HijackedResponse) |
| ... | ... |
@@ -169,7 +169,7 @@ func demultiplexStreams(ctx context.Context, resp client.HijackedResponse) (stre |
| 169 | 169 |
func Remove(ctx context.Context, t *testing.T, apiClient client.APIClient, container string, options client.ContainerRemoveOptions) {
|
| 170 | 170 |
t.Helper() |
| 171 | 171 |
|
| 172 |
- err := apiClient.ContainerRemove(ctx, container, options) |
|
| 172 |
+ _, err := apiClient.ContainerRemove(ctx, container, options) |
|
| 173 | 173 |
assert.NilError(t, err) |
| 174 | 174 |
} |
| 175 | 175 |
|
| ... | ... |
@@ -233,7 +233,7 @@ func TestIPRangeAt64BitLimit(t *testing.T) {
|
| 233 | 233 |
|
| 234 | 234 |
id := ctr.Create(ctx, t, c, ctr.WithNetworkMode(netName)) |
| 235 | 235 |
defer c.ContainerRemove(ctx, id, client.ContainerRemoveOptions{Force: true})
|
| 236 |
- err := c.ContainerStart(ctx, id, client.ContainerStartOptions{})
|
|
| 236 |
+ _, err := c.ContainerStart(ctx, id, client.ContainerStartOptions{})
|
|
| 237 | 237 |
assert.NilError(t, err) |
| 238 | 238 |
}) |
| 239 | 239 |
} |
| ... | ... |
@@ -528,7 +528,7 @@ func TestPublishedPortAlreadyInUse(t *testing.T) {
|
| 528 | 528 |
ctr.WithPortMap(networktypes.PortMap{mappedPort: {{HostPort: "8000"}}}))
|
| 529 | 529 |
defer ctr.Remove(ctx, t, apiClient, ctr2, client.ContainerRemoveOptions{Force: true})
|
| 530 | 530 |
|
| 531 |
- err := apiClient.ContainerStart(ctx, ctr2, client.ContainerStartOptions{})
|
|
| 531 |
+ _, err := apiClient.ContainerStart(ctx, ctr2, client.ContainerStartOptions{})
|
|
| 532 | 532 |
assert.Assert(t, is.ErrorContains(err, "failed to set up container networking")) |
| 533 | 533 |
|
| 534 | 534 |
inspect, err := apiClient.ContainerInspect(ctx, ctr2, client.ContainerInspectOptions{})
|
| ... | ... |
@@ -754,7 +754,7 @@ func TestRemoveLegacyLink(t *testing.T) {
|
| 754 | 754 |
assert.Check(t, is.Contains(res.Stderr(), "404 Not Found")) |
| 755 | 755 |
|
| 756 | 756 |
// Remove the link ("docker rm --link client/thealias").
|
| 757 |
- err := c.ContainerRemove(ctx, clientName+"/"+svrAlias, client.ContainerRemoveOptions{RemoveLinks: true})
|
|
| 757 |
+ _, err := c.ContainerRemove(ctx, clientName+"/"+svrAlias, client.ContainerRemoveOptions{RemoveLinks: true})
|
|
| 758 | 758 |
assert.Check(t, err) |
| 759 | 759 |
|
| 760 | 760 |
// Check both containers are still running. |
| ... | ... |
@@ -1336,7 +1336,7 @@ func TestReadOnlySlashProc(t *testing.T) {
|
| 1336 | 1336 |
container.WithCmd("ls"),
|
| 1337 | 1337 |
) |
| 1338 | 1338 |
defer c.ContainerRemove(ctx, id4, client.ContainerRemoveOptions{Force: true})
|
| 1339 |
- err := c.ContainerStart(ctx, id4, client.ContainerStartOptions{})
|
|
| 1339 |
+ _, err := c.ContainerStart(ctx, id4, client.ContainerStartOptions{})
|
|
| 1340 | 1340 |
if tc.expErr == "" {
|
| 1341 | 1341 |
assert.Check(t, err) |
| 1342 | 1342 |
} else {
|
| ... | ... |
@@ -55,7 +55,7 @@ func TestMACAddrOnRestart(t *testing.T) {
|
| 55 | 55 |
defer c.ContainerRemove(ctx, id1, client.ContainerRemoveOptions{
|
| 56 | 56 |
Force: true, |
| 57 | 57 |
}) |
| 58 |
- err := c.ContainerStop(ctx, ctr1Name, client.ContainerStopOptions{})
|
|
| 58 |
+ _, err := c.ContainerStop(ctx, ctr1Name, client.ContainerStopOptions{})
|
|
| 59 | 59 |
assert.Assert(t, is.Nil(err)) |
| 60 | 60 |
|
| 61 | 61 |
// Start a second container, giving the daemon a chance to recycle the first container's |
| ... | ... |
@@ -71,7 +71,7 @@ func TestMACAddrOnRestart(t *testing.T) {
|
| 71 | 71 |
}) |
| 72 | 72 |
|
| 73 | 73 |
// Restart the first container. |
| 74 |
- err = c.ContainerStart(ctx, ctr1Name, client.ContainerStartOptions{})
|
|
| 74 |
+ _, err = c.ContainerStart(ctx, ctr1Name, client.ContainerStartOptions{})
|
|
| 75 | 75 |
assert.Assert(t, is.Nil(err)) |
| 76 | 76 |
|
| 77 | 77 |
// Check that the containers ended up with different MAC addresses. |
| ... | ... |
@@ -124,7 +124,7 @@ func TestCfgdMACAddrOnRestart(t *testing.T) {
|
| 124 | 124 |
|
| 125 | 125 |
startAndCheck := func() {
|
| 126 | 126 |
t.Helper() |
| 127 |
- err := c.ContainerStart(ctx, ctr1Name, client.ContainerStartOptions{})
|
|
| 127 |
+ _, err := c.ContainerStart(ctx, ctr1Name, client.ContainerStartOptions{})
|
|
| 128 | 128 |
assert.Assert(t, is.Nil(err)) |
| 129 | 129 |
inspect = container.Inspect(ctx, t, c, ctr1Name) |
| 130 | 130 |
gotMAC = inspect.NetworkSettings.Networks[netName].MacAddress |
| ... | ... |
@@ -132,12 +132,12 @@ func TestCfgdMACAddrOnRestart(t *testing.T) {
|
| 132 | 132 |
} |
| 133 | 133 |
|
| 134 | 134 |
// Restart the container, check that the MAC address is restored. |
| 135 |
- err := c.ContainerStop(ctx, ctr1Name, client.ContainerStopOptions{})
|
|
| 135 |
+ _, err := c.ContainerStop(ctx, ctr1Name, client.ContainerStopOptions{})
|
|
| 136 | 136 |
assert.Assert(t, is.Nil(err)) |
| 137 | 137 |
startAndCheck() |
| 138 | 138 |
|
| 139 | 139 |
// Restart the daemon, check that the MAC address is restored. |
| 140 |
- err = c.ContainerStop(ctx, ctr1Name, client.ContainerStopOptions{})
|
|
| 140 |
+ _, err = c.ContainerStop(ctx, ctr1Name, client.ContainerStopOptions{})
|
|
| 141 | 141 |
assert.Assert(t, is.Nil(err)) |
| 142 | 142 |
d.Restart(t) |
| 143 | 143 |
startAndCheck() |
| ... | ... |
@@ -294,7 +294,7 @@ func TestWatchtowerCreate(t *testing.T) {
|
| 294 | 294 |
} |
| 295 | 295 |
id := createLegacyContainer(ctx, t, c, ctrMAC, opts...) |
| 296 | 296 |
defer c.ContainerRemove(ctx, id, client.ContainerRemoveOptions{Force: true})
|
| 297 |
- err := c.ContainerStart(ctx, id, client.ContainerStartOptions{})
|
|
| 297 |
+ _, err := c.ContainerStart(ctx, id, client.ContainerStartOptions{})
|
|
| 298 | 298 |
assert.NilError(t, err) |
| 299 | 299 |
|
| 300 | 300 |
// Check that the container got the expected addresses. |
| ... | ... |
@@ -625,7 +625,8 @@ func TestRestartUserlandProxyUnder2MSL(t *testing.T) {
|
| 625 | 625 |
// Removing the container will kill the userland proxy, and the connection |
| 626 | 626 |
// opened by the previous HTTP request will be properly closed (ie. on both |
| 627 | 627 |
// sides). Thus, that connection will transition to the TIME_WAIT state. |
| 628 |
- assert.NilError(t, c.ContainerRemove(ctx, ctrName, client.ContainerRemoveOptions{Force: true}))
|
|
| 628 |
+ _, err = c.ContainerRemove(ctx, ctrName, client.ContainerRemoveOptions{Force: true})
|
|
| 629 |
+ assert.NilError(t, err) |
|
| 629 | 630 |
|
| 630 | 631 |
// Make sure the container can be restarted. [container.Run] checks that |
| 631 | 632 |
// the ContainerStart API call doesn't return an error. We don't need to |
| ... | ... |
@@ -63,7 +63,7 @@ func TestReadPluginNoRead(t *testing.T) {
|
| 63 | 63 |
assert.Assert(t, err) |
| 64 | 64 |
defer apiclient.ContainerRemove(ctx, c.ID, client.ContainerRemoveOptions{Force: true})
|
| 65 | 65 |
|
| 66 |
- err = apiclient.ContainerStart(ctx, c.ID, client.ContainerStartOptions{})
|
|
| 66 |
+ _, err = apiclient.ContainerStart(ctx, c.ID, client.ContainerStartOptions{})
|
|
| 67 | 67 |
assert.Assert(t, err) |
| 68 | 68 |
|
| 69 | 69 |
poll.WaitOn(t, testContainer.IsStopped(ctx, apiclient, c.ID)) |
| ... | ... |
@@ -54,7 +54,7 @@ func TestDockerNetworkConnectAliasPreV144(t *testing.T) {
|
| 54 | 54 |
}) |
| 55 | 55 |
assert.NilError(t, err) |
| 56 | 56 |
|
| 57 |
- err = apiClient.ContainerStart(ctx, cID1, client.ContainerStartOptions{})
|
|
| 57 |
+ _, err = apiClient.ContainerStart(ctx, cID1, client.ContainerStartOptions{})
|
|
| 58 | 58 |
assert.NilError(t, err) |
| 59 | 59 |
|
| 60 | 60 |
ng1, err := apiClient.ContainerInspect(ctx, cID1, client.ContainerInspectOptions{})
|
| ... | ... |
@@ -77,7 +77,7 @@ func TestDockerNetworkConnectAliasPreV144(t *testing.T) {
|
| 77 | 77 |
}) |
| 78 | 78 |
assert.NilError(t, err) |
| 79 | 79 |
|
| 80 |
- err = apiClient.ContainerStart(ctx, cID2, client.ContainerStartOptions{})
|
|
| 80 |
+ _, err = apiClient.ContainerStart(ctx, cID2, client.ContainerStartOptions{})
|
|
| 81 | 81 |
assert.NilError(t, err) |
| 82 | 82 |
|
| 83 | 83 |
ng2, err := apiClient.ContainerInspect(ctx, cID2, client.ContainerInspectOptions{})
|
| ... | ... |
@@ -111,7 +111,7 @@ func TestDockerNetworkReConnect(t *testing.T) {
|
| 111 | 111 |
err := apiClient.NetworkConnect(ctx, name, c1, &network.EndpointSettings{})
|
| 112 | 112 |
assert.NilError(t, err) |
| 113 | 113 |
|
| 114 |
- err = apiClient.ContainerStart(ctx, c1, client.ContainerStartOptions{})
|
|
| 114 |
+ _, err = apiClient.ContainerStart(ctx, c1, client.ContainerStartOptions{})
|
|
| 115 | 115 |
assert.NilError(t, err) |
| 116 | 116 |
|
| 117 | 117 |
n1, err := apiClient.ContainerInspect(ctx, c1, client.ContainerInspectOptions{})
|
| ... | ... |
@@ -46,7 +46,7 @@ func TestCgroupDriverSystemdMemoryLimit(t *testing.T) {
|
| 46 | 46 |
}) |
| 47 | 47 |
defer c.ContainerRemove(ctx, ctrID, client.ContainerRemoveOptions{Force: true})
|
| 48 | 48 |
|
| 49 |
- err := c.ContainerStart(ctx, ctrID, client.ContainerStartOptions{})
|
|
| 49 |
+ _, err := c.ContainerStart(ctx, ctrID, client.ContainerStartOptions{})
|
|
| 50 | 50 |
assert.NilError(t, err) |
| 51 | 51 |
|
| 52 | 52 |
s, err := c.ContainerInspect(ctx, ctrID, client.ContainerInspectOptions{})
|
| ... | ... |
@@ -97,7 +97,7 @@ func TestRunMountVolumeSubdir(t *testing.T) {
|
| 97 | 97 |
} |
| 98 | 98 |
assert.NilError(t, creatErr, "container creation failed") |
| 99 | 99 |
|
| 100 |
- startErr := apiClient.ContainerStart(ctx, id, client.ContainerStartOptions{})
|
|
| 100 |
+ _, startErr := apiClient.ContainerStart(ctx, id, client.ContainerStartOptions{})
|
|
| 101 | 101 |
if tc.startErr != "" {
|
| 102 | 102 |
assert.ErrorContains(t, startErr, tc.startErr) |
| 103 | 103 |
return |
| ... | ... |
@@ -173,7 +173,7 @@ func TestRunMountImage(t *testing.T) {
|
| 173 | 173 |
} |
| 174 | 174 |
|
| 175 | 175 |
startContainer := func(id string) {
|
| 176 |
- startErr := apiClient.ContainerStart(ctx, id, client.ContainerStartOptions{})
|
|
| 176 |
+ _, startErr := apiClient.ContainerStart(ctx, id, client.ContainerStartOptions{})
|
|
| 177 | 177 |
if tc.startErr != "" {
|
| 178 | 178 |
assert.ErrorContains(t, startErr, tc.startErr) |
| 179 | 179 |
return |
| ... | ... |
@@ -210,7 +210,7 @@ func TestRunMountImage(t *testing.T) {
|
| 210 | 210 |
|
| 211 | 211 |
// Test that the container servives a restart when mounted image is removed |
| 212 | 212 |
if tc.name == "image_remove_force" {
|
| 213 |
- stopErr := apiClient.ContainerStop(ctx, id, client.ContainerStopOptions{})
|
|
| 213 |
+ _, stopErr := apiClient.ContainerStop(ctx, id, client.ContainerStopOptions{})
|
|
| 214 | 214 |
assert.NilError(t, stopErr) |
| 215 | 215 |
|
| 216 | 216 |
_, removeErr := apiClient.ImageRemove(ctx, testImage, client.ImageRemoveOptions{Force: true})
|
| ... | ... |
@@ -82,7 +82,7 @@ func TestVolumesRemove(t *testing.T) {
|
| 82 | 82 |
}) |
| 83 | 83 |
|
| 84 | 84 |
t.Run("volume not in use", func(t *testing.T) {
|
| 85 |
- err = apiClient.ContainerRemove(ctx, id, client.ContainerRemoveOptions{
|
|
| 85 |
+ _, err = apiClient.ContainerRemove(ctx, id, client.ContainerRemoveOptions{
|
|
| 86 | 86 |
Force: true, |
| 87 | 87 |
}) |
| 88 | 88 |
assert.NilError(t, err) |
| ... | ... |
@@ -134,7 +134,7 @@ func TestVolumesRemoveSwarmEnabled(t *testing.T) {
|
| 134 | 134 |
}) |
| 135 | 135 |
|
| 136 | 136 |
t.Run("volume not in use", func(t *testing.T) {
|
| 137 |
- err = apiClient.ContainerRemove(ctx, id, client.ContainerRemoveOptions{
|
|
| 137 |
+ _, err = apiClient.ContainerRemove(ctx, id, client.ContainerRemoveOptions{
|
|
| 138 | 138 |
Force: true, |
| 139 | 139 |
}) |
| 140 | 140 |
assert.NilError(t, err) |
| ... | ... |
@@ -351,7 +351,7 @@ VOLUME ` + volDest |
| 351 | 351 |
volumeName := inspect.Container.Mounts[0].Name |
| 352 | 352 |
assert.Assert(t, volumeName != "") |
| 353 | 353 |
|
| 354 |
- err = apiClient.ContainerRemove(ctx, id, client.ContainerRemoveOptions{})
|
|
| 354 |
+ _, err = apiClient.ContainerRemove(ctx, id, client.ContainerRemoveOptions{})
|
|
| 355 | 355 |
assert.NilError(t, err) |
| 356 | 356 |
|
| 357 | 357 |
res, err := apiClient.VolumesPrune(ctx, client.VolumePruneOptions{})
|
| ... | ... |
@@ -38,12 +38,12 @@ func (e *Execution) Clean(ctx context.Context, t testing.TB) {
|
| 38 | 38 |
} |
| 39 | 39 |
} |
| 40 | 40 |
|
| 41 |
-func unpauseAllContainers(ctx context.Context, t testing.TB, client client.ContainerAPIClient) {
|
|
| 41 |
+func unpauseAllContainers(ctx context.Context, t testing.TB, apiClient client.ContainerAPIClient) {
|
|
| 42 | 42 |
t.Helper() |
| 43 |
- containers := getPausedContainers(ctx, t, client) |
|
| 43 |
+ containers := getPausedContainers(ctx, t, apiClient) |
|
| 44 | 44 |
if len(containers) > 0 {
|
| 45 | 45 |
for _, ctr := range containers {
|
| 46 |
- err := client.ContainerUnpause(ctx, ctr.ID) |
|
| 46 |
+ _, err := apiClient.ContainerUnpause(ctx, ctr.ID, client.ContainerUnPauseOptions{})
|
|
| 47 | 47 |
assert.Check(t, err, "failed to unpause container %s", ctr.ID) |
| 48 | 48 |
} |
| 49 | 49 |
} |
| ... | ... |
@@ -70,7 +70,7 @@ func deleteAllContainers(ctx context.Context, t testing.TB, apiclient client.Con |
| 70 | 70 |
if _, ok := protectedContainers[ctr.ID]; ok {
|
| 71 | 71 |
continue |
| 72 | 72 |
} |
| 73 |
- err := apiclient.ContainerRemove(ctx, ctr.ID, client.ContainerRemoveOptions{
|
|
| 73 |
+ _, err := apiclient.ContainerRemove(ctx, ctr.ID, client.ContainerRemoveOptions{
|
|
| 74 | 74 |
Force: true, |
| 75 | 75 |
RemoveVolumes: true, |
| 76 | 76 |
}) |
| ... | ... |
@@ -124,10 +124,11 @@ func (f *remoteFileServer) Close() error {
|
| 124 | 124 |
if f.container == "" {
|
| 125 | 125 |
return nil |
| 126 | 126 |
} |
| 127 |
- return f.client.ContainerRemove(context.Background(), f.container, client.ContainerRemoveOptions{
|
|
| 127 |
+ _, err := f.client.ContainerRemove(context.Background(), f.container, client.ContainerRemoveOptions{
|
|
| 128 | 128 |
Force: true, |
| 129 | 129 |
RemoveVolumes: true, |
| 130 | 130 |
}) |
| 131 |
+ return err |
|
| 131 | 132 |
} |
| 132 | 133 |
|
| 133 | 134 |
func newRemoteFileServer(t testing.TB, ctx *fakecontext.Fake, c client.APIClient) *remoteFileServer {
|
| ... | ... |
@@ -160,7 +161,7 @@ COPY . /static`); err != nil {
|
| 160 | 160 |
Name: ctrName, |
| 161 | 161 |
}) |
| 162 | 162 |
assert.NilError(t, err) |
| 163 |
- err = c.ContainerStart(context.Background(), b.ID, client.ContainerStartOptions{})
|
|
| 163 |
+ _, err = c.ContainerStart(context.Background(), b.ID, client.ContainerStartOptions{})
|
|
| 164 | 164 |
assert.NilError(t, err) |
| 165 | 165 |
|
| 166 | 166 |
// Find out the system assigned port |
| ... | ... |
@@ -64,20 +64,20 @@ type ContainerAPIClient interface {
|
| 64 | 64 |
ExecAPIClient |
| 65 | 65 |
ContainerExport(ctx context.Context, container string) (io.ReadCloser, error) |
| 66 | 66 |
ContainerInspect(ctx context.Context, container string, options ContainerInspectOptions) (ContainerInspectResult, error) |
| 67 |
- ContainerKill(ctx context.Context, container, signal string) error |
|
| 67 |
+ ContainerKill(ctx context.Context, container string, options ContainerKillOptions) (ContainerKillResult, error) |
|
| 68 | 68 |
ContainerList(ctx context.Context, options ContainerListOptions) ([]container.Summary, error) |
| 69 | 69 |
ContainerLogs(ctx context.Context, container string, options ContainerLogsOptions) (io.ReadCloser, error) |
| 70 |
- ContainerPause(ctx context.Context, container string) error |
|
| 71 |
- ContainerRemove(ctx context.Context, container string, options ContainerRemoveOptions) error |
|
| 70 |
+ ContainerPause(ctx context.Context, container string, options ContainerPauseOptions) (ContainerPauseResult, error) |
|
| 71 |
+ ContainerRemove(ctx context.Context, container string, options ContainerRemoveOptions) (ContainerRemoveResult, error) |
|
| 72 | 72 |
ContainerRename(ctx context.Context, container, newContainerName string) error |
| 73 |
- ContainerResize(ctx context.Context, container string, options ContainerResizeOptions) error |
|
| 74 |
- ContainerRestart(ctx context.Context, container string, options ContainerStopOptions) error |
|
| 73 |
+ ContainerResize(ctx context.Context, container string, options ContainerResizeOptions) (ContainerResizeResult, error) |
|
| 74 |
+ ContainerRestart(ctx context.Context, container string, options ContainerRestartOptions) (ContainerRestartResult, error) |
|
| 75 | 75 |
ContainerStatPath(ctx context.Context, container, path string) (container.PathStat, error) |
| 76 | 76 |
ContainerStats(ctx context.Context, container string, options ContainerStatsOptions) (ContainerStatsResult, error) |
| 77 |
- ContainerStart(ctx context.Context, container string, options ContainerStartOptions) error |
|
| 78 |
- ContainerStop(ctx context.Context, container string, options ContainerStopOptions) error |
|
| 77 |
+ ContainerStart(ctx context.Context, container string, options ContainerStartOptions) (ContainerStartResult, error) |
|
| 78 |
+ ContainerStop(ctx context.Context, container string, options ContainerStopOptions) (ContainerStopResult, error) |
|
| 79 | 79 |
ContainerTop(ctx context.Context, container string, arguments []string) (container.TopResponse, error) |
| 80 |
- ContainerUnpause(ctx context.Context, container string) error |
|
| 80 |
+ ContainerUnpause(ctx context.Context, container string, options ContainerUnPauseOptions) (ContainerUnPauseResult, error) |
|
| 81 | 81 |
ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (container.UpdateResponse, error) |
| 82 | 82 |
ContainerWait(ctx context.Context, container string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error) |
| 83 | 83 |
CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, container.PathStat, error) |
| ... | ... |
@@ -5,19 +5,35 @@ import ( |
| 5 | 5 |
"net/url" |
| 6 | 6 |
) |
| 7 | 7 |
|
| 8 |
+// ContainerKillOptions holds options for [Client.ContainerKill]. |
|
| 9 |
+type ContainerKillOptions struct {
|
|
| 10 |
+ // Signal (optional) is the signal to send to the container to (gracefully) |
|
| 11 |
+ // stop it before forcibly terminating the container with SIGKILL after a |
|
| 12 |
+ // timeout. If no value is set, the default (SIGKILL) is used. |
|
| 13 |
+ Signal string `json:",omitempty"` |
|
| 14 |
+} |
|
| 15 |
+ |
|
| 16 |
+// ContainerKillResult holds the result of [Client.ContainerKill], |
|
| 17 |
+type ContainerKillResult struct {
|
|
| 18 |
+ // Add future fields here. |
|
| 19 |
+} |
|
| 20 |
+ |
|
| 8 | 21 |
// ContainerKill terminates the container process but does not remove the container from the docker host. |
| 9 |
-func (cli *Client) ContainerKill(ctx context.Context, containerID, signal string) error {
|
|
| 22 |
+func (cli *Client) ContainerKill(ctx context.Context, containerID string, options ContainerKillOptions) (ContainerKillResult, error) {
|
|
| 10 | 23 |
containerID, err := trimID("container", containerID)
|
| 11 | 24 |
if err != nil {
|
| 12 |
- return err |
|
| 25 |
+ return ContainerKillResult{}, err
|
|
| 13 | 26 |
} |
| 14 | 27 |
|
| 15 | 28 |
query := url.Values{}
|
| 16 |
- if signal != "" {
|
|
| 17 |
- query.Set("signal", signal)
|
|
| 29 |
+ if options.Signal != "" {
|
|
| 30 |
+ query.Set("signal", options.Signal)
|
|
| 18 | 31 |
} |
| 19 | 32 |
|
| 20 | 33 |
resp, err := cli.post(ctx, "/containers/"+containerID+"/kill", query, nil, nil) |
| 21 | 34 |
defer ensureReaderClosed(resp) |
| 22 |
- return err |
|
| 35 |
+ if err != nil {
|
|
| 36 |
+ return ContainerKillResult{}, err
|
|
| 37 |
+ } |
|
| 38 |
+ return ContainerKillResult{}, nil
|
|
| 23 | 39 |
} |
| ... | ... |
@@ -2,14 +2,27 @@ package client |
| 2 | 2 |
|
| 3 | 3 |
import "context" |
| 4 | 4 |
|
| 5 |
+// ContainerPauseOptions holds options for [Client.ContainerPause]. |
|
| 6 |
+type ContainerPauseOptions struct {
|
|
| 7 |
+ // Add future optional parameters here. |
|
| 8 |
+} |
|
| 9 |
+ |
|
| 10 |
+// ContainerPauseResult holds the result of [Client.ContainerPause], |
|
| 11 |
+type ContainerPauseResult struct {
|
|
| 12 |
+ // Add future fields here. |
|
| 13 |
+} |
|
| 14 |
+ |
|
| 5 | 15 |
// ContainerPause pauses the main process of a given container without terminating it. |
| 6 |
-func (cli *Client) ContainerPause(ctx context.Context, containerID string) error {
|
|
| 16 |
+func (cli *Client) ContainerPause(ctx context.Context, containerID string, options ContainerPauseOptions) (ContainerPauseResult, error) {
|
|
| 7 | 17 |
containerID, err := trimID("container", containerID)
|
| 8 | 18 |
if err != nil {
|
| 9 |
- return err |
|
| 19 |
+ return ContainerPauseResult{}, err
|
|
| 10 | 20 |
} |
| 11 | 21 |
|
| 12 | 22 |
resp, err := cli.post(ctx, "/containers/"+containerID+"/pause", nil, nil, nil) |
| 13 | 23 |
defer ensureReaderClosed(resp) |
| 14 |
- return err |
|
| 24 |
+ if err != nil {
|
|
| 25 |
+ return ContainerPauseResult{}, err
|
|
| 26 |
+ } |
|
| 27 |
+ return ContainerPauseResult{}, nil
|
|
| 15 | 28 |
} |
| ... | ... |
@@ -12,11 +12,16 @@ type ContainerRemoveOptions struct {
|
| 12 | 12 |
Force bool |
| 13 | 13 |
} |
| 14 | 14 |
|
| 15 |
+// ContainerRemoveResult holds the result of [Client.ContainerRemove], |
|
| 16 |
+type ContainerRemoveResult struct {
|
|
| 17 |
+ // Add future fields here. |
|
| 18 |
+} |
|
| 19 |
+ |
|
| 15 | 20 |
// ContainerRemove kills and removes a container from the docker host. |
| 16 |
-func (cli *Client) ContainerRemove(ctx context.Context, containerID string, options ContainerRemoveOptions) error {
|
|
| 21 |
+func (cli *Client) ContainerRemove(ctx context.Context, containerID string, options ContainerRemoveOptions) (ContainerRemoveResult, error) {
|
|
| 17 | 22 |
containerID, err := trimID("container", containerID)
|
| 18 | 23 |
if err != nil {
|
| 19 |
- return err |
|
| 24 |
+ return ContainerRemoveResult{}, err
|
|
| 20 | 25 |
} |
| 21 | 26 |
|
| 22 | 27 |
query := url.Values{}
|
| ... | ... |
@@ -33,5 +38,8 @@ func (cli *Client) ContainerRemove(ctx context.Context, containerID string, opti |
| 33 | 33 |
|
| 34 | 34 |
resp, err := cli.delete(ctx, "/containers/"+containerID, query, nil) |
| 35 | 35 |
defer ensureReaderClosed(resp) |
| 36 |
- return err |
|
| 36 |
+ if err != nil {
|
|
| 37 |
+ return ContainerRemoveResult{}, err
|
|
| 38 |
+ } |
|
| 39 |
+ return ContainerRemoveResult{}, nil
|
|
| 37 | 40 |
} |
| ... | ... |
@@ -14,13 +14,28 @@ type ContainerResizeOptions struct {
|
| 14 | 14 |
Width uint |
| 15 | 15 |
} |
| 16 | 16 |
|
| 17 |
+// ContainerResizeResult holds the result of [Client.ContainerResize], |
|
| 18 |
+type ContainerResizeResult struct {
|
|
| 19 |
+ // Add future fields here. |
|
| 20 |
+} |
|
| 21 |
+ |
|
| 17 | 22 |
// ContainerResize changes the size of the pseudo-TTY for a container. |
| 18 |
-func (cli *Client) ContainerResize(ctx context.Context, containerID string, options ContainerResizeOptions) error {
|
|
| 23 |
+func (cli *Client) ContainerResize(ctx context.Context, containerID string, options ContainerResizeOptions) (ContainerResizeResult, error) {
|
|
| 19 | 24 |
containerID, err := trimID("container", containerID)
|
| 20 | 25 |
if err != nil {
|
| 21 |
- return err |
|
| 26 |
+ return ContainerResizeResult{}, err
|
|
| 27 |
+ } |
|
| 28 |
+ // FIXME(thaJeztah): the API / backend accepts uint32, but container.ResizeOptions uses uint. |
|
| 29 |
+ query := url.Values{}
|
|
| 30 |
+ query.Set("h", strconv.FormatUint(uint64(options.Height), 10))
|
|
| 31 |
+ query.Set("w", strconv.FormatUint(uint64(options.Width), 10))
|
|
| 32 |
+ |
|
| 33 |
+ resp, err := cli.post(ctx, "/containers/"+containerID+"/resize", query, nil, nil) |
|
| 34 |
+ defer ensureReaderClosed(resp) |
|
| 35 |
+ if err != nil {
|
|
| 36 |
+ return ContainerResizeResult{}, err
|
|
| 22 | 37 |
} |
| 23 |
- return cli.resize(ctx, "/containers/"+containerID, options.Height, options.Width) |
|
| 38 |
+ return ContainerResizeResult{}, nil
|
|
| 24 | 39 |
} |
| 25 | 40 |
|
| 26 | 41 |
// ExecResizeOptions holds options for resizing a container exec TTY. |
| ... | ... |
@@ -36,17 +51,16 @@ func (cli *Client) ExecResize(ctx context.Context, execID string, options ExecRe |
| 36 | 36 |
if err != nil {
|
| 37 | 37 |
return ExecResizeResult{}, err
|
| 38 | 38 |
} |
| 39 |
- err = cli.resize(ctx, "/exec/"+execID, options.Height, options.Width) |
|
| 40 |
- return ExecResizeResult{}, err
|
|
| 41 |
-} |
|
| 42 |
- |
|
| 43 |
-func (cli *Client) resize(ctx context.Context, basePath string, height, width uint) error {
|
|
| 44 | 39 |
// FIXME(thaJeztah): the API / backend accepts uint32, but container.ResizeOptions uses uint. |
| 45 | 40 |
query := url.Values{}
|
| 46 |
- query.Set("h", strconv.FormatUint(uint64(height), 10))
|
|
| 47 |
- query.Set("w", strconv.FormatUint(uint64(width), 10))
|
|
| 41 |
+ query.Set("h", strconv.FormatUint(uint64(options.Height), 10))
|
|
| 42 |
+ query.Set("w", strconv.FormatUint(uint64(options.Width), 10))
|
|
| 48 | 43 |
|
| 49 |
- resp, err := cli.post(ctx, basePath+"/resize", query, nil, nil) |
|
| 44 |
+ resp, err := cli.post(ctx, "/exec/"+execID+"/resize", query, nil, nil) |
|
| 50 | 45 |
defer ensureReaderClosed(resp) |
| 51 |
- return err |
|
| 46 |
+ if err != nil {
|
|
| 47 |
+ return ExecResizeResult{}, err
|
|
| 48 |
+ } |
|
| 49 |
+ return ExecResizeResult{}, nil
|
|
| 50 |
+ |
|
| 52 | 51 |
} |
| ... | ... |
@@ -6,13 +6,36 @@ import ( |
| 6 | 6 |
"strconv" |
| 7 | 7 |
) |
| 8 | 8 |
|
| 9 |
+// ContainerRestartOptions holds options for [Client.ContainerRestart]. |
|
| 10 |
+type ContainerRestartOptions struct {
|
|
| 11 |
+ // Signal (optional) is the signal to send to the container to (gracefully) |
|
| 12 |
+ // stop it before forcibly terminating the container with SIGKILL after the |
|
| 13 |
+ // timeout expires. If no value is set, the default (SIGTERM) is used. |
|
| 14 |
+ Signal string `json:",omitempty"` |
|
| 15 |
+ |
|
| 16 |
+ // Timeout (optional) is the timeout (in seconds) to wait for the container |
|
| 17 |
+ // to stop gracefully before forcibly terminating it with SIGKILL. |
|
| 18 |
+ // |
|
| 19 |
+ // - Use nil to use the default timeout (10 seconds). |
|
| 20 |
+ // - Use '-1' to wait indefinitely. |
|
| 21 |
+ // - Use '0' to not wait for the container to exit gracefully, and |
|
| 22 |
+ // immediately proceeds to forcibly terminating the container. |
|
| 23 |
+ // - Other positive values are used as timeout (in seconds). |
|
| 24 |
+ Timeout *int `json:",omitempty"` |
|
| 25 |
+} |
|
| 26 |
+ |
|
| 27 |
+// ContainerRestartResult holds the result of [Client.ContainerRestart], |
|
| 28 |
+type ContainerRestartResult struct {
|
|
| 29 |
+ // Add future fields here. |
|
| 30 |
+} |
|
| 31 |
+ |
|
| 9 | 32 |
// ContainerRestart stops, and starts a container again. |
| 10 | 33 |
// It makes the daemon wait for the container to be up again for |
| 11 | 34 |
// a specific amount of time, given the timeout. |
| 12 |
-func (cli *Client) ContainerRestart(ctx context.Context, containerID string, options ContainerStopOptions) error {
|
|
| 35 |
+func (cli *Client) ContainerRestart(ctx context.Context, containerID string, options ContainerRestartOptions) (ContainerRestartResult, error) {
|
|
| 13 | 36 |
containerID, err := trimID("container", containerID)
|
| 14 | 37 |
if err != nil {
|
| 15 |
- return err |
|
| 38 |
+ return ContainerRestartResult{}, err
|
|
| 16 | 39 |
} |
| 17 | 40 |
|
| 18 | 41 |
query := url.Values{}
|
| ... | ... |
@@ -24,5 +47,8 @@ func (cli *Client) ContainerRestart(ctx context.Context, containerID string, opt |
| 24 | 24 |
} |
| 25 | 25 |
resp, err := cli.post(ctx, "/containers/"+containerID+"/restart", query, nil, nil) |
| 26 | 26 |
defer ensureReaderClosed(resp) |
| 27 |
- return err |
|
| 27 |
+ if err != nil {
|
|
| 28 |
+ return ContainerRestartResult{}, err
|
|
| 29 |
+ } |
|
| 30 |
+ return ContainerRestartResult{}, nil
|
|
| 28 | 31 |
} |
| ... | ... |
@@ -5,17 +5,22 @@ import ( |
| 5 | 5 |
"net/url" |
| 6 | 6 |
) |
| 7 | 7 |
|
| 8 |
-// ContainerStartOptions holds parameters to start containers. |
|
| 8 |
+// ContainerStartOptions holds options for [Client.ContainerStart]. |
|
| 9 | 9 |
type ContainerStartOptions struct {
|
| 10 | 10 |
CheckpointID string |
| 11 | 11 |
CheckpointDir string |
| 12 | 12 |
} |
| 13 | 13 |
|
| 14 |
+// ContainerStartResult holds the result of [Client.ContainerStart], |
|
| 15 |
+type ContainerStartResult struct {
|
|
| 16 |
+ // Add future fields here. |
|
| 17 |
+} |
|
| 18 |
+ |
|
| 14 | 19 |
// ContainerStart sends a request to the docker daemon to start a container. |
| 15 |
-func (cli *Client) ContainerStart(ctx context.Context, containerID string, options ContainerStartOptions) error {
|
|
| 20 |
+func (cli *Client) ContainerStart(ctx context.Context, containerID string, options ContainerStartOptions) (ContainerStartResult, error) {
|
|
| 16 | 21 |
containerID, err := trimID("container", containerID)
|
| 17 | 22 |
if err != nil {
|
| 18 |
- return err |
|
| 23 |
+ return ContainerStartResult{}, err
|
|
| 19 | 24 |
} |
| 20 | 25 |
|
| 21 | 26 |
query := url.Values{}
|
| ... | ... |
@@ -28,5 +33,8 @@ func (cli *Client) ContainerStart(ctx context.Context, containerID string, optio |
| 28 | 28 |
|
| 29 | 29 |
resp, err := cli.post(ctx, "/containers/"+containerID+"/start", query, nil, nil) |
| 30 | 30 |
defer ensureReaderClosed(resp) |
| 31 |
- return err |
|
| 31 |
+ if err != nil {
|
|
| 32 |
+ return ContainerStartResult{}, err
|
|
| 33 |
+ } |
|
| 34 |
+ return ContainerStartResult{}, nil
|
|
| 32 | 35 |
} |
| ... | ... |
@@ -6,11 +6,11 @@ import ( |
| 6 | 6 |
"strconv" |
| 7 | 7 |
) |
| 8 | 8 |
|
| 9 |
-// ContainerStopOptions holds the options to stop or restart a container. |
|
| 9 |
+// ContainerStopOptions holds the options for [Client.ContainerStop]. |
|
| 10 | 10 |
type ContainerStopOptions struct {
|
| 11 | 11 |
// Signal (optional) is the signal to send to the container to (gracefully) |
| 12 | 12 |
// stop it before forcibly terminating the container with SIGKILL after the |
| 13 |
- // timeout expires. If not value is set, the default (SIGTERM) is used. |
|
| 13 |
+ // timeout expires. If no value is set, the default (SIGTERM) is used. |
|
| 14 | 14 |
Signal string `json:",omitempty"` |
| 15 | 15 |
|
| 16 | 16 |
// Timeout (optional) is the timeout (in seconds) to wait for the container |
| ... | ... |
@@ -24,6 +24,11 @@ type ContainerStopOptions struct {
|
| 24 | 24 |
Timeout *int `json:",omitempty"` |
| 25 | 25 |
} |
| 26 | 26 |
|
| 27 |
+// ContainerStopResult holds the result of [Client.ContainerStop], |
|
| 28 |
+type ContainerStopResult struct {
|
|
| 29 |
+ // Add future fields here. |
|
| 30 |
+} |
|
| 31 |
+ |
|
| 27 | 32 |
// ContainerStop stops a container. In case the container fails to stop |
| 28 | 33 |
// gracefully within a time frame specified by the timeout argument, |
| 29 | 34 |
// it is forcefully terminated (killed). |
| ... | ... |
@@ -31,10 +36,10 @@ type ContainerStopOptions struct {
|
| 31 | 31 |
// If the timeout is nil, the container's StopTimeout value is used, if set, |
| 32 | 32 |
// otherwise the engine default. A negative timeout value can be specified, |
| 33 | 33 |
// meaning no timeout, i.e. no forceful termination is performed. |
| 34 |
-func (cli *Client) ContainerStop(ctx context.Context, containerID string, options ContainerStopOptions) error {
|
|
| 34 |
+func (cli *Client) ContainerStop(ctx context.Context, containerID string, options ContainerStopOptions) (ContainerStopResult, error) {
|
|
| 35 | 35 |
containerID, err := trimID("container", containerID)
|
| 36 | 36 |
if err != nil {
|
| 37 |
- return err |
|
| 37 |
+ return ContainerStopResult{}, err
|
|
| 38 | 38 |
} |
| 39 | 39 |
|
| 40 | 40 |
query := url.Values{}
|
| ... | ... |
@@ -46,5 +51,8 @@ func (cli *Client) ContainerStop(ctx context.Context, containerID string, option |
| 46 | 46 |
} |
| 47 | 47 |
resp, err := cli.post(ctx, "/containers/"+containerID+"/stop", query, nil, nil) |
| 48 | 48 |
defer ensureReaderClosed(resp) |
| 49 |
- return err |
|
| 49 |
+ if err != nil {
|
|
| 50 |
+ return ContainerStopResult{}, err
|
|
| 51 |
+ } |
|
| 52 |
+ return ContainerStopResult{}, nil
|
|
| 50 | 53 |
} |
| ... | ... |
@@ -2,14 +2,27 @@ package client |
| 2 | 2 |
|
| 3 | 3 |
import "context" |
| 4 | 4 |
|
| 5 |
+// ContainerUnPauseOptions holds options for [Client.ContainerUnpause]. |
|
| 6 |
+type ContainerUnPauseOptions struct {
|
|
| 7 |
+ // Add future optional parameters here. |
|
| 8 |
+} |
|
| 9 |
+ |
|
| 10 |
+// ContainerUnPauseResult holds the result of [Client.ContainerUnpause], |
|
| 11 |
+type ContainerUnPauseResult struct {
|
|
| 12 |
+ // Add future fields here. |
|
| 13 |
+} |
|
| 14 |
+ |
|
| 5 | 15 |
// ContainerUnpause resumes the process execution within a container. |
| 6 |
-func (cli *Client) ContainerUnpause(ctx context.Context, containerID string) error {
|
|
| 16 |
+func (cli *Client) ContainerUnpause(ctx context.Context, containerID string, options ContainerUnPauseOptions) (ContainerUnPauseResult, error) {
|
|
| 7 | 17 |
containerID, err := trimID("container", containerID)
|
| 8 | 18 |
if err != nil {
|
| 9 |
- return err |
|
| 19 |
+ return ContainerUnPauseResult{}, err
|
|
| 10 | 20 |
} |
| 11 | 21 |
|
| 12 | 22 |
resp, err := cli.post(ctx, "/containers/"+containerID+"/unpause", nil, nil, nil) |
| 13 | 23 |
defer ensureReaderClosed(resp) |
| 14 |
- return err |
|
| 24 |
+ if err != nil {
|
|
| 25 |
+ return ContainerUnPauseResult{}, err
|
|
| 26 |
+ } |
|
| 27 |
+ return ContainerUnPauseResult{}, nil
|
|
| 15 | 28 |
} |