stackify_docker_api/opts/
exec.rs

1use containers_api::{impl_field, impl_opts_builder, impl_str_field, impl_vec_field};
2use serde::Serialize;
3
4impl_opts_builder!(json => ExecCreate);
5
6#[derive(Copy, Clone, PartialEq, Debug)]
7/// Initial size of the console
8pub struct ConsoleSize {
9    pub height: u64,
10    pub width: u64,
11}
12
13impl Serialize for ConsoleSize {
14    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
15    where
16        S: serde::Serializer,
17    {
18        [self.height, self.width].serialize(serializer)
19    }
20}
21
22impl ExecCreateOptsBuilder {
23    impl_vec_field!(
24        /// Command to run, as an array of strings.
25        command => "Cmd"
26    );
27
28    impl_vec_field!(
29        /// A list of environment variables in the form 'VAR=value'.
30        env => "Env"
31    );
32
33    impl_field!(
34        /// Attach to stdout of the exec command.
35        attach_stdout: bool => "AttachStdout"
36    );
37
38    impl_field!(
39        /// Attach to stderr of the exec command.
40        attach_stderr: bool => "AttachStderr"
41    );
42
43    impl_field!(
44        /// Attach to stdin of the exec command.
45        attach_stdin: bool => "AttachStdin"
46    );
47
48    impl_str_field!(
49        /// Override the key sequence for detaching a container. Format is a single
50        /// character [a-Z] or ctrl-<value> where <value> is one of: a-z, @, ^, [, , or _.
51        detach_keys => "DetachKeys"
52    );
53
54    impl_field!(
55        /// Allocate a pseudo-TTY.
56        tty: bool => "Tty"
57    );
58
59    impl_field!(
60        /// Runs the exec process with extended privileges. (Default: `false`)
61        privileged: bool => "Privileged"
62    );
63
64    impl_str_field!(
65        /// The user, and optionally, group to run the exec process inside the container.
66        /// Format is one of: user, user:group, uid, or uid:gid.
67        user => "User"
68    );
69
70    impl_str_field!(
71        /// The working directory for the exec process inside the container.
72        working_dir => "WorkingDir"
73    );
74
75    impl_field!(
76        /// Initial console size
77        console_size: ConsoleSize => "ConsoleSize"
78    );
79}
80
81impl_opts_builder!(json => ExecResize);
82
83impl ExecResizeOptsBuilder {
84    impl_field!(height: u64 => "Height");
85    impl_field!(width: u64 => "Width");
86}
87
88impl_opts_builder!(json => ExecStart);
89
90impl ExecStartOptsBuilder {
91    impl_field!(
92        /// Detach from the command.
93        detach: bool => "Detach"
94    );
95
96    impl_field!(
97        /// Allocate a pseudo-TTY.
98        tty: bool => "Tty"
99    );
100
101    impl_field!(
102        /// Initial console size
103        console_size: ConsoleSize => "ConsoleSize"
104    );
105}