k8s_openapi/v1_32/api/core/v1/
container.rs

1// Generated from definition io.k8s.api.core.v1.Container
2
3/// A single application container that you want to run within a pod.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct Container {
6    /// Arguments to the entrypoint. The container image's CMD is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell
7    pub args: Option<Vec<String>>,
8
9    /// Entrypoint array. Not executed within a shell. The container image's ENTRYPOINT is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell
10    pub command: Option<Vec<String>>,
11
12    /// List of environment variables to set in the container. Cannot be updated.
13    pub env: Option<Vec<crate::api::core::v1::EnvVar>>,
14
15    /// List of sources to populate environment variables in the container. The keys defined within a source must be a C_IDENTIFIER. All invalid keys will be reported as an event when the container is starting. When a key exists in multiple sources, the value associated with the last source will take precedence. Values defined by an Env with a duplicate key will take precedence. Cannot be updated.
16    pub env_from: Option<Vec<crate::api::core::v1::EnvFromSource>>,
17
18    /// Container image name. More info: https://kubernetes.io/docs/concepts/containers/images This field is optional to allow higher level config management to default or override container images in workload controllers like Deployments and StatefulSets.
19    pub image: Option<String>,
20
21    /// Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always if :latest tag is specified, or IfNotPresent otherwise. Cannot be updated. More info: https://kubernetes.io/docs/concepts/containers/images#updating-images
22    pub image_pull_policy: Option<String>,
23
24    /// Actions that the management system should take in response to container lifecycle events. Cannot be updated.
25    pub lifecycle: Option<crate::api::core::v1::Lifecycle>,
26
27    /// Periodic probe of container liveness. Container will be restarted if the probe fails. Cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
28    pub liveness_probe: Option<crate::api::core::v1::Probe>,
29
30    /// Name of the container specified as a DNS_LABEL. Each container in a pod must have a unique name (DNS_LABEL). Cannot be updated.
31    pub name: String,
32
33    /// List of ports to expose from the container. Not specifying a port here DOES NOT prevent that port from being exposed. Any port which is listening on the default "0.0.0.0" address inside a container will be accessible from the network. Modifying this array with strategic merge patch may corrupt the data. For more information See https://github.com/kubernetes/kubernetes/issues/108255. Cannot be updated.
34    pub ports: Option<Vec<crate::api::core::v1::ContainerPort>>,
35
36    /// Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails. Cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
37    pub readiness_probe: Option<crate::api::core::v1::Probe>,
38
39    /// Resources resize policy for the container.
40    pub resize_policy: Option<Vec<crate::api::core::v1::ContainerResizePolicy>>,
41
42    /// Compute Resources required by this container. Cannot be updated. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
43    pub resources: Option<crate::api::core::v1::ResourceRequirements>,
44
45    /// RestartPolicy defines the restart behavior of individual containers in a pod. This field may only be set for init containers, and the only allowed value is "Always". For non-init containers or when this field is not specified, the restart behavior is defined by the Pod's restart policy and the container type. Setting the RestartPolicy as "Always" for the init container will have the following effect: this init container will be continually restarted on exit until all regular containers have terminated. Once all regular containers have completed, all init containers with restartPolicy "Always" will be shut down. This lifecycle differs from normal init containers and is often referred to as a "sidecar" container. Although this init container still starts in the init container sequence, it does not wait for the container to complete before proceeding to the next init container. Instead, the next init container starts immediately after this init container is started, or after any startupProbe has successfully completed.
46    pub restart_policy: Option<String>,
47
48    /// SecurityContext defines the security options the container should be run with. If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext. More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
49    pub security_context: Option<crate::api::core::v1::SecurityContext>,
50
51    /// StartupProbe indicates that the Pod has successfully initialized. If specified, no other probes are executed until this completes successfully. If this probe fails, the Pod will be restarted, just as if the livenessProbe failed. This can be used to provide different probe parameters at the beginning of a Pod's lifecycle, when it might take a long time to load data or warm a cache, than during steady-state operation. This cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
52    pub startup_probe: Option<crate::api::core::v1::Probe>,
53
54    /// Whether this container should allocate a buffer for stdin in the container runtime. If this is not set, reads from stdin in the container will always result in EOF. Default is false.
55    pub stdin: Option<bool>,
56
57    /// Whether the container runtime should close the stdin channel after it has been opened by a single attach. When stdin is true the stdin stream will remain open across multiple attach sessions. If stdinOnce is set to true, stdin is opened on container start, is empty until the first client attaches to stdin, and then remains open and accepts data until the client disconnects, at which time stdin is closed and remains closed until the container is restarted. If this flag is false, a container processes that reads from stdin will never receive an EOF. Default is false
58    pub stdin_once: Option<bool>,
59
60    /// Optional: Path at which the file to which the container's termination message will be written is mounted into the container's filesystem. Message written is intended to be brief final status, such as an assertion failure message. Will be truncated by the node if greater than 4096 bytes. The total message length across all containers will be limited to 12kb. Defaults to /dev/termination-log. Cannot be updated.
61    pub termination_message_path: Option<String>,
62
63    /// Indicate how the termination message should be populated. File will use the contents of terminationMessagePath to populate the container status message on both success and failure. FallbackToLogsOnError will use the last chunk of container log output if the termination message file is empty and the container exited with an error. The log output is limited to 2048 bytes or 80 lines, whichever is smaller. Defaults to File. Cannot be updated.
64    pub termination_message_policy: Option<String>,
65
66    /// Whether this container should allocate a TTY for itself, also requires 'stdin' to be true. Default is false.
67    pub tty: Option<bool>,
68
69    /// volumeDevices is the list of block devices to be used by the container.
70    pub volume_devices: Option<Vec<crate::api::core::v1::VolumeDevice>>,
71
72    /// Pod volumes to mount into the container's filesystem. Cannot be updated.
73    pub volume_mounts: Option<Vec<crate::api::core::v1::VolumeMount>>,
74
75    /// Container's working directory. If not specified, the container runtime's default will be used, which might be configured in the container image. Cannot be updated.
76    pub working_dir: Option<String>,
77}
78
79impl crate::DeepMerge for Container {
80    fn merge_from(&mut self, other: Self) {
81        crate::merge_strategies::list::atomic(&mut self.args, other.args);
82        crate::merge_strategies::list::atomic(&mut self.command, other.command);
83        crate::merge_strategies::list::map(
84            &mut self.env,
85            other.env,
86            &[|lhs, rhs| lhs.name == rhs.name],
87            |current_item, other_item| {
88                crate::DeepMerge::merge_from(current_item, other_item);
89            },
90        );
91        crate::merge_strategies::list::atomic(&mut self.env_from, other.env_from);
92        crate::DeepMerge::merge_from(&mut self.image, other.image);
93        crate::DeepMerge::merge_from(&mut self.image_pull_policy, other.image_pull_policy);
94        crate::DeepMerge::merge_from(&mut self.lifecycle, other.lifecycle);
95        crate::DeepMerge::merge_from(&mut self.liveness_probe, other.liveness_probe);
96        crate::DeepMerge::merge_from(&mut self.name, other.name);
97        crate::merge_strategies::list::map(
98            &mut self.ports,
99            other.ports,
100            &[|lhs, rhs| lhs.container_port == rhs.container_port],
101            |current_item, other_item| {
102                crate::DeepMerge::merge_from(current_item, other_item);
103            },
104        );
105        crate::DeepMerge::merge_from(&mut self.readiness_probe, other.readiness_probe);
106        crate::merge_strategies::list::atomic(&mut self.resize_policy, other.resize_policy);
107        crate::DeepMerge::merge_from(&mut self.resources, other.resources);
108        crate::DeepMerge::merge_from(&mut self.restart_policy, other.restart_policy);
109        crate::DeepMerge::merge_from(&mut self.security_context, other.security_context);
110        crate::DeepMerge::merge_from(&mut self.startup_probe, other.startup_probe);
111        crate::DeepMerge::merge_from(&mut self.stdin, other.stdin);
112        crate::DeepMerge::merge_from(&mut self.stdin_once, other.stdin_once);
113        crate::DeepMerge::merge_from(&mut self.termination_message_path, other.termination_message_path);
114        crate::DeepMerge::merge_from(&mut self.termination_message_policy, other.termination_message_policy);
115        crate::DeepMerge::merge_from(&mut self.tty, other.tty);
116        crate::merge_strategies::list::map(
117            &mut self.volume_devices,
118            other.volume_devices,
119            &[|lhs, rhs| lhs.device_path == rhs.device_path],
120            |current_item, other_item| {
121                crate::DeepMerge::merge_from(current_item, other_item);
122            },
123        );
124        crate::merge_strategies::list::map(
125            &mut self.volume_mounts,
126            other.volume_mounts,
127            &[|lhs, rhs| lhs.mount_path == rhs.mount_path],
128            |current_item, other_item| {
129                crate::DeepMerge::merge_from(current_item, other_item);
130            },
131        );
132        crate::DeepMerge::merge_from(&mut self.working_dir, other.working_dir);
133    }
134}
135
136impl<'de> crate::serde::Deserialize<'de> for Container {
137    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
138        #[allow(non_camel_case_types)]
139        enum Field {
140            Key_args,
141            Key_command,
142            Key_env,
143            Key_env_from,
144            Key_image,
145            Key_image_pull_policy,
146            Key_lifecycle,
147            Key_liveness_probe,
148            Key_name,
149            Key_ports,
150            Key_readiness_probe,
151            Key_resize_policy,
152            Key_resources,
153            Key_restart_policy,
154            Key_security_context,
155            Key_startup_probe,
156            Key_stdin,
157            Key_stdin_once,
158            Key_termination_message_path,
159            Key_termination_message_policy,
160            Key_tty,
161            Key_volume_devices,
162            Key_volume_mounts,
163            Key_working_dir,
164            Other,
165        }
166
167        impl<'de> crate::serde::Deserialize<'de> for Field {
168            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
169                struct Visitor;
170
171                impl crate::serde::de::Visitor<'_> for Visitor {
172                    type Value = Field;
173
174                    fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
175                        f.write_str("field identifier")
176                    }
177
178                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
179                        Ok(match v {
180                            "args" => Field::Key_args,
181                            "command" => Field::Key_command,
182                            "env" => Field::Key_env,
183                            "envFrom" => Field::Key_env_from,
184                            "image" => Field::Key_image,
185                            "imagePullPolicy" => Field::Key_image_pull_policy,
186                            "lifecycle" => Field::Key_lifecycle,
187                            "livenessProbe" => Field::Key_liveness_probe,
188                            "name" => Field::Key_name,
189                            "ports" => Field::Key_ports,
190                            "readinessProbe" => Field::Key_readiness_probe,
191                            "resizePolicy" => Field::Key_resize_policy,
192                            "resources" => Field::Key_resources,
193                            "restartPolicy" => Field::Key_restart_policy,
194                            "securityContext" => Field::Key_security_context,
195                            "startupProbe" => Field::Key_startup_probe,
196                            "stdin" => Field::Key_stdin,
197                            "stdinOnce" => Field::Key_stdin_once,
198                            "terminationMessagePath" => Field::Key_termination_message_path,
199                            "terminationMessagePolicy" => Field::Key_termination_message_policy,
200                            "tty" => Field::Key_tty,
201                            "volumeDevices" => Field::Key_volume_devices,
202                            "volumeMounts" => Field::Key_volume_mounts,
203                            "workingDir" => Field::Key_working_dir,
204                            _ => Field::Other,
205                        })
206                    }
207                }
208
209                deserializer.deserialize_identifier(Visitor)
210            }
211        }
212
213        struct Visitor;
214
215        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
216            type Value = Container;
217
218            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
219                f.write_str("Container")
220            }
221
222            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
223                let mut value_args: Option<Vec<String>> = None;
224                let mut value_command: Option<Vec<String>> = None;
225                let mut value_env: Option<Vec<crate::api::core::v1::EnvVar>> = None;
226                let mut value_env_from: Option<Vec<crate::api::core::v1::EnvFromSource>> = None;
227                let mut value_image: Option<String> = None;
228                let mut value_image_pull_policy: Option<String> = None;
229                let mut value_lifecycle: Option<crate::api::core::v1::Lifecycle> = None;
230                let mut value_liveness_probe: Option<crate::api::core::v1::Probe> = None;
231                let mut value_name: Option<String> = None;
232                let mut value_ports: Option<Vec<crate::api::core::v1::ContainerPort>> = None;
233                let mut value_readiness_probe: Option<crate::api::core::v1::Probe> = None;
234                let mut value_resize_policy: Option<Vec<crate::api::core::v1::ContainerResizePolicy>> = None;
235                let mut value_resources: Option<crate::api::core::v1::ResourceRequirements> = None;
236                let mut value_restart_policy: Option<String> = None;
237                let mut value_security_context: Option<crate::api::core::v1::SecurityContext> = None;
238                let mut value_startup_probe: Option<crate::api::core::v1::Probe> = None;
239                let mut value_stdin: Option<bool> = None;
240                let mut value_stdin_once: Option<bool> = None;
241                let mut value_termination_message_path: Option<String> = None;
242                let mut value_termination_message_policy: Option<String> = None;
243                let mut value_tty: Option<bool> = None;
244                let mut value_volume_devices: Option<Vec<crate::api::core::v1::VolumeDevice>> = None;
245                let mut value_volume_mounts: Option<Vec<crate::api::core::v1::VolumeMount>> = None;
246                let mut value_working_dir: Option<String> = None;
247
248                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
249                    match key {
250                        Field::Key_args => value_args = crate::serde::de::MapAccess::next_value(&mut map)?,
251                        Field::Key_command => value_command = crate::serde::de::MapAccess::next_value(&mut map)?,
252                        Field::Key_env => value_env = crate::serde::de::MapAccess::next_value(&mut map)?,
253                        Field::Key_env_from => value_env_from = crate::serde::de::MapAccess::next_value(&mut map)?,
254                        Field::Key_image => value_image = crate::serde::de::MapAccess::next_value(&mut map)?,
255                        Field::Key_image_pull_policy => value_image_pull_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
256                        Field::Key_lifecycle => value_lifecycle = crate::serde::de::MapAccess::next_value(&mut map)?,
257                        Field::Key_liveness_probe => value_liveness_probe = crate::serde::de::MapAccess::next_value(&mut map)?,
258                        Field::Key_name => value_name = crate::serde::de::MapAccess::next_value(&mut map)?,
259                        Field::Key_ports => value_ports = crate::serde::de::MapAccess::next_value(&mut map)?,
260                        Field::Key_readiness_probe => value_readiness_probe = crate::serde::de::MapAccess::next_value(&mut map)?,
261                        Field::Key_resize_policy => value_resize_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
262                        Field::Key_resources => value_resources = crate::serde::de::MapAccess::next_value(&mut map)?,
263                        Field::Key_restart_policy => value_restart_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
264                        Field::Key_security_context => value_security_context = crate::serde::de::MapAccess::next_value(&mut map)?,
265                        Field::Key_startup_probe => value_startup_probe = crate::serde::de::MapAccess::next_value(&mut map)?,
266                        Field::Key_stdin => value_stdin = crate::serde::de::MapAccess::next_value(&mut map)?,
267                        Field::Key_stdin_once => value_stdin_once = crate::serde::de::MapAccess::next_value(&mut map)?,
268                        Field::Key_termination_message_path => value_termination_message_path = crate::serde::de::MapAccess::next_value(&mut map)?,
269                        Field::Key_termination_message_policy => value_termination_message_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
270                        Field::Key_tty => value_tty = crate::serde::de::MapAccess::next_value(&mut map)?,
271                        Field::Key_volume_devices => value_volume_devices = crate::serde::de::MapAccess::next_value(&mut map)?,
272                        Field::Key_volume_mounts => value_volume_mounts = crate::serde::de::MapAccess::next_value(&mut map)?,
273                        Field::Key_working_dir => value_working_dir = crate::serde::de::MapAccess::next_value(&mut map)?,
274                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
275                    }
276                }
277
278                Ok(Container {
279                    args: value_args,
280                    command: value_command,
281                    env: value_env,
282                    env_from: value_env_from,
283                    image: value_image,
284                    image_pull_policy: value_image_pull_policy,
285                    lifecycle: value_lifecycle,
286                    liveness_probe: value_liveness_probe,
287                    name: value_name.unwrap_or_default(),
288                    ports: value_ports,
289                    readiness_probe: value_readiness_probe,
290                    resize_policy: value_resize_policy,
291                    resources: value_resources,
292                    restart_policy: value_restart_policy,
293                    security_context: value_security_context,
294                    startup_probe: value_startup_probe,
295                    stdin: value_stdin,
296                    stdin_once: value_stdin_once,
297                    termination_message_path: value_termination_message_path,
298                    termination_message_policy: value_termination_message_policy,
299                    tty: value_tty,
300                    volume_devices: value_volume_devices,
301                    volume_mounts: value_volume_mounts,
302                    working_dir: value_working_dir,
303                })
304            }
305        }
306
307        deserializer.deserialize_struct(
308            "Container",
309            &[
310                "args",
311                "command",
312                "env",
313                "envFrom",
314                "image",
315                "imagePullPolicy",
316                "lifecycle",
317                "livenessProbe",
318                "name",
319                "ports",
320                "readinessProbe",
321                "resizePolicy",
322                "resources",
323                "restartPolicy",
324                "securityContext",
325                "startupProbe",
326                "stdin",
327                "stdinOnce",
328                "terminationMessagePath",
329                "terminationMessagePolicy",
330                "tty",
331                "volumeDevices",
332                "volumeMounts",
333                "workingDir",
334            ],
335            Visitor,
336        )
337    }
338}
339
340impl crate::serde::Serialize for Container {
341    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
342        let mut state = serializer.serialize_struct(
343            "Container",
344            1 +
345            self.args.as_ref().map_or(0, |_| 1) +
346            self.command.as_ref().map_or(0, |_| 1) +
347            self.env.as_ref().map_or(0, |_| 1) +
348            self.env_from.as_ref().map_or(0, |_| 1) +
349            self.image.as_ref().map_or(0, |_| 1) +
350            self.image_pull_policy.as_ref().map_or(0, |_| 1) +
351            self.lifecycle.as_ref().map_or(0, |_| 1) +
352            self.liveness_probe.as_ref().map_or(0, |_| 1) +
353            self.ports.as_ref().map_or(0, |_| 1) +
354            self.readiness_probe.as_ref().map_or(0, |_| 1) +
355            self.resize_policy.as_ref().map_or(0, |_| 1) +
356            self.resources.as_ref().map_or(0, |_| 1) +
357            self.restart_policy.as_ref().map_or(0, |_| 1) +
358            self.security_context.as_ref().map_or(0, |_| 1) +
359            self.startup_probe.as_ref().map_or(0, |_| 1) +
360            self.stdin.as_ref().map_or(0, |_| 1) +
361            self.stdin_once.as_ref().map_or(0, |_| 1) +
362            self.termination_message_path.as_ref().map_or(0, |_| 1) +
363            self.termination_message_policy.as_ref().map_or(0, |_| 1) +
364            self.tty.as_ref().map_or(0, |_| 1) +
365            self.volume_devices.as_ref().map_or(0, |_| 1) +
366            self.volume_mounts.as_ref().map_or(0, |_| 1) +
367            self.working_dir.as_ref().map_or(0, |_| 1),
368        )?;
369        if let Some(value) = &self.args {
370            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "args", value)?;
371        }
372        if let Some(value) = &self.command {
373            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "command", value)?;
374        }
375        if let Some(value) = &self.env {
376            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "env", value)?;
377        }
378        if let Some(value) = &self.env_from {
379            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "envFrom", value)?;
380        }
381        if let Some(value) = &self.image {
382            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "image", value)?;
383        }
384        if let Some(value) = &self.image_pull_policy {
385            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "imagePullPolicy", value)?;
386        }
387        if let Some(value) = &self.lifecycle {
388            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "lifecycle", value)?;
389        }
390        if let Some(value) = &self.liveness_probe {
391            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "livenessProbe", value)?;
392        }
393        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "name", &self.name)?;
394        if let Some(value) = &self.ports {
395            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ports", value)?;
396        }
397        if let Some(value) = &self.readiness_probe {
398            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readinessProbe", value)?;
399        }
400        if let Some(value) = &self.resize_policy {
401            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resizePolicy", value)?;
402        }
403        if let Some(value) = &self.resources {
404            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resources", value)?;
405        }
406        if let Some(value) = &self.restart_policy {
407            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "restartPolicy", value)?;
408        }
409        if let Some(value) = &self.security_context {
410            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "securityContext", value)?;
411        }
412        if let Some(value) = &self.startup_probe {
413            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "startupProbe", value)?;
414        }
415        if let Some(value) = &self.stdin {
416            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "stdin", value)?;
417        }
418        if let Some(value) = &self.stdin_once {
419            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "stdinOnce", value)?;
420        }
421        if let Some(value) = &self.termination_message_path {
422            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "terminationMessagePath", value)?;
423        }
424        if let Some(value) = &self.termination_message_policy {
425            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "terminationMessagePolicy", value)?;
426        }
427        if let Some(value) = &self.tty {
428            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "tty", value)?;
429        }
430        if let Some(value) = &self.volume_devices {
431            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "volumeDevices", value)?;
432        }
433        if let Some(value) = &self.volume_mounts {
434            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "volumeMounts", value)?;
435        }
436        if let Some(value) = &self.working_dir {
437            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "workingDir", value)?;
438        }
439        crate::serde::ser::SerializeStruct::end(state)
440    }
441}
442
443#[cfg(feature = "schemars")]
444impl crate::schemars::JsonSchema for Container {
445    fn schema_name() -> String {
446        "io.k8s.api.core.v1.Container".to_owned()
447    }
448
449    fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
450        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
451            metadata: Some(Box::new(crate::schemars::schema::Metadata {
452                description: Some("A single application container that you want to run within a pod.".to_owned()),
453                ..Default::default()
454            })),
455            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
456            object: Some(Box::new(crate::schemars::schema::ObjectValidation {
457                properties: [
458                    (
459                        "args".to_owned(),
460                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
461                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
462                                description: Some("Arguments to the entrypoint. The container image's CMD is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. \"$$(VAR_NAME)\" will produce the string literal \"$(VAR_NAME)\". Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell".to_owned()),
463                                ..Default::default()
464                            })),
465                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Array))),
466                            array: Some(Box::new(crate::schemars::schema::ArrayValidation {
467                                items: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(
468                                    crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
469                                        instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
470                                        ..Default::default()
471                                    })
472                                ))),
473                                ..Default::default()
474                            })),
475                            ..Default::default()
476                        }),
477                    ),
478                    (
479                        "command".to_owned(),
480                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
481                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
482                                description: Some("Entrypoint array. Not executed within a shell. The container image's ENTRYPOINT is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. \"$$(VAR_NAME)\" will produce the string literal \"$(VAR_NAME)\". Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell".to_owned()),
483                                ..Default::default()
484                            })),
485                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Array))),
486                            array: Some(Box::new(crate::schemars::schema::ArrayValidation {
487                                items: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(
488                                    crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
489                                        instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
490                                        ..Default::default()
491                                    })
492                                ))),
493                                ..Default::default()
494                            })),
495                            ..Default::default()
496                        }),
497                    ),
498                    (
499                        "env".to_owned(),
500                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
501                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
502                                description: Some("List of environment variables to set in the container. Cannot be updated.".to_owned()),
503                                ..Default::default()
504                            })),
505                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Array))),
506                            array: Some(Box::new(crate::schemars::schema::ArrayValidation {
507                                items: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(__gen.subschema_for::<crate::api::core::v1::EnvVar>()))),
508                                ..Default::default()
509                            })),
510                            ..Default::default()
511                        }),
512                    ),
513                    (
514                        "envFrom".to_owned(),
515                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
516                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
517                                description: Some("List of sources to populate environment variables in the container. The keys defined within a source must be a C_IDENTIFIER. All invalid keys will be reported as an event when the container is starting. When a key exists in multiple sources, the value associated with the last source will take precedence. Values defined by an Env with a duplicate key will take precedence. Cannot be updated.".to_owned()),
518                                ..Default::default()
519                            })),
520                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Array))),
521                            array: Some(Box::new(crate::schemars::schema::ArrayValidation {
522                                items: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(__gen.subschema_for::<crate::api::core::v1::EnvFromSource>()))),
523                                ..Default::default()
524                            })),
525                            ..Default::default()
526                        }),
527                    ),
528                    (
529                        "image".to_owned(),
530                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
531                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
532                                description: Some("Container image name. More info: https://kubernetes.io/docs/concepts/containers/images This field is optional to allow higher level config management to default or override container images in workload controllers like Deployments and StatefulSets.".to_owned()),
533                                ..Default::default()
534                            })),
535                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
536                            ..Default::default()
537                        }),
538                    ),
539                    (
540                        "imagePullPolicy".to_owned(),
541                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
542                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
543                                description: Some("Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always if :latest tag is specified, or IfNotPresent otherwise. Cannot be updated. More info: https://kubernetes.io/docs/concepts/containers/images#updating-images".to_owned()),
544                                ..Default::default()
545                            })),
546                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
547                            ..Default::default()
548                        }),
549                    ),
550                    (
551                        "lifecycle".to_owned(),
552                        {
553                            let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::Lifecycle>().into_object();
554                            schema_obj.metadata = Some(Box::new(crate::schemars::schema::Metadata {
555                                description: Some("Actions that the management system should take in response to container lifecycle events. Cannot be updated.".to_owned()),
556                                ..Default::default()
557                            }));
558                            crate::schemars::schema::Schema::Object(schema_obj)
559                        },
560                    ),
561                    (
562                        "livenessProbe".to_owned(),
563                        {
564                            let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::Probe>().into_object();
565                            schema_obj.metadata = Some(Box::new(crate::schemars::schema::Metadata {
566                                description: Some("Periodic probe of container liveness. Container will be restarted if the probe fails. Cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes".to_owned()),
567                                ..Default::default()
568                            }));
569                            crate::schemars::schema::Schema::Object(schema_obj)
570                        },
571                    ),
572                    (
573                        "name".to_owned(),
574                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
575                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
576                                description: Some("Name of the container specified as a DNS_LABEL. Each container in a pod must have a unique name (DNS_LABEL). Cannot be updated.".to_owned()),
577                                ..Default::default()
578                            })),
579                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
580                            ..Default::default()
581                        }),
582                    ),
583                    (
584                        "ports".to_owned(),
585                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
586                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
587                                description: Some("List of ports to expose from the container. Not specifying a port here DOES NOT prevent that port from being exposed. Any port which is listening on the default \"0.0.0.0\" address inside a container will be accessible from the network. Modifying this array with strategic merge patch may corrupt the data. For more information See https://github.com/kubernetes/kubernetes/issues/108255. Cannot be updated.".to_owned()),
588                                ..Default::default()
589                            })),
590                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Array))),
591                            array: Some(Box::new(crate::schemars::schema::ArrayValidation {
592                                items: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(__gen.subschema_for::<crate::api::core::v1::ContainerPort>()))),
593                                ..Default::default()
594                            })),
595                            ..Default::default()
596                        }),
597                    ),
598                    (
599                        "readinessProbe".to_owned(),
600                        {
601                            let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::Probe>().into_object();
602                            schema_obj.metadata = Some(Box::new(crate::schemars::schema::Metadata {
603                                description: Some("Periodic probe of container service readiness. Container will be removed from service endpoints if the probe fails. Cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes".to_owned()),
604                                ..Default::default()
605                            }));
606                            crate::schemars::schema::Schema::Object(schema_obj)
607                        },
608                    ),
609                    (
610                        "resizePolicy".to_owned(),
611                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
612                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
613                                description: Some("Resources resize policy for the container.".to_owned()),
614                                ..Default::default()
615                            })),
616                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Array))),
617                            array: Some(Box::new(crate::schemars::schema::ArrayValidation {
618                                items: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(__gen.subschema_for::<crate::api::core::v1::ContainerResizePolicy>()))),
619                                ..Default::default()
620                            })),
621                            ..Default::default()
622                        }),
623                    ),
624                    (
625                        "resources".to_owned(),
626                        {
627                            let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::ResourceRequirements>().into_object();
628                            schema_obj.metadata = Some(Box::new(crate::schemars::schema::Metadata {
629                                description: Some("Compute Resources required by this container. Cannot be updated. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/".to_owned()),
630                                ..Default::default()
631                            }));
632                            crate::schemars::schema::Schema::Object(schema_obj)
633                        },
634                    ),
635                    (
636                        "restartPolicy".to_owned(),
637                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
638                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
639                                description: Some("RestartPolicy defines the restart behavior of individual containers in a pod. This field may only be set for init containers, and the only allowed value is \"Always\". For non-init containers or when this field is not specified, the restart behavior is defined by the Pod's restart policy and the container type. Setting the RestartPolicy as \"Always\" for the init container will have the following effect: this init container will be continually restarted on exit until all regular containers have terminated. Once all regular containers have completed, all init containers with restartPolicy \"Always\" will be shut down. This lifecycle differs from normal init containers and is often referred to as a \"sidecar\" container. Although this init container still starts in the init container sequence, it does not wait for the container to complete before proceeding to the next init container. Instead, the next init container starts immediately after this init container is started, or after any startupProbe has successfully completed.".to_owned()),
640                                ..Default::default()
641                            })),
642                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
643                            ..Default::default()
644                        }),
645                    ),
646                    (
647                        "securityContext".to_owned(),
648                        {
649                            let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::SecurityContext>().into_object();
650                            schema_obj.metadata = Some(Box::new(crate::schemars::schema::Metadata {
651                                description: Some("SecurityContext defines the security options the container should be run with. If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext. More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/".to_owned()),
652                                ..Default::default()
653                            }));
654                            crate::schemars::schema::Schema::Object(schema_obj)
655                        },
656                    ),
657                    (
658                        "startupProbe".to_owned(),
659                        {
660                            let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::Probe>().into_object();
661                            schema_obj.metadata = Some(Box::new(crate::schemars::schema::Metadata {
662                                description: Some("StartupProbe indicates that the Pod has successfully initialized. If specified, no other probes are executed until this completes successfully. If this probe fails, the Pod will be restarted, just as if the livenessProbe failed. This can be used to provide different probe parameters at the beginning of a Pod's lifecycle, when it might take a long time to load data or warm a cache, than during steady-state operation. This cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes".to_owned()),
663                                ..Default::default()
664                            }));
665                            crate::schemars::schema::Schema::Object(schema_obj)
666                        },
667                    ),
668                    (
669                        "stdin".to_owned(),
670                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
671                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
672                                description: Some("Whether this container should allocate a buffer for stdin in the container runtime. If this is not set, reads from stdin in the container will always result in EOF. Default is false.".to_owned()),
673                                ..Default::default()
674                            })),
675                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Boolean))),
676                            ..Default::default()
677                        }),
678                    ),
679                    (
680                        "stdinOnce".to_owned(),
681                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
682                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
683                                description: Some("Whether the container runtime should close the stdin channel after it has been opened by a single attach. When stdin is true the stdin stream will remain open across multiple attach sessions. If stdinOnce is set to true, stdin is opened on container start, is empty until the first client attaches to stdin, and then remains open and accepts data until the client disconnects, at which time stdin is closed and remains closed until the container is restarted. If this flag is false, a container processes that reads from stdin will never receive an EOF. Default is false".to_owned()),
684                                ..Default::default()
685                            })),
686                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Boolean))),
687                            ..Default::default()
688                        }),
689                    ),
690                    (
691                        "terminationMessagePath".to_owned(),
692                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
693                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
694                                description: Some("Optional: Path at which the file to which the container's termination message will be written is mounted into the container's filesystem. Message written is intended to be brief final status, such as an assertion failure message. Will be truncated by the node if greater than 4096 bytes. The total message length across all containers will be limited to 12kb. Defaults to /dev/termination-log. Cannot be updated.".to_owned()),
695                                ..Default::default()
696                            })),
697                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
698                            ..Default::default()
699                        }),
700                    ),
701                    (
702                        "terminationMessagePolicy".to_owned(),
703                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
704                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
705                                description: Some("Indicate how the termination message should be populated. File will use the contents of terminationMessagePath to populate the container status message on both success and failure. FallbackToLogsOnError will use the last chunk of container log output if the termination message file is empty and the container exited with an error. The log output is limited to 2048 bytes or 80 lines, whichever is smaller. Defaults to File. Cannot be updated.".to_owned()),
706                                ..Default::default()
707                            })),
708                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
709                            ..Default::default()
710                        }),
711                    ),
712                    (
713                        "tty".to_owned(),
714                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
715                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
716                                description: Some("Whether this container should allocate a TTY for itself, also requires 'stdin' to be true. Default is false.".to_owned()),
717                                ..Default::default()
718                            })),
719                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Boolean))),
720                            ..Default::default()
721                        }),
722                    ),
723                    (
724                        "volumeDevices".to_owned(),
725                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
726                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
727                                description: Some("volumeDevices is the list of block devices to be used by the container.".to_owned()),
728                                ..Default::default()
729                            })),
730                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Array))),
731                            array: Some(Box::new(crate::schemars::schema::ArrayValidation {
732                                items: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(__gen.subschema_for::<crate::api::core::v1::VolumeDevice>()))),
733                                ..Default::default()
734                            })),
735                            ..Default::default()
736                        }),
737                    ),
738                    (
739                        "volumeMounts".to_owned(),
740                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
741                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
742                                description: Some("Pod volumes to mount into the container's filesystem. Cannot be updated.".to_owned()),
743                                ..Default::default()
744                            })),
745                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Array))),
746                            array: Some(Box::new(crate::schemars::schema::ArrayValidation {
747                                items: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(__gen.subschema_for::<crate::api::core::v1::VolumeMount>()))),
748                                ..Default::default()
749                            })),
750                            ..Default::default()
751                        }),
752                    ),
753                    (
754                        "workingDir".to_owned(),
755                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
756                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
757                                description: Some("Container's working directory. If not specified, the container runtime's default will be used, which might be configured in the container image. Cannot be updated.".to_owned()),
758                                ..Default::default()
759                            })),
760                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
761                            ..Default::default()
762                        }),
763                    ),
764                ].into(),
765                required: [
766                    "name".to_owned(),
767                ].into(),
768                ..Default::default()
769            })),
770            ..Default::default()
771        })
772    }
773}