k8s_openapi/v1_31/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<std::vec::Vec<std::string::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<std::vec::Vec<std::string::String>>,
11
12    /// List of environment variables to set in the container. Cannot be updated.
13    pub env: Option<std::vec::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<std::vec::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<std::string::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<std::string::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: std::string::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<std::vec::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<std::vec::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<std::string::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<std::string::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<std::string::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<std::vec::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<std::vec::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<std::string::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 core::fmt::Formatter<'_>) -> core::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 core::fmt::Formatter<'_>) -> core::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<std::vec::Vec<std::string::String>> = None;
224                let mut value_command: Option<std::vec::Vec<std::string::String>> = None;
225                let mut value_env: Option<std::vec::Vec<crate::api::core::v1::EnvVar>> = None;
226                let mut value_env_from: Option<std::vec::Vec<crate::api::core::v1::EnvFromSource>> = None;
227                let mut value_image: Option<std::string::String> = None;
228                let mut value_image_pull_policy: Option<std::string::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<std::string::String> = None;
232                let mut value_ports: Option<std::vec::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<std::vec::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<std::string::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<std::string::String> = None;
242                let mut value_termination_message_policy: Option<std::string::String> = None;
243                let mut value_tty: Option<bool> = None;
244                let mut value_volume_devices: Option<std::vec::Vec<crate::api::core::v1::VolumeDevice>> = None;
245                let mut value_volume_mounts: Option<std::vec::Vec<crate::api::core::v1::VolumeMount>> = None;
246                let mut value_working_dir: Option<std::string::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() -> std::borrow::Cow<'static, str> {
446        "io.k8s.api.core.v1.Container".into()
447    }
448
449    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
450        crate::schemars::json_schema!({
451            "description": "A single application container that you want to run within a pod.",
452            "type": "object",
453            "properties": {
454                "args": {
455                    "description": "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",
456                    "type": "array",
457                    "items": {
458                        "type": "string",
459                    },
460                },
461                "command": {
462                    "description": "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",
463                    "type": "array",
464                    "items": {
465                        "type": "string",
466                    },
467                },
468                "env": {
469                    "description": "List of environment variables to set in the container. Cannot be updated.",
470                    "type": "array",
471                    "items": (__gen.subschema_for::<crate::api::core::v1::EnvVar>()),
472                },
473                "envFrom": {
474                    "description": "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.",
475                    "type": "array",
476                    "items": (__gen.subschema_for::<crate::api::core::v1::EnvFromSource>()),
477                },
478                "image": {
479                    "description": "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.",
480                    "type": "string",
481                },
482                "imagePullPolicy": {
483                    "description": "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",
484                    "type": "string",
485                },
486                "lifecycle": ({
487                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::Lifecycle>();
488                    schema_obj.ensure_object().insert("description".into(), "Actions that the management system should take in response to container lifecycle events. Cannot be updated.".into());
489                    schema_obj
490                }),
491                "livenessProbe": ({
492                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::Probe>();
493                    schema_obj.ensure_object().insert("description".into(), "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".into());
494                    schema_obj
495                }),
496                "name": {
497                    "description": "Name of the container specified as a DNS_LABEL. Each container in a pod must have a unique name (DNS_LABEL). Cannot be updated.",
498                    "type": "string",
499                },
500                "ports": {
501                    "description": "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.",
502                    "type": "array",
503                    "items": (__gen.subschema_for::<crate::api::core::v1::ContainerPort>()),
504                },
505                "readinessProbe": ({
506                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::Probe>();
507                    schema_obj.ensure_object().insert("description".into(), "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".into());
508                    schema_obj
509                }),
510                "resizePolicy": {
511                    "description": "Resources resize policy for the container.",
512                    "type": "array",
513                    "items": (__gen.subschema_for::<crate::api::core::v1::ContainerResizePolicy>()),
514                },
515                "resources": ({
516                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::ResourceRequirements>();
517                    schema_obj.ensure_object().insert("description".into(), "Compute Resources required by this container. Cannot be updated. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/".into());
518                    schema_obj
519                }),
520                "restartPolicy": {
521                    "description": "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.",
522                    "type": "string",
523                },
524                "securityContext": ({
525                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::SecurityContext>();
526                    schema_obj.ensure_object().insert("description".into(), "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/".into());
527                    schema_obj
528                }),
529                "startupProbe": ({
530                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::Probe>();
531                    schema_obj.ensure_object().insert("description".into(), "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".into());
532                    schema_obj
533                }),
534                "stdin": {
535                    "description": "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.",
536                    "type": "boolean",
537                },
538                "stdinOnce": {
539                    "description": "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",
540                    "type": "boolean",
541                },
542                "terminationMessagePath": {
543                    "description": "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.",
544                    "type": "string",
545                },
546                "terminationMessagePolicy": {
547                    "description": "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.",
548                    "type": "string",
549                },
550                "tty": {
551                    "description": "Whether this container should allocate a TTY for itself, also requires 'stdin' to be true. Default is false.",
552                    "type": "boolean",
553                },
554                "volumeDevices": {
555                    "description": "volumeDevices is the list of block devices to be used by the container.",
556                    "type": "array",
557                    "items": (__gen.subschema_for::<crate::api::core::v1::VolumeDevice>()),
558                },
559                "volumeMounts": {
560                    "description": "Pod volumes to mount into the container's filesystem. Cannot be updated.",
561                    "type": "array",
562                    "items": (__gen.subschema_for::<crate::api::core::v1::VolumeMount>()),
563                },
564                "workingDir": {
565                    "description": "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.",
566                    "type": "string",
567                },
568            },
569            "required": [
570                "name",
571            ],
572        })
573    }
574}