Browse code

api/types: move ContainerLogsOptions to api/types/container

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2023/08/26 07:19:21
Showing 30 changed files
... ...
@@ -7,8 +7,8 @@ import (
7 7
 	"net/url"
8 8
 	"sort"
9 9
 
10
-	"github.com/docker/docker/api/types"
11 10
 	"github.com/docker/docker/api/types/backend"
11
+	"github.com/docker/docker/api/types/container"
12 12
 	"github.com/docker/docker/pkg/ioutils"
13 13
 	"github.com/docker/docker/pkg/jsonmessage"
14 14
 	"github.com/docker/docker/pkg/stdcopy"
... ...
@@ -16,7 +16,7 @@ import (
16 16
 
17 17
 // WriteLogStream writes an encoded byte stream of log messages from the
18 18
 // messages channel, multiplexing them with a stdcopy.Writer if mux is true
19
-func WriteLogStream(_ context.Context, w io.Writer, msgs <-chan *backend.LogMessage, config *types.ContainerLogsOptions, mux bool) {
19
+func WriteLogStream(_ context.Context, w io.Writer, msgs <-chan *backend.LogMessage, config *container.LogsOptions, mux bool) {
20 20
 	wf := ioutils.NewWriteFlusher(w)
21 21
 	defer wf.Close()
22 22
 
... ...
@@ -50,7 +50,7 @@ type stateBackend interface {
50 50
 type monitorBackend interface {
51 51
 	ContainerChanges(ctx context.Context, name string) ([]archive.Change, error)
52 52
 	ContainerInspect(ctx context.Context, name string, size bool, version string) (interface{}, error)
53
-	ContainerLogs(ctx context.Context, name string, config *types.ContainerLogsOptions) (msgs <-chan *backend.LogMessage, tty bool, err error)
53
+	ContainerLogs(ctx context.Context, name string, config *container.LogsOptions) (msgs <-chan *backend.LogMessage, tty bool, err error)
54 54
 	ContainerStats(ctx context.Context, name string, config *backend.ContainerStatsConfig) error
55 55
 	ContainerTop(name string, psArgs string) (*container.ContainerTopOKBody, error)
56 56
 	Containers(ctx context.Context, config *container.ListOptions) ([]*types.Container, error)
... ...
@@ -142,7 +142,7 @@ func (s *containerRouter) getContainersLogs(ctx context.Context, w http.Response
142 142
 	}
143 143
 
144 144
 	containerName := vars["name"]
145
-	logsConfig := &types.ContainerLogsOptions{
145
+	logsConfig := &container.LogsOptions{
146 146
 		Follow:     httputils.BoolValue(r, "follow"),
147 147
 		Timestamps: httputils.BoolValue(r, "timestamps"),
148 148
 		Since:      r.Form.Get("since"),
... ...
@@ -5,6 +5,7 @@ import (
5 5
 
6 6
 	"github.com/docker/docker/api/types"
7 7
 	"github.com/docker/docker/api/types/backend"
8
+	"github.com/docker/docker/api/types/container"
8 9
 	"github.com/docker/docker/api/types/swarm"
9 10
 )
10 11
 
... ...
@@ -22,7 +23,7 @@ type Backend interface {
22 22
 	CreateService(swarm.ServiceSpec, string, bool) (*swarm.ServiceCreateResponse, error)
23 23
 	UpdateService(string, uint64, swarm.ServiceSpec, types.ServiceUpdateOptions, bool) (*swarm.ServiceUpdateResponse, error)
24 24
 	RemoveService(string) error
25
-	ServiceLogs(context.Context, *backend.LogSelector, *types.ContainerLogsOptions) (<-chan *backend.LogMessage, error)
25
+	ServiceLogs(context.Context, *backend.LogSelector, *container.LogsOptions) (<-chan *backend.LogMessage, error)
26 26
 	GetNodes(types.NodeListOptions) ([]swarm.Node, error)
27 27
 	GetNode(string) (swarm.Node, error)
28 28
 	UpdateNode(string, uint64, swarm.NodeSpec) error
... ...
@@ -8,6 +8,7 @@ import (
8 8
 	"github.com/docker/docker/api/server/httputils"
9 9
 	basictypes "github.com/docker/docker/api/types"
10 10
 	"github.com/docker/docker/api/types/backend"
11
+	"github.com/docker/docker/api/types/container"
11 12
 	"github.com/docker/docker/api/types/swarm"
12 13
 	"github.com/docker/docker/api/types/versions"
13 14
 )
... ...
@@ -25,9 +26,9 @@ func (sr *swarmRouter) swarmLogs(ctx context.Context, w http.ResponseWriter, r *
25 25
 		return fmt.Errorf("Bad parameters: you must choose at least one stream")
26 26
 	}
27 27
 
28
-	// there is probably a neater way to manufacture the ContainerLogsOptions
28
+	// there is probably a neater way to manufacture the LogsOptions
29 29
 	// struct, probably in the caller, to eliminate the dependency on net/http
30
-	logsConfig := &basictypes.ContainerLogsOptions{
30
+	logsConfig := &container.LogsOptions{
31 31
 		Follow:     httputils.BoolValue(r, "follow"),
32 32
 		Timestamps: httputils.BoolValue(r, "timestamps"),
33 33
 		Since:      r.Form.Get("since"),
... ...
@@ -20,18 +20,6 @@ type ContainerExecInspect struct {
20 20
 	Pid         int
21 21
 }
22 22
 
23
-// ContainerLogsOptions holds parameters to filter logs with.
24
-type ContainerLogsOptions struct {
25
-	ShowStdout bool
26
-	ShowStderr bool
27
-	Since      string
28
-	Until      string
29
-	Timestamps bool
30
-	Follow     bool
31
-	Tail       string
32
-	Details    bool
33
-}
34
-
35 23
 // CopyToContainerOptions holds information
36 24
 // about files to copy into a container
37 25
 type CopyToContainerOptions struct {
... ...
@@ -53,3 +53,15 @@ type ListOptions struct {
53 53
 	Limit   int
54 54
 	Filters filters.Args
55 55
 }
56
+
57
+// LogsOptions holds parameters to filter logs with.
58
+type LogsOptions struct {
59
+	ShowStdout bool
60
+	ShowStderr bool
61
+	Since      string
62
+	Until      string
63
+	Timestamps bool
64
+	Follow     bool
65
+	Tail       string
66
+	Details    bool
67
+}
... ...
@@ -119,6 +119,11 @@ type ContainerCommitOptions = container.CommitOptions
119 119
 // Deprecated: use [container.ListOptions].
120 120
 type ContainerListOptions = container.ListOptions
121 121
 
122
+// ContainerLogsOptions holds parameters to filter logs with.
123
+//
124
+// Deprecated: use [container.LogsOptions].
125
+type ContainerLogsOptions = container.LogsOptions
126
+
122 127
 // ContainerRemoveOptions holds parameters to remove containers.
123 128
 //
124 129
 // Deprecated: use [container.RemoveOptions].
... ...
@@ -6,7 +6,7 @@ import (
6 6
 	"net/url"
7 7
 	"time"
8 8
 
9
-	"github.com/docker/docker/api/types"
9
+	"github.com/docker/docker/api/types/container"
10 10
 	timetypes "github.com/docker/docker/api/types/time"
11 11
 	"github.com/pkg/errors"
12 12
 )
... ...
@@ -33,7 +33,7 @@ import (
33 33
 //
34 34
 // You can use github.com/docker/docker/pkg/stdcopy.StdCopy to demultiplex this
35 35
 // stream.
36
-func (cli *Client) ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error) {
36
+func (cli *Client) ContainerLogs(ctx context.Context, container string, options container.LogsOptions) (io.ReadCloser, error) {
37 37
 	query := url.Values{}
38 38
 	if options.ShowStdout {
39 39
 		query.Set("stdout", "1")
... ...
@@ -12,7 +12,7 @@ import (
12 12
 	"testing"
13 13
 	"time"
14 14
 
15
-	"github.com/docker/docker/api/types"
15
+	"github.com/docker/docker/api/types/container"
16 16
 	"github.com/docker/docker/errdefs"
17 17
 	"gotest.tools/v3/assert"
18 18
 	is "gotest.tools/v3/assert/cmp"
... ...
@@ -22,7 +22,7 @@ func TestContainerLogsNotFoundError(t *testing.T) {
22 22
 	client := &Client{
23 23
 		client: newMockClient(errorMock(http.StatusNotFound, "Not found")),
24 24
 	}
25
-	_, err := client.ContainerLogs(context.Background(), "container_id", types.ContainerLogsOptions{})
25
+	_, err := client.ContainerLogs(context.Background(), "container_id", container.LogsOptions{})
26 26
 	assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
27 27
 }
28 28
 
... ...
@@ -30,14 +30,14 @@ func TestContainerLogsError(t *testing.T) {
30 30
 	client := &Client{
31 31
 		client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
32 32
 	}
33
-	_, err := client.ContainerLogs(context.Background(), "container_id", types.ContainerLogsOptions{})
33
+	_, err := client.ContainerLogs(context.Background(), "container_id", container.LogsOptions{})
34 34
 	assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
35 35
 
36
-	_, err = client.ContainerLogs(context.Background(), "container_id", types.ContainerLogsOptions{
36
+	_, err = client.ContainerLogs(context.Background(), "container_id", container.LogsOptions{
37 37
 		Since: "2006-01-02TZ",
38 38
 	})
39 39
 	assert.Check(t, is.ErrorContains(err, `parsing time "2006-01-02TZ"`))
40
-	_, err = client.ContainerLogs(context.Background(), "container_id", types.ContainerLogsOptions{
40
+	_, err = client.ContainerLogs(context.Background(), "container_id", container.LogsOptions{
41 41
 		Until: "2006-01-02TZ",
42 42
 	})
43 43
 	assert.Check(t, is.ErrorContains(err, `parsing time "2006-01-02TZ"`))
... ...
@@ -46,7 +46,7 @@ func TestContainerLogsError(t *testing.T) {
46 46
 func TestContainerLogs(t *testing.T) {
47 47
 	expectedURL := "/containers/container_id/logs"
48 48
 	cases := []struct {
49
-		options             types.ContainerLogsOptions
49
+		options             container.LogsOptions
50 50
 		expectedQueryParams map[string]string
51 51
 		expectedError       string
52 52
 	}{
... ...
@@ -56,7 +56,7 @@ func TestContainerLogs(t *testing.T) {
56 56
 			},
57 57
 		},
58 58
 		{
59
-			options: types.ContainerLogsOptions{
59
+			options: container.LogsOptions{
60 60
 				Tail: "any",
61 61
 			},
62 62
 			expectedQueryParams: map[string]string{
... ...
@@ -64,7 +64,7 @@ func TestContainerLogs(t *testing.T) {
64 64
 			},
65 65
 		},
66 66
 		{
67
-			options: types.ContainerLogsOptions{
67
+			options: container.LogsOptions{
68 68
 				ShowStdout: true,
69 69
 				ShowStderr: true,
70 70
 				Timestamps: true,
... ...
@@ -81,7 +81,7 @@ func TestContainerLogs(t *testing.T) {
81 81
 			},
82 82
 		},
83 83
 		{
84
-			options: types.ContainerLogsOptions{
84
+			options: container.LogsOptions{
85 85
 				// timestamp will be passed as is
86 86
 				Since: "1136073600.000000001",
87 87
 			},
... ...
@@ -91,7 +91,7 @@ func TestContainerLogs(t *testing.T) {
91 91
 			},
92 92
 		},
93 93
 		{
94
-			options: types.ContainerLogsOptions{
94
+			options: container.LogsOptions{
95 95
 				// timestamp will be passed as is
96 96
 				Until: "1136073600.000000001",
97 97
 			},
... ...
@@ -101,14 +101,14 @@ func TestContainerLogs(t *testing.T) {
101 101
 			},
102 102
 		},
103 103
 		{
104
-			options: types.ContainerLogsOptions{
104
+			options: container.LogsOptions{
105 105
 				// An complete invalid date will not be passed
106 106
 				Since: "invalid value",
107 107
 			},
108 108
 			expectedError: `invalid value for "since": failed to parse value as time or duration: "invalid value"`,
109 109
 		},
110 110
 		{
111
-			options: types.ContainerLogsOptions{
111
+			options: container.LogsOptions{
112 112
 				// An complete invalid date will not be passed
113 113
 				Until: "invalid value",
114 114
 			},
... ...
@@ -153,7 +153,7 @@ func ExampleClient_ContainerLogs_withTimeout() {
153 153
 	defer cancel()
154 154
 
155 155
 	client, _ := NewClientWithOpts(FromEnv)
156
-	reader, err := client.ContainerLogs(ctx, "container_id", types.ContainerLogsOptions{})
156
+	reader, err := client.ContainerLogs(ctx, "container_id", container.LogsOptions{})
157 157
 	if err != nil {
158 158
 		log.Fatal(err)
159 159
 	}
... ...
@@ -60,7 +60,7 @@ type ContainerAPIClient interface {
60 60
 	ContainerInspectWithRaw(ctx context.Context, container string, getSize bool) (types.ContainerJSON, []byte, error)
61 61
 	ContainerKill(ctx context.Context, container, signal string) error
62 62
 	ContainerList(ctx context.Context, options container.ListOptions) ([]types.Container, error)
63
-	ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error)
63
+	ContainerLogs(ctx context.Context, container string, options container.LogsOptions) (io.ReadCloser, error)
64 64
 	ContainerPause(ctx context.Context, container string) error
65 65
 	ContainerRemove(ctx context.Context, container string, options container.RemoveOptions) error
66 66
 	ContainerRename(ctx context.Context, container, newContainerName string) error
... ...
@@ -146,8 +146,8 @@ type ServiceAPIClient interface {
146 146
 	ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error)
147 147
 	ServiceRemove(ctx context.Context, serviceID string) error
148 148
 	ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
149
-	ServiceLogs(ctx context.Context, serviceID string, options types.ContainerLogsOptions) (io.ReadCloser, error)
150
-	TaskLogs(ctx context.Context, taskID string, options types.ContainerLogsOptions) (io.ReadCloser, error)
149
+	ServiceLogs(ctx context.Context, serviceID string, options container.LogsOptions) (io.ReadCloser, error)
150
+	TaskLogs(ctx context.Context, taskID string, options container.LogsOptions) (io.ReadCloser, error)
151 151
 	TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error)
152 152
 	TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error)
153 153
 }
... ...
@@ -6,14 +6,14 @@ import (
6 6
 	"net/url"
7 7
 	"time"
8 8
 
9
-	"github.com/docker/docker/api/types"
9
+	"github.com/docker/docker/api/types/container"
10 10
 	timetypes "github.com/docker/docker/api/types/time"
11 11
 	"github.com/pkg/errors"
12 12
 )
13 13
 
14 14
 // ServiceLogs returns the logs generated by a service in an io.ReadCloser.
15 15
 // It's up to the caller to close the stream.
16
-func (cli *Client) ServiceLogs(ctx context.Context, serviceID string, options types.ContainerLogsOptions) (io.ReadCloser, error) {
16
+func (cli *Client) ServiceLogs(ctx context.Context, serviceID string, options container.LogsOptions) (io.ReadCloser, error) {
17 17
 	query := url.Values{}
18 18
 	if options.ShowStdout {
19 19
 		query.Set("stdout", "1")
... ...
@@ -12,7 +12,7 @@ import (
12 12
 	"testing"
13 13
 	"time"
14 14
 
15
-	"github.com/docker/docker/api/types"
15
+	"github.com/docker/docker/api/types/container"
16 16
 	"github.com/docker/docker/errdefs"
17 17
 	"gotest.tools/v3/assert"
18 18
 	is "gotest.tools/v3/assert/cmp"
... ...
@@ -22,10 +22,10 @@ func TestServiceLogsError(t *testing.T) {
22 22
 	client := &Client{
23 23
 		client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
24 24
 	}
25
-	_, err := client.ServiceLogs(context.Background(), "service_id", types.ContainerLogsOptions{})
25
+	_, err := client.ServiceLogs(context.Background(), "service_id", container.LogsOptions{})
26 26
 	assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
27 27
 
28
-	_, err = client.ServiceLogs(context.Background(), "service_id", types.ContainerLogsOptions{
28
+	_, err = client.ServiceLogs(context.Background(), "service_id", container.LogsOptions{
29 29
 		Since: "2006-01-02TZ",
30 30
 	})
31 31
 	assert.Check(t, is.ErrorContains(err, `parsing time "2006-01-02TZ"`))
... ...
@@ -34,7 +34,7 @@ func TestServiceLogsError(t *testing.T) {
34 34
 func TestServiceLogs(t *testing.T) {
35 35
 	expectedURL := "/services/service_id/logs"
36 36
 	cases := []struct {
37
-		options             types.ContainerLogsOptions
37
+		options             container.LogsOptions
38 38
 		expectedQueryParams map[string]string
39 39
 		expectedError       string
40 40
 	}{
... ...
@@ -44,7 +44,7 @@ func TestServiceLogs(t *testing.T) {
44 44
 			},
45 45
 		},
46 46
 		{
47
-			options: types.ContainerLogsOptions{
47
+			options: container.LogsOptions{
48 48
 				Tail: "any",
49 49
 			},
50 50
 			expectedQueryParams: map[string]string{
... ...
@@ -52,7 +52,7 @@ func TestServiceLogs(t *testing.T) {
52 52
 			},
53 53
 		},
54 54
 		{
55
-			options: types.ContainerLogsOptions{
55
+			options: container.LogsOptions{
56 56
 				ShowStdout: true,
57 57
 				ShowStderr: true,
58 58
 				Timestamps: true,
... ...
@@ -69,7 +69,7 @@ func TestServiceLogs(t *testing.T) {
69 69
 			},
70 70
 		},
71 71
 		{
72
-			options: types.ContainerLogsOptions{
72
+			options: container.LogsOptions{
73 73
 				// timestamp will be passed as is
74 74
 				Since: "1136073600.000000001",
75 75
 			},
... ...
@@ -79,7 +79,7 @@ func TestServiceLogs(t *testing.T) {
79 79
 			},
80 80
 		},
81 81
 		{
82
-			options: types.ContainerLogsOptions{
82
+			options: container.LogsOptions{
83 83
 				// An complete invalid date will not be passed
84 84
 				Since: "invalid value",
85 85
 			},
... ...
@@ -124,7 +124,7 @@ func ExampleClient_ServiceLogs_withTimeout() {
124 124
 	defer cancel()
125 125
 
126 126
 	client, _ := NewClientWithOpts(FromEnv)
127
-	reader, err := client.ServiceLogs(ctx, "service_id", types.ContainerLogsOptions{})
127
+	reader, err := client.ServiceLogs(ctx, "service_id", container.LogsOptions{})
128 128
 	if err != nil {
129 129
 		log.Fatal(err)
130 130
 	}
... ...
@@ -6,13 +6,13 @@ import (
6 6
 	"net/url"
7 7
 	"time"
8 8
 
9
-	"github.com/docker/docker/api/types"
9
+	"github.com/docker/docker/api/types/container"
10 10
 	timetypes "github.com/docker/docker/api/types/time"
11 11
 )
12 12
 
13 13
 // TaskLogs returns the logs generated by a task in an io.ReadCloser.
14 14
 // It's up to the caller to close the stream.
15
-func (cli *Client) TaskLogs(ctx context.Context, taskID string, options types.ContainerLogsOptions) (io.ReadCloser, error) {
15
+func (cli *Client) TaskLogs(ctx context.Context, taskID string, options container.LogsOptions) (io.ReadCloser, error) {
16 16
 	query := url.Values{}
17 17
 	if options.ShowStdout {
18 18
 		query.Set("stdout", "1")
... ...
@@ -41,7 +41,7 @@ type Backend interface {
41 41
 	CreateManagedContainer(ctx context.Context, config types.ContainerCreateConfig) (container.CreateResponse, error)
42 42
 	ContainerStart(ctx context.Context, name string, hostConfig *container.HostConfig, checkpoint string, checkpointDir string) error
43 43
 	ContainerStop(ctx context.Context, name string, config container.StopOptions) error
44
-	ContainerLogs(ctx context.Context, name string, config *types.ContainerLogsOptions) (msgs <-chan *backend.LogMessage, tty bool, err error)
44
+	ContainerLogs(ctx context.Context, name string, config *container.LogsOptions) (msgs <-chan *backend.LogMessage, tty bool, err error)
45 45
 	ConnectContainerToNetwork(containerName, networkName string, endpointConfig *network.EndpointSettings) error
46 46
 	ActivateContainerServiceBinding(containerName string) error
47 47
 	DeactivateContainerServiceBinding(containerName string) error
... ...
@@ -489,7 +489,7 @@ func (c *containerAdapter) deactivateServiceBinding() error {
489 489
 }
490 490
 
491 491
 func (c *containerAdapter) logs(ctx context.Context, options api.LogSubscriptionOptions) (<-chan *backend.LogMessage, error) {
492
-	apiOptions := &types.ContainerLogsOptions{
492
+	apiOptions := &containertypes.LogsOptions{
493 493
 		Follow: options.Follow,
494 494
 
495 495
 		// Always say yes to Timestamps and Details. we make the decision
... ...
@@ -15,6 +15,7 @@ import (
15 15
 	"github.com/distribution/reference"
16 16
 	"github.com/docker/docker/api/types"
17 17
 	"github.com/docker/docker/api/types/backend"
18
+	"github.com/docker/docker/api/types/container"
18 19
 	"github.com/docker/docker/api/types/registry"
19 20
 	"github.com/docker/docker/api/types/swarm"
20 21
 	timetypes "github.com/docker/docker/api/types/time"
... ...
@@ -422,7 +423,7 @@ func (c *Cluster) RemoveService(input string) error {
422 422
 }
423 423
 
424 424
 // ServiceLogs collects service logs and writes them back to `config.OutStream`
425
-func (c *Cluster) ServiceLogs(ctx context.Context, selector *backend.LogSelector, config *types.ContainerLogsOptions) (<-chan *backend.LogMessage, error) {
425
+func (c *Cluster) ServiceLogs(ctx context.Context, selector *backend.LogSelector, config *container.LogsOptions) (<-chan *backend.LogMessage, error) {
426 426
 	c.mu.RLock()
427 427
 	defer c.mu.RUnlock()
428 428
 
... ...
@@ -6,7 +6,6 @@ import (
6 6
 	"time"
7 7
 
8 8
 	"github.com/containerd/log"
9
-	"github.com/docker/docker/api/types"
10 9
 	"github.com/docker/docker/api/types/backend"
11 10
 	containertypes "github.com/docker/docker/api/types/container"
12 11
 	timetypes "github.com/docker/docker/api/types/time"
... ...
@@ -24,7 +23,7 @@ import (
24 24
 //
25 25
 // if it returns nil, the config channel will be active and return log
26 26
 // messages until it runs out or the context is canceled.
27
-func (daemon *Daemon) ContainerLogs(ctx context.Context, containerName string, config *types.ContainerLogsOptions) (messages <-chan *backend.LogMessage, isTTY bool, retErr error) {
27
+func (daemon *Daemon) ContainerLogs(ctx context.Context, containerName string, config *containertypes.LogsOptions) (messages <-chan *backend.LogMessage, isTTY bool, retErr error) {
28 28
 	lg := log.G(ctx).WithFields(log.Fields{
29 29
 		"module":    "daemon",
30 30
 		"method":    "(*Daemon).ContainerLogs",
... ...
@@ -11,7 +11,7 @@ import (
11 11
 	"testing"
12 12
 	"time"
13 13
 
14
-	"github.com/docker/docker/api/types"
14
+	"github.com/docker/docker/api/types/container"
15 15
 	"github.com/docker/docker/client"
16 16
 	"github.com/docker/docker/pkg/stdcopy"
17 17
 	"github.com/docker/docker/testutil"
... ...
@@ -62,7 +62,7 @@ func (s *DockerAPISuite) TestLogsAPINoStdoutNorStderr(c *testing.T) {
62 62
 	assert.NilError(c, err)
63 63
 	defer apiClient.Close()
64 64
 
65
-	_, err = apiClient.ContainerLogs(testutil.GetContext(c), name, types.ContainerLogsOptions{})
65
+	_, err = apiClient.ContainerLogs(testutil.GetContext(c), name, container.LogsOptions{})
66 66
 	assert.ErrorContains(c, err, "Bad parameters: you must choose at least one stream")
67 67
 }
68 68
 
... ...
@@ -105,8 +105,12 @@ func (s *DockerAPISuite) TestLogsAPIUntilFutureFollow(c *testing.T) {
105 105
 		c.Fatal(err)
106 106
 	}
107 107
 
108
-	cfg := types.ContainerLogsOptions{Until: until.Format(time.RFC3339Nano), Follow: true, ShowStdout: true, Timestamps: true}
109
-	reader, err := client.ContainerLogs(testutil.GetContext(c), name, cfg)
108
+	reader, err := client.ContainerLogs(testutil.GetContext(c), name, container.LogsOptions{
109
+		Until:      until.Format(time.RFC3339Nano),
110
+		Follow:     true,
111
+		ShowStdout: true,
112
+		Timestamps: true,
113
+	})
110 114
 	assert.NilError(c, err)
111 115
 
112 116
 	type logOut struct {
... ...
@@ -167,7 +171,7 @@ func (s *DockerAPISuite) TestLogsAPIUntil(c *testing.T) {
167 167
 		c.Fatal(err)
168 168
 	}
169 169
 
170
-	extractBody := func(c *testing.T, cfg types.ContainerLogsOptions) []string {
170
+	extractBody := func(c *testing.T, cfg container.LogsOptions) []string {
171 171
 		reader, err := client.ContainerLogs(testutil.GetContext(c), name, cfg)
172 172
 		assert.NilError(c, err)
173 173
 
... ...
@@ -180,7 +184,7 @@ func (s *DockerAPISuite) TestLogsAPIUntil(c *testing.T) {
180 180
 	}
181 181
 
182 182
 	// Get timestamp of second log line
183
-	allLogs := extractBody(c, types.ContainerLogsOptions{Timestamps: true, ShowStdout: true})
183
+	allLogs := extractBody(c, container.LogsOptions{Timestamps: true, ShowStdout: true})
184 184
 	assert.Assert(c, len(allLogs) >= 3)
185 185
 
186 186
 	t, err := time.Parse(time.RFC3339Nano, strings.Split(allLogs[1], " ")[0])
... ...
@@ -188,7 +192,7 @@ func (s *DockerAPISuite) TestLogsAPIUntil(c *testing.T) {
188 188
 	until := t.Format(time.RFC3339Nano)
189 189
 
190 190
 	// Get logs until the timestamp of second line, i.e. first two lines
191
-	logs := extractBody(c, types.ContainerLogsOptions{Timestamps: true, ShowStdout: true, Until: until})
191
+	logs := extractBody(c, container.LogsOptions{Timestamps: true, ShowStdout: true, Until: until})
192 192
 
193 193
 	// Ensure log lines after cut-off are excluded
194 194
 	logsString := strings.Join(logs, "\n")
... ...
@@ -204,7 +208,7 @@ func (s *DockerAPISuite) TestLogsAPIUntilDefaultValue(c *testing.T) {
204 204
 		c.Fatal(err)
205 205
 	}
206 206
 
207
-	extractBody := func(c *testing.T, cfg types.ContainerLogsOptions) []string {
207
+	extractBody := func(c *testing.T, cfg container.LogsOptions) []string {
208 208
 		reader, err := client.ContainerLogs(testutil.GetContext(c), name, cfg)
209 209
 		assert.NilError(c, err)
210 210
 
... ...
@@ -217,9 +221,9 @@ func (s *DockerAPISuite) TestLogsAPIUntilDefaultValue(c *testing.T) {
217 217
 	}
218 218
 
219 219
 	// Get timestamp of second log line
220
-	allLogs := extractBody(c, types.ContainerLogsOptions{Timestamps: true, ShowStdout: true})
220
+	allLogs := extractBody(c, container.LogsOptions{Timestamps: true, ShowStdout: true})
221 221
 
222 222
 	// Test with default value specified and parameter omitted
223
-	defaultLogs := extractBody(c, types.ContainerLogsOptions{Timestamps: true, ShowStdout: true, Until: "0"})
223
+	defaultLogs := extractBody(c, container.LogsOptions{Timestamps: true, ShowStdout: true, Until: "0"})
224 224
 	assert.DeepEqual(c, defaultLogs, allLogs)
225 225
 }
... ...
@@ -7,6 +7,7 @@ import (
7 7
 	"testing"
8 8
 
9 9
 	"github.com/docker/docker/api/types"
10
+	containertypes "github.com/docker/docker/api/types/container"
10 11
 	dclient "github.com/docker/docker/client"
11 12
 	"github.com/docker/docker/integration/internal/container"
12 13
 	"github.com/docker/docker/pkg/stdcopy"
... ...
@@ -84,7 +85,7 @@ func TestBuildSquashParent(t *testing.T) {
84 84
 		container.WithImage(name),
85 85
 		container.WithCmd("/bin/sh", "-c", "cat /hello"),
86 86
 	)
87
-	reader, err := client.ContainerLogs(ctx, cid, types.ContainerLogsOptions{
87
+	reader, err := client.ContainerLogs(ctx, cid, containertypes.LogsOptions{
88 88
 		ShowStdout: true,
89 89
 	})
90 90
 	assert.NilError(t, err)
... ...
@@ -9,6 +9,7 @@ import (
9 9
 	"testing"
10 10
 
11 11
 	"github.com/docker/docker/api/types"
12
+	containertypes "github.com/docker/docker/api/types/container"
12 13
 	"github.com/docker/docker/integration/internal/container"
13 14
 	"github.com/docker/docker/pkg/jsonmessage"
14 15
 	"github.com/docker/docker/pkg/stdcopy"
... ...
@@ -116,7 +117,7 @@ func TestBuildUserNamespaceValidateCapabilitiesAreV2(t *testing.T) {
116 116
 		container.WithImage(imageTag),
117 117
 		container.WithCmd("/sbin/getcap", "-n", "/bin/sleep"),
118 118
 	)
119
-	logReader, err := clientNoUserRemap.ContainerLogs(ctx, cid, types.ContainerLogsOptions{
119
+	logReader, err := clientNoUserRemap.ContainerLogs(ctx, cid, containertypes.LogsOptions{
120 120
 		ShowStdout: true,
121 121
 	})
122 122
 	assert.NilError(t, err)
... ...
@@ -8,6 +8,7 @@ import (
8 8
 	"time"
9 9
 
10 10
 	"github.com/docker/docker/api/types"
11
+	containertypes "github.com/docker/docker/api/types/container"
11 12
 	"github.com/docker/docker/integration/internal/container"
12 13
 	"github.com/docker/docker/pkg/stdcopy"
13 14
 	"github.com/docker/docker/testutil"
... ...
@@ -83,7 +84,7 @@ func TestNoNewPrivileges(t *testing.T) {
83 83
 			poll.WaitOn(t, container.IsInState(ctx, client, cid, "exited"), poll.WithDelay(100*time.Millisecond))
84 84
 
85 85
 			// Assert on outputs
86
-			logReader, err := client.ContainerLogs(ctx, cid, types.ContainerLogsOptions{
86
+			logReader, err := client.ContainerLogs(ctx, cid, containertypes.LogsOptions{
87 87
 				ShowStdout: true,
88 88
 				ShowStderr: true,
89 89
 			})
... ...
@@ -9,7 +9,6 @@ import (
9 9
 	"strings"
10 10
 	"testing"
11 11
 
12
-	"github.com/docker/docker/api/types"
13 12
 	containertypes "github.com/docker/docker/api/types/container"
14 13
 	"github.com/docker/docker/integration/internal/container"
15 14
 	"github.com/docker/docker/pkg/stdcopy"
... ...
@@ -51,7 +50,7 @@ func TestCreateWithCDIDevices(t *testing.T) {
51 51
 	}
52 52
 	assert.Check(t, is.DeepEqual(inspect.HostConfig.DeviceRequests, expectedRequests))
53 53
 
54
-	reader, err := apiClient.ContainerLogs(ctx, id, types.ContainerLogsOptions{
54
+	reader, err := apiClient.ContainerLogs(ctx, id, containertypes.LogsOptions{
55 55
 		ShowStdout: true,
56 56
 	})
57 57
 	assert.NilError(t, err)
... ...
@@ -7,7 +7,6 @@ import (
7 7
 	"testing"
8 8
 	"time"
9 9
 
10
-	"github.com/docker/docker/api/types"
11 10
 	containertypes "github.com/docker/docker/api/types/container"
12 11
 	"github.com/docker/docker/daemon/logger/jsonfilelog"
13 12
 	"github.com/docker/docker/daemon/logger/local"
... ...
@@ -30,7 +29,7 @@ func TestLogsFollowTailEmpty(t *testing.T) {
30 30
 
31 31
 	id := container.Run(ctx, t, apiClient, container.WithCmd("sleep", "100000"))
32 32
 
33
-	logs, err := apiClient.ContainerLogs(ctx, id, types.ContainerLogsOptions{ShowStdout: true, Tail: "2"})
33
+	logs, err := apiClient.ContainerLogs(ctx, id, containertypes.LogsOptions{ShowStdout: true, Tail: "2"})
34 34
 	if logs != nil {
35 35
 		defer logs.Close()
36 36
 	}
... ...
@@ -56,7 +55,7 @@ func testLogs(t *testing.T, logDriver string) {
56 56
 
57 57
 	testCases := []struct {
58 58
 		desc        string
59
-		logOps      types.ContainerLogsOptions
59
+		logOps      containertypes.LogsOptions
60 60
 		expectedOut string
61 61
 		expectedErr string
62 62
 		tty         bool
... ...
@@ -65,7 +64,7 @@ func testLogs(t *testing.T, logDriver string) {
65 65
 		{
66 66
 			desc: "tty/stdout and stderr",
67 67
 			tty:  true,
68
-			logOps: types.ContainerLogsOptions{
68
+			logOps: containertypes.LogsOptions{
69 69
 				ShowStdout: true,
70 70
 				ShowStderr: true,
71 71
 			},
... ...
@@ -74,7 +73,7 @@ func testLogs(t *testing.T, logDriver string) {
74 74
 		{
75 75
 			desc: "tty/only stdout",
76 76
 			tty:  true,
77
-			logOps: types.ContainerLogsOptions{
77
+			logOps: containertypes.LogsOptions{
78 78
 				ShowStdout: true,
79 79
 				ShowStderr: false,
80 80
 			},
... ...
@@ -83,7 +82,7 @@ func testLogs(t *testing.T, logDriver string) {
83 83
 		{
84 84
 			desc: "tty/only stderr",
85 85
 			tty:  true,
86
-			logOps: types.ContainerLogsOptions{
86
+			logOps: containertypes.LogsOptions{
87 87
 				ShowStdout: false,
88 88
 				ShowStderr: true,
89 89
 			},
... ...
@@ -93,7 +92,7 @@ func testLogs(t *testing.T, logDriver string) {
93 93
 		{
94 94
 			desc: "without tty/stdout and stderr",
95 95
 			tty:  false,
96
-			logOps: types.ContainerLogsOptions{
96
+			logOps: containertypes.LogsOptions{
97 97
 				ShowStdout: true,
98 98
 				ShowStderr: true,
99 99
 			},
... ...
@@ -103,7 +102,7 @@ func testLogs(t *testing.T, logDriver string) {
103 103
 		{
104 104
 			desc: "without tty/only stdout",
105 105
 			tty:  false,
106
-			logOps: types.ContainerLogsOptions{
106
+			logOps: containertypes.LogsOptions{
107 107
 				ShowStdout: true,
108 108
 				ShowStderr: false,
109 109
 			},
... ...
@@ -113,7 +112,7 @@ func testLogs(t *testing.T, logDriver string) {
113 113
 		{
114 114
 			desc: "without tty/only stderr",
115 115
 			tty:  false,
116
-			logOps: types.ContainerLogsOptions{
116
+			logOps: containertypes.LogsOptions{
117 117
 				ShowStdout: false,
118 118
 				ShowStderr: true,
119 119
 			},
... ...
@@ -10,7 +10,7 @@ import (
10 10
 	"testing"
11 11
 	"time"
12 12
 
13
-	"github.com/docker/docker/api/types"
13
+	containertypes "github.com/docker/docker/api/types/container"
14 14
 	"github.com/docker/docker/integration/internal/container"
15 15
 	"github.com/docker/go-connections/nat"
16 16
 	"gotest.tools/v3/assert"
... ...
@@ -77,7 +77,7 @@ func TestNetworkLoopbackNat(t *testing.T) {
77 77
 
78 78
 	poll.WaitOn(t, container.IsStopped(ctx, apiClient, cID), poll.WithDelay(100*time.Millisecond))
79 79
 
80
-	body, err := apiClient.ContainerLogs(ctx, cID, types.ContainerLogsOptions{
80
+	body, err := apiClient.ContainerLogs(ctx, cID, containertypes.LogsOptions{
81 81
 		ShowStdout: true,
82 82
 	})
83 83
 	assert.NilError(t, err)
... ...
@@ -10,7 +10,6 @@ import (
10 10
 	"testing"
11 11
 	"time"
12 12
 
13
-	"github.com/docker/docker/api/types"
14 13
 	containertypes "github.com/docker/docker/api/types/container"
15 14
 	"github.com/docker/docker/api/types/versions"
16 15
 	"github.com/docker/docker/integration/internal/container"
... ...
@@ -191,7 +190,7 @@ func TestRunConsoleSize(t *testing.T) {
191 191
 
192 192
 	poll.WaitOn(t, container.IsStopped(ctx, apiClient, cID), poll.WithDelay(100*time.Millisecond))
193 193
 
194
-	out, err := apiClient.ContainerLogs(ctx, cID, types.ContainerLogsOptions{ShowStdout: true})
194
+	out, err := apiClient.ContainerLogs(ctx, cID, containertypes.LogsOptions{ShowStdout: true})
195 195
 	assert.NilError(t, err)
196 196
 	defer out.Close()
197 197
 
... ...
@@ -246,7 +245,7 @@ func TestRunWithAlternativeContainerdShim(t *testing.T) {
246 246
 
247 247
 	poll.WaitOn(t, container.IsStopped(ctx, apiClient, cID), poll.WithDelay(100*time.Millisecond))
248 248
 
249
-	out, err := apiClient.ContainerLogs(ctx, cID, types.ContainerLogsOptions{ShowStdout: true})
249
+	out, err := apiClient.ContainerLogs(ctx, cID, containertypes.LogsOptions{ShowStdout: true})
250 250
 	assert.NilError(t, err)
251 251
 	defer out.Close()
252 252
 
... ...
@@ -266,7 +265,7 @@ func TestRunWithAlternativeContainerdShim(t *testing.T) {
266 266
 
267 267
 	poll.WaitOn(t, container.IsStopped(ctx, apiClient, cID), poll.WithDelay(100*time.Millisecond))
268 268
 
269
-	out, err = apiClient.ContainerLogs(ctx, cID, types.ContainerLogsOptions{ShowStdout: true})
269
+	out, err = apiClient.ContainerLogs(ctx, cID, containertypes.LogsOptions{ShowStdout: true})
270 270
 	assert.NilError(t, err)
271 271
 	defer out.Close()
272 272
 
... ...
@@ -9,7 +9,6 @@ import (
9 9
 	"testing"
10 10
 	"time"
11 11
 
12
-	"github.com/docker/docker/api/types"
13 12
 	containertypes "github.com/docker/docker/api/types/container"
14 13
 	"github.com/docker/docker/client"
15 14
 	"github.com/docker/docker/errdefs"
... ...
@@ -128,7 +127,7 @@ func TestStopContainerWithTimeoutCancel(t *testing.T) {
128 128
 // logsContains verifies the container contains the given text in the log's stdout.
129 129
 func logsContains(ctx context.Context, client client.APIClient, containerID string, logString string) func(log poll.LogT) poll.Result {
130 130
 	return func(log poll.LogT) poll.Result {
131
-		logs, err := client.ContainerLogs(ctx, containerID, types.ContainerLogsOptions{
131
+		logs, err := client.ContainerLogs(ctx, containerID, containertypes.LogsOptions{
132 132
 			ShowStdout: true,
133 133
 		})
134 134
 		if err != nil {
... ...
@@ -493,7 +493,7 @@ func testLiveRestoreVolumeReferences(t *testing.T) {
493 493
 				assert.Check(t, is.Equal(inspect.State.ExitCode, 0), "volume doesn't have the same file")
494 494
 			}
495 495
 
496
-			logs, err := c.ContainerLogs(ctx, cID2, types.ContainerLogsOptions{ShowStdout: true})
496
+			logs, err := c.ContainerLogs(ctx, cID2, containertypes.LogsOptions{ShowStdout: true})
497 497
 			assert.NilError(t, err)
498 498
 			defer logs.Close()
499 499
 
... ...
@@ -65,7 +65,7 @@ func TestReadPluginNoRead(t *testing.T) {
65 65
 			err = client.ContainerStart(ctx, c.ID, container.StartOptions{})
66 66
 			assert.Assert(t, err)
67 67
 
68
-			logs, err := client.ContainerLogs(ctx, c.ID, types.ContainerLogsOptions{ShowStdout: true})
68
+			logs, err := client.ContainerLogs(ctx, c.ID, container.LogsOptions{ShowStdout: true})
69 69
 			if !test.logsSupported {
70 70
 				assert.Assert(t, err != nil)
71 71
 				return
... ...
@@ -231,7 +231,7 @@ func TestCreateServiceSecretFileMode(t *testing.T) {
231 231
 
232 232
 	poll.WaitOn(t, swarm.RunningTasksCount(ctx, client, serviceID, instances), swarm.ServicePoll)
233 233
 
234
-	body, err := client.ServiceLogs(ctx, serviceID, types.ContainerLogsOptions{
234
+	body, err := client.ServiceLogs(ctx, serviceID, container.LogsOptions{
235 235
 		Tail:       "1",
236 236
 		ShowStdout: true,
237 237
 	})
... ...
@@ -288,7 +288,7 @@ func TestCreateServiceConfigFileMode(t *testing.T) {
288 288
 
289 289
 	poll.WaitOn(t, swarm.RunningTasksCount(ctx, client, serviceID, instances))
290 290
 
291
-	body, err := client.ServiceLogs(ctx, serviceID, types.ContainerLogsOptions{
291
+	body, err := client.ServiceLogs(ctx, serviceID, container.LogsOptions{
292 292
 		Tail:       "1",
293 293
 		ShowStdout: true,
294 294
 	})