Browse code

client: move container options together with their users

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

Sebastiaan van Stijn authored on 2025/09/05 00:56:11
Showing 14 changed files
... ...
@@ -6,6 +6,16 @@ import (
6 6
 	"net/url"
7 7
 )
8 8
 
9
+// ContainerAttachOptions holds parameters to attach to a container.
10
+type ContainerAttachOptions struct {
11
+	Stream     bool
12
+	Stdin      bool
13
+	Stdout     bool
14
+	Stderr     bool
15
+	DetachKeys string
16
+	Logs       bool
17
+}
18
+
9 19
 // ContainerAttach attaches a connection to a container in the server.
10 20
 // It returns a [HijackedResponse] with the hijacked connection
11 21
 // and a reader to get output. It's up to the called to close
... ...
@@ -10,6 +10,16 @@ import (
10 10
 	"github.com/moby/moby/api/types/container"
11 11
 )
12 12
 
13
+// ContainerCommitOptions holds parameters to commit changes into a container.
14
+type ContainerCommitOptions struct {
15
+	Reference string
16
+	Comment   string
17
+	Author    string
18
+	Changes   []string
19
+	Pause     bool
20
+	Config    *container.Config
21
+}
22
+
13 23
 // ContainerCommit applies changes to a container and creates a new tagged image.
14 24
 func (cli *Client) ContainerCommit(ctx context.Context, containerID string, options ContainerCommitOptions) (container.CommitResponse, error) {
15 25
 	containerID, err := trimID("container", containerID)
... ...
@@ -11,6 +11,17 @@ import (
11 11
 	"github.com/moby/moby/api/types/versions"
12 12
 )
13 13
 
14
+// ContainerListOptions holds parameters to list containers with.
15
+type ContainerListOptions struct {
16
+	Size    bool
17
+	All     bool
18
+	Latest  bool
19
+	Since   string
20
+	Before  string
21
+	Limit   int
22
+	Filters filters.Args
23
+}
24
+
14 25
 // ContainerList returns the list of containers in the docker host.
15 26
 func (cli *Client) ContainerList(ctx context.Context, options ContainerListOptions) ([]container.Summary, error) {
16 27
 	query := url.Values{}
... ...
@@ -10,6 +10,18 @@ import (
10 10
 	"github.com/moby/moby/client/internal/timestamp"
11 11
 )
12 12
 
13
+// ContainerLogsOptions holds parameters to filter logs with.
14
+type ContainerLogsOptions struct {
15
+	ShowStdout bool
16
+	ShowStderr bool
17
+	Since      string
18
+	Until      string
19
+	Timestamps bool
20
+	Follow     bool
21
+	Tail       string
22
+	Details    bool
23
+}
24
+
13 25
 // ContainerLogs returns the logs generated by a container in an [io.ReadCloser].
14 26
 // It's up to the caller to close the stream.
15 27
 //
16 28
deleted file mode 100644
... ...
@@ -1,62 +0,0 @@
1
-package client
2
-
3
-import (
4
-	"github.com/moby/moby/api/types/container"
5
-	"github.com/moby/moby/api/types/filters"
6
-)
7
-
8
-// ContainerAttachOptions holds parameters to attach to a container.
9
-type ContainerAttachOptions struct {
10
-	Stream     bool
11
-	Stdin      bool
12
-	Stdout     bool
13
-	Stderr     bool
14
-	DetachKeys string
15
-	Logs       bool
16
-}
17
-
18
-// ContainerCommitOptions holds parameters to commit changes into a container.
19
-type ContainerCommitOptions struct {
20
-	Reference string
21
-	Comment   string
22
-	Author    string
23
-	Changes   []string
24
-	Pause     bool
25
-	Config    *container.Config
26
-}
27
-
28
-// ContainerRemoveOptions holds parameters to remove containers.
29
-type ContainerRemoveOptions struct {
30
-	RemoveVolumes bool
31
-	RemoveLinks   bool
32
-	Force         bool
33
-}
34
-
35
-// ContainerStartOptions holds parameters to start containers.
36
-type ContainerStartOptions struct {
37
-	CheckpointID  string
38
-	CheckpointDir string
39
-}
40
-
41
-// ContainerListOptions holds parameters to list containers with.
42
-type ContainerListOptions struct {
43
-	Size    bool
44
-	All     bool
45
-	Latest  bool
46
-	Since   string
47
-	Before  string
48
-	Limit   int
49
-	Filters filters.Args
50
-}
51
-
52
-// ContainerLogsOptions holds parameters to filter logs with.
53
-type ContainerLogsOptions struct {
54
-	ShowStdout bool
55
-	ShowStderr bool
56
-	Since      string
57
-	Until      string
58
-	Timestamps bool
59
-	Follow     bool
60
-	Tail       string
61
-	Details    bool
62
-}
... ...
@@ -5,6 +5,13 @@ import (
5 5
 	"net/url"
6 6
 )
7 7
 
8
+// ContainerRemoveOptions holds parameters to remove containers.
9
+type ContainerRemoveOptions struct {
10
+	RemoveVolumes bool
11
+	RemoveLinks   bool
12
+	Force         bool
13
+}
14
+
8 15
 // ContainerRemove kills and removes a container from the docker host.
9 16
 func (cli *Client) ContainerRemove(ctx context.Context, containerID string, options ContainerRemoveOptions) error {
10 17
 	containerID, err := trimID("container", containerID)
... ...
@@ -5,6 +5,12 @@ import (
5 5
 	"net/url"
6 6
 )
7 7
 
8
+// ContainerStartOptions holds parameters to start containers.
9
+type ContainerStartOptions struct {
10
+	CheckpointID  string
11
+	CheckpointDir string
12
+}
13
+
8 14
 // ContainerStart sends a request to the docker daemon to start a container.
9 15
 func (cli *Client) ContainerStart(ctx context.Context, containerID string, options ContainerStartOptions) error {
10 16
 	containerID, err := trimID("container", containerID)
... ...
@@ -6,6 +6,16 @@ import (
6 6
 	"net/url"
7 7
 )
8 8
 
9
+// ContainerAttachOptions holds parameters to attach to a container.
10
+type ContainerAttachOptions struct {
11
+	Stream     bool
12
+	Stdin      bool
13
+	Stdout     bool
14
+	Stderr     bool
15
+	DetachKeys string
16
+	Logs       bool
17
+}
18
+
9 19
 // ContainerAttach attaches a connection to a container in the server.
10 20
 // It returns a [HijackedResponse] with the hijacked connection
11 21
 // and a reader to get output. It's up to the called to close
... ...
@@ -10,6 +10,16 @@ import (
10 10
 	"github.com/moby/moby/api/types/container"
11 11
 )
12 12
 
13
+// ContainerCommitOptions holds parameters to commit changes into a container.
14
+type ContainerCommitOptions struct {
15
+	Reference string
16
+	Comment   string
17
+	Author    string
18
+	Changes   []string
19
+	Pause     bool
20
+	Config    *container.Config
21
+}
22
+
13 23
 // ContainerCommit applies changes to a container and creates a new tagged image.
14 24
 func (cli *Client) ContainerCommit(ctx context.Context, containerID string, options ContainerCommitOptions) (container.CommitResponse, error) {
15 25
 	containerID, err := trimID("container", containerID)
... ...
@@ -11,6 +11,17 @@ import (
11 11
 	"github.com/moby/moby/api/types/versions"
12 12
 )
13 13
 
14
+// ContainerListOptions holds parameters to list containers with.
15
+type ContainerListOptions struct {
16
+	Size    bool
17
+	All     bool
18
+	Latest  bool
19
+	Since   string
20
+	Before  string
21
+	Limit   int
22
+	Filters filters.Args
23
+}
24
+
14 25
 // ContainerList returns the list of containers in the docker host.
15 26
 func (cli *Client) ContainerList(ctx context.Context, options ContainerListOptions) ([]container.Summary, error) {
16 27
 	query := url.Values{}
... ...
@@ -10,6 +10,18 @@ import (
10 10
 	"github.com/moby/moby/client/internal/timestamp"
11 11
 )
12 12
 
13
+// ContainerLogsOptions holds parameters to filter logs with.
14
+type ContainerLogsOptions struct {
15
+	ShowStdout bool
16
+	ShowStderr bool
17
+	Since      string
18
+	Until      string
19
+	Timestamps bool
20
+	Follow     bool
21
+	Tail       string
22
+	Details    bool
23
+}
24
+
13 25
 // ContainerLogs returns the logs generated by a container in an [io.ReadCloser].
14 26
 // It's up to the caller to close the stream.
15 27
 //
16 28
deleted file mode 100644
... ...
@@ -1,62 +0,0 @@
1
-package client
2
-
3
-import (
4
-	"github.com/moby/moby/api/types/container"
5
-	"github.com/moby/moby/api/types/filters"
6
-)
7
-
8
-// ContainerAttachOptions holds parameters to attach to a container.
9
-type ContainerAttachOptions struct {
10
-	Stream     bool
11
-	Stdin      bool
12
-	Stdout     bool
13
-	Stderr     bool
14
-	DetachKeys string
15
-	Logs       bool
16
-}
17
-
18
-// ContainerCommitOptions holds parameters to commit changes into a container.
19
-type ContainerCommitOptions struct {
20
-	Reference string
21
-	Comment   string
22
-	Author    string
23
-	Changes   []string
24
-	Pause     bool
25
-	Config    *container.Config
26
-}
27
-
28
-// ContainerRemoveOptions holds parameters to remove containers.
29
-type ContainerRemoveOptions struct {
30
-	RemoveVolumes bool
31
-	RemoveLinks   bool
32
-	Force         bool
33
-}
34
-
35
-// ContainerStartOptions holds parameters to start containers.
36
-type ContainerStartOptions struct {
37
-	CheckpointID  string
38
-	CheckpointDir string
39
-}
40
-
41
-// ContainerListOptions holds parameters to list containers with.
42
-type ContainerListOptions struct {
43
-	Size    bool
44
-	All     bool
45
-	Latest  bool
46
-	Since   string
47
-	Before  string
48
-	Limit   int
49
-	Filters filters.Args
50
-}
51
-
52
-// ContainerLogsOptions holds parameters to filter logs with.
53
-type ContainerLogsOptions struct {
54
-	ShowStdout bool
55
-	ShowStderr bool
56
-	Since      string
57
-	Until      string
58
-	Timestamps bool
59
-	Follow     bool
60
-	Tail       string
61
-	Details    bool
62
-}
... ...
@@ -5,6 +5,13 @@ import (
5 5
 	"net/url"
6 6
 )
7 7
 
8
+// ContainerRemoveOptions holds parameters to remove containers.
9
+type ContainerRemoveOptions struct {
10
+	RemoveVolumes bool
11
+	RemoveLinks   bool
12
+	Force         bool
13
+}
14
+
8 15
 // ContainerRemove kills and removes a container from the docker host.
9 16
 func (cli *Client) ContainerRemove(ctx context.Context, containerID string, options ContainerRemoveOptions) error {
10 17
 	containerID, err := trimID("container", containerID)
... ...
@@ -5,6 +5,12 @@ import (
5 5
 	"net/url"
6 6
 )
7 7
 
8
+// ContainerStartOptions holds parameters to start containers.
9
+type ContainerStartOptions struct {
10
+	CheckpointID  string
11
+	CheckpointDir string
12
+}
13
+
8 14
 // ContainerStart sends a request to the docker daemon to start a container.
9 15
 func (cli *Client) ContainerStart(ctx context.Context, containerID string, options ContainerStartOptions) error {
10 16
 	containerID, err := trimID("container", containerID)