k8s_openapi/v1_34/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 may consist of any printable ASCII characters except '='. 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 overrides the pod-level restart policy. When this field is not specified, the restart behavior is defined by the Pod's restart policy and the container type. Additionally, 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    /// Represents a list of rules to be checked to determine if the container should be restarted on exit. The rules are evaluated in order. Once a rule matches a container exit condition, the remaining rules are ignored. If no rule matches the container exit condition, the Container-level restart policy determines the whether the container is restarted or not. Constraints on the rules: - At most 20 rules are allowed. - Rules can have the same action. - Identical rules are not forbidden in validations. When rules are specified, container MUST set RestartPolicy explicitly even it if matches the Pod's RestartPolicy.
49    pub restart_policy_rules: Option<std::vec::Vec<crate::api::core::v1::ContainerRestartRule>>,
50
51    /// 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/
52    pub security_context: Option<crate::api::core::v1::SecurityContext>,
53
54    /// 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
55    pub startup_probe: Option<crate::api::core::v1::Probe>,
56
57    /// 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.
58    pub stdin: Option<bool>,
59
60    /// 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
61    pub stdin_once: Option<bool>,
62
63    /// 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.
64    pub termination_message_path: Option<std::string::String>,
65
66    /// 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.
67    pub termination_message_policy: Option<std::string::String>,
68
69    /// Whether this container should allocate a TTY for itself, also requires 'stdin' to be true. Default is false.
70    pub tty: Option<bool>,
71
72    /// volumeDevices is the list of block devices to be used by the container.
73    pub volume_devices: Option<std::vec::Vec<crate::api::core::v1::VolumeDevice>>,
74
75    /// Pod volumes to mount into the container's filesystem. Cannot be updated.
76    pub volume_mounts: Option<std::vec::Vec<crate::api::core::v1::VolumeMount>>,
77
78    /// 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.
79    pub working_dir: Option<std::string::String>,
80}
81
82impl crate::DeepMerge for Container {
83    fn merge_from(&mut self, other: Self) {
84        crate::merge_strategies::list::atomic(&mut self.args, other.args);
85        crate::merge_strategies::list::atomic(&mut self.command, other.command);
86        crate::merge_strategies::list::map(
87            &mut self.env,
88            other.env,
89            &[|lhs, rhs| lhs.name == rhs.name],
90            |current_item, other_item| {
91                crate::DeepMerge::merge_from(current_item, other_item);
92            },
93        );
94        crate::merge_strategies::list::atomic(&mut self.env_from, other.env_from);
95        crate::DeepMerge::merge_from(&mut self.image, other.image);
96        crate::DeepMerge::merge_from(&mut self.image_pull_policy, other.image_pull_policy);
97        crate::DeepMerge::merge_from(&mut self.lifecycle, other.lifecycle);
98        crate::DeepMerge::merge_from(&mut self.liveness_probe, other.liveness_probe);
99        crate::DeepMerge::merge_from(&mut self.name, other.name);
100        crate::merge_strategies::list::map(
101            &mut self.ports,
102            other.ports,
103            &[|lhs, rhs| lhs.container_port == rhs.container_port],
104            |current_item, other_item| {
105                crate::DeepMerge::merge_from(current_item, other_item);
106            },
107        );
108        crate::DeepMerge::merge_from(&mut self.readiness_probe, other.readiness_probe);
109        crate::merge_strategies::list::atomic(&mut self.resize_policy, other.resize_policy);
110        crate::DeepMerge::merge_from(&mut self.resources, other.resources);
111        crate::DeepMerge::merge_from(&mut self.restart_policy, other.restart_policy);
112        crate::merge_strategies::list::atomic(&mut self.restart_policy_rules, other.restart_policy_rules);
113        crate::DeepMerge::merge_from(&mut self.security_context, other.security_context);
114        crate::DeepMerge::merge_from(&mut self.startup_probe, other.startup_probe);
115        crate::DeepMerge::merge_from(&mut self.stdin, other.stdin);
116        crate::DeepMerge::merge_from(&mut self.stdin_once, other.stdin_once);
117        crate::DeepMerge::merge_from(&mut self.termination_message_path, other.termination_message_path);
118        crate::DeepMerge::merge_from(&mut self.termination_message_policy, other.termination_message_policy);
119        crate::DeepMerge::merge_from(&mut self.tty, other.tty);
120        crate::merge_strategies::list::map(
121            &mut self.volume_devices,
122            other.volume_devices,
123            &[|lhs, rhs| lhs.device_path == rhs.device_path],
124            |current_item, other_item| {
125                crate::DeepMerge::merge_from(current_item, other_item);
126            },
127        );
128        crate::merge_strategies::list::map(
129            &mut self.volume_mounts,
130            other.volume_mounts,
131            &[|lhs, rhs| lhs.mount_path == rhs.mount_path],
132            |current_item, other_item| {
133                crate::DeepMerge::merge_from(current_item, other_item);
134            },
135        );
136        crate::DeepMerge::merge_from(&mut self.working_dir, other.working_dir);
137    }
138}
139
140impl<'de> crate::serde::Deserialize<'de> for Container {
141    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
142        #[allow(non_camel_case_types)]
143        enum Field {
144            Key_args,
145            Key_command,
146            Key_env,
147            Key_env_from,
148            Key_image,
149            Key_image_pull_policy,
150            Key_lifecycle,
151            Key_liveness_probe,
152            Key_name,
153            Key_ports,
154            Key_readiness_probe,
155            Key_resize_policy,
156            Key_resources,
157            Key_restart_policy,
158            Key_restart_policy_rules,
159            Key_security_context,
160            Key_startup_probe,
161            Key_stdin,
162            Key_stdin_once,
163            Key_termination_message_path,
164            Key_termination_message_policy,
165            Key_tty,
166            Key_volume_devices,
167            Key_volume_mounts,
168            Key_working_dir,
169            Other,
170        }
171
172        impl<'de> crate::serde::Deserialize<'de> for Field {
173            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
174                struct Visitor;
175
176                impl crate::serde::de::Visitor<'_> for Visitor {
177                    type Value = Field;
178
179                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
180                        f.write_str("field identifier")
181                    }
182
183                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
184                        Ok(match v {
185                            "args" => Field::Key_args,
186                            "command" => Field::Key_command,
187                            "env" => Field::Key_env,
188                            "envFrom" => Field::Key_env_from,
189                            "image" => Field::Key_image,
190                            "imagePullPolicy" => Field::Key_image_pull_policy,
191                            "lifecycle" => Field::Key_lifecycle,
192                            "livenessProbe" => Field::Key_liveness_probe,
193                            "name" => Field::Key_name,
194                            "ports" => Field::Key_ports,
195                            "readinessProbe" => Field::Key_readiness_probe,
196                            "resizePolicy" => Field::Key_resize_policy,
197                            "resources" => Field::Key_resources,
198                            "restartPolicy" => Field::Key_restart_policy,
199                            "restartPolicyRules" => Field::Key_restart_policy_rules,
200                            "securityContext" => Field::Key_security_context,
201                            "startupProbe" => Field::Key_startup_probe,
202                            "stdin" => Field::Key_stdin,
203                            "stdinOnce" => Field::Key_stdin_once,
204                            "terminationMessagePath" => Field::Key_termination_message_path,
205                            "terminationMessagePolicy" => Field::Key_termination_message_policy,
206                            "tty" => Field::Key_tty,
207                            "volumeDevices" => Field::Key_volume_devices,
208                            "volumeMounts" => Field::Key_volume_mounts,
209                            "workingDir" => Field::Key_working_dir,
210                            _ => Field::Other,
211                        })
212                    }
213                }
214
215                deserializer.deserialize_identifier(Visitor)
216            }
217        }
218
219        struct Visitor;
220
221        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
222            type Value = Container;
223
224            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
225                f.write_str("Container")
226            }
227
228            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
229                let mut value_args: Option<std::vec::Vec<std::string::String>> = None;
230                let mut value_command: Option<std::vec::Vec<std::string::String>> = None;
231                let mut value_env: Option<std::vec::Vec<crate::api::core::v1::EnvVar>> = None;
232                let mut value_env_from: Option<std::vec::Vec<crate::api::core::v1::EnvFromSource>> = None;
233                let mut value_image: Option<std::string::String> = None;
234                let mut value_image_pull_policy: Option<std::string::String> = None;
235                let mut value_lifecycle: Option<crate::api::core::v1::Lifecycle> = None;
236                let mut value_liveness_probe: Option<crate::api::core::v1::Probe> = None;
237                let mut value_name: Option<std::string::String> = None;
238                let mut value_ports: Option<std::vec::Vec<crate::api::core::v1::ContainerPort>> = None;
239                let mut value_readiness_probe: Option<crate::api::core::v1::Probe> = None;
240                let mut value_resize_policy: Option<std::vec::Vec<crate::api::core::v1::ContainerResizePolicy>> = None;
241                let mut value_resources: Option<crate::api::core::v1::ResourceRequirements> = None;
242                let mut value_restart_policy: Option<std::string::String> = None;
243                let mut value_restart_policy_rules: Option<std::vec::Vec<crate::api::core::v1::ContainerRestartRule>> = None;
244                let mut value_security_context: Option<crate::api::core::v1::SecurityContext> = None;
245                let mut value_startup_probe: Option<crate::api::core::v1::Probe> = None;
246                let mut value_stdin: Option<bool> = None;
247                let mut value_stdin_once: Option<bool> = None;
248                let mut value_termination_message_path: Option<std::string::String> = None;
249                let mut value_termination_message_policy: Option<std::string::String> = None;
250                let mut value_tty: Option<bool> = None;
251                let mut value_volume_devices: Option<std::vec::Vec<crate::api::core::v1::VolumeDevice>> = None;
252                let mut value_volume_mounts: Option<std::vec::Vec<crate::api::core::v1::VolumeMount>> = None;
253                let mut value_working_dir: Option<std::string::String> = None;
254
255                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
256                    match key {
257                        Field::Key_args => value_args = crate::serde::de::MapAccess::next_value(&mut map)?,
258                        Field::Key_command => value_command = crate::serde::de::MapAccess::next_value(&mut map)?,
259                        Field::Key_env => value_env = crate::serde::de::MapAccess::next_value(&mut map)?,
260                        Field::Key_env_from => value_env_from = crate::serde::de::MapAccess::next_value(&mut map)?,
261                        Field::Key_image => value_image = crate::serde::de::MapAccess::next_value(&mut map)?,
262                        Field::Key_image_pull_policy => value_image_pull_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
263                        Field::Key_lifecycle => value_lifecycle = crate::serde::de::MapAccess::next_value(&mut map)?,
264                        Field::Key_liveness_probe => value_liveness_probe = crate::serde::de::MapAccess::next_value(&mut map)?,
265                        Field::Key_name => value_name = crate::serde::de::MapAccess::next_value(&mut map)?,
266                        Field::Key_ports => value_ports = crate::serde::de::MapAccess::next_value(&mut map)?,
267                        Field::Key_readiness_probe => value_readiness_probe = crate::serde::de::MapAccess::next_value(&mut map)?,
268                        Field::Key_resize_policy => value_resize_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
269                        Field::Key_resources => value_resources = crate::serde::de::MapAccess::next_value(&mut map)?,
270                        Field::Key_restart_policy => value_restart_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
271                        Field::Key_restart_policy_rules => value_restart_policy_rules = crate::serde::de::MapAccess::next_value(&mut map)?,
272                        Field::Key_security_context => value_security_context = crate::serde::de::MapAccess::next_value(&mut map)?,
273                        Field::Key_startup_probe => value_startup_probe = crate::serde::de::MapAccess::next_value(&mut map)?,
274                        Field::Key_stdin => value_stdin = crate::serde::de::MapAccess::next_value(&mut map)?,
275                        Field::Key_stdin_once => value_stdin_once = crate::serde::de::MapAccess::next_value(&mut map)?,
276                        Field::Key_termination_message_path => value_termination_message_path = crate::serde::de::MapAccess::next_value(&mut map)?,
277                        Field::Key_termination_message_policy => value_termination_message_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
278                        Field::Key_tty => value_tty = crate::serde::de::MapAccess::next_value(&mut map)?,
279                        Field::Key_volume_devices => value_volume_devices = crate::serde::de::MapAccess::next_value(&mut map)?,
280                        Field::Key_volume_mounts => value_volume_mounts = crate::serde::de::MapAccess::next_value(&mut map)?,
281                        Field::Key_working_dir => value_working_dir = crate::serde::de::MapAccess::next_value(&mut map)?,
282                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
283                    }
284                }
285
286                Ok(Container {
287                    args: value_args,
288                    command: value_command,
289                    env: value_env,
290                    env_from: value_env_from,
291                    image: value_image,
292                    image_pull_policy: value_image_pull_policy,
293                    lifecycle: value_lifecycle,
294                    liveness_probe: value_liveness_probe,
295                    name: value_name.unwrap_or_default(),
296                    ports: value_ports,
297                    readiness_probe: value_readiness_probe,
298                    resize_policy: value_resize_policy,
299                    resources: value_resources,
300                    restart_policy: value_restart_policy,
301                    restart_policy_rules: value_restart_policy_rules,
302                    security_context: value_security_context,
303                    startup_probe: value_startup_probe,
304                    stdin: value_stdin,
305                    stdin_once: value_stdin_once,
306                    termination_message_path: value_termination_message_path,
307                    termination_message_policy: value_termination_message_policy,
308                    tty: value_tty,
309                    volume_devices: value_volume_devices,
310                    volume_mounts: value_volume_mounts,
311                    working_dir: value_working_dir,
312                })
313            }
314        }
315
316        deserializer.deserialize_struct(
317            "Container",
318            &[
319                "args",
320                "command",
321                "env",
322                "envFrom",
323                "image",
324                "imagePullPolicy",
325                "lifecycle",
326                "livenessProbe",
327                "name",
328                "ports",
329                "readinessProbe",
330                "resizePolicy",
331                "resources",
332                "restartPolicy",
333                "restartPolicyRules",
334                "securityContext",
335                "startupProbe",
336                "stdin",
337                "stdinOnce",
338                "terminationMessagePath",
339                "terminationMessagePolicy",
340                "tty",
341                "volumeDevices",
342                "volumeMounts",
343                "workingDir",
344            ],
345            Visitor,
346        )
347    }
348}
349
350impl crate::serde::Serialize for Container {
351    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
352        let mut state = serializer.serialize_struct(
353            "Container",
354            1 +
355            self.args.as_ref().map_or(0, |_| 1) +
356            self.command.as_ref().map_or(0, |_| 1) +
357            self.env.as_ref().map_or(0, |_| 1) +
358            self.env_from.as_ref().map_or(0, |_| 1) +
359            self.image.as_ref().map_or(0, |_| 1) +
360            self.image_pull_policy.as_ref().map_or(0, |_| 1) +
361            self.lifecycle.as_ref().map_or(0, |_| 1) +
362            self.liveness_probe.as_ref().map_or(0, |_| 1) +
363            self.ports.as_ref().map_or(0, |_| 1) +
364            self.readiness_probe.as_ref().map_or(0, |_| 1) +
365            self.resize_policy.as_ref().map_or(0, |_| 1) +
366            self.resources.as_ref().map_or(0, |_| 1) +
367            self.restart_policy.as_ref().map_or(0, |_| 1) +
368            self.restart_policy_rules.as_ref().map_or(0, |_| 1) +
369            self.security_context.as_ref().map_or(0, |_| 1) +
370            self.startup_probe.as_ref().map_or(0, |_| 1) +
371            self.stdin.as_ref().map_or(0, |_| 1) +
372            self.stdin_once.as_ref().map_or(0, |_| 1) +
373            self.termination_message_path.as_ref().map_or(0, |_| 1) +
374            self.termination_message_policy.as_ref().map_or(0, |_| 1) +
375            self.tty.as_ref().map_or(0, |_| 1) +
376            self.volume_devices.as_ref().map_or(0, |_| 1) +
377            self.volume_mounts.as_ref().map_or(0, |_| 1) +
378            self.working_dir.as_ref().map_or(0, |_| 1),
379        )?;
380        if let Some(value) = &self.args {
381            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "args", value)?;
382        }
383        if let Some(value) = &self.command {
384            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "command", value)?;
385        }
386        if let Some(value) = &self.env {
387            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "env", value)?;
388        }
389        if let Some(value) = &self.env_from {
390            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "envFrom", value)?;
391        }
392        if let Some(value) = &self.image {
393            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "image", value)?;
394        }
395        if let Some(value) = &self.image_pull_policy {
396            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "imagePullPolicy", value)?;
397        }
398        if let Some(value) = &self.lifecycle {
399            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "lifecycle", value)?;
400        }
401        if let Some(value) = &self.liveness_probe {
402            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "livenessProbe", value)?;
403        }
404        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "name", &self.name)?;
405        if let Some(value) = &self.ports {
406            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ports", value)?;
407        }
408        if let Some(value) = &self.readiness_probe {
409            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readinessProbe", value)?;
410        }
411        if let Some(value) = &self.resize_policy {
412            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resizePolicy", value)?;
413        }
414        if let Some(value) = &self.resources {
415            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resources", value)?;
416        }
417        if let Some(value) = &self.restart_policy {
418            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "restartPolicy", value)?;
419        }
420        if let Some(value) = &self.restart_policy_rules {
421            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "restartPolicyRules", value)?;
422        }
423        if let Some(value) = &self.security_context {
424            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "securityContext", value)?;
425        }
426        if let Some(value) = &self.startup_probe {
427            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "startupProbe", value)?;
428        }
429        if let Some(value) = &self.stdin {
430            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "stdin", value)?;
431        }
432        if let Some(value) = &self.stdin_once {
433            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "stdinOnce", value)?;
434        }
435        if let Some(value) = &self.termination_message_path {
436            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "terminationMessagePath", value)?;
437        }
438        if let Some(value) = &self.termination_message_policy {
439            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "terminationMessagePolicy", value)?;
440        }
441        if let Some(value) = &self.tty {
442            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "tty", value)?;
443        }
444        if let Some(value) = &self.volume_devices {
445            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "volumeDevices", value)?;
446        }
447        if let Some(value) = &self.volume_mounts {
448            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "volumeMounts", value)?;
449        }
450        if let Some(value) = &self.working_dir {
451            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "workingDir", value)?;
452        }
453        crate::serde::ser::SerializeStruct::end(state)
454    }
455}
456
457#[cfg(feature = "schemars")]
458impl crate::schemars::JsonSchema for Container {
459    fn schema_name() -> std::borrow::Cow<'static, str> {
460        "io.k8s.api.core.v1.Container".into()
461    }
462
463    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
464        crate::schemars::json_schema!({
465            "description": "A single application container that you want to run within a pod.",
466            "type": "object",
467            "properties": {
468                "args": {
469                    "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",
470                    "type": "array",
471                    "items": {
472                        "type": "string",
473                    },
474                },
475                "command": {
476                    "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",
477                    "type": "array",
478                    "items": {
479                        "type": "string",
480                    },
481                },
482                "env": {
483                    "description": "List of environment variables to set in the container. Cannot be updated.",
484                    "type": "array",
485                    "items": (__gen.subschema_for::<crate::api::core::v1::EnvVar>()),
486                },
487                "envFrom": {
488                    "description": "List of sources to populate environment variables in the container. The keys defined within a source may consist of any printable ASCII characters except '='. 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.",
489                    "type": "array",
490                    "items": (__gen.subschema_for::<crate::api::core::v1::EnvFromSource>()),
491                },
492                "image": {
493                    "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.",
494                    "type": "string",
495                },
496                "imagePullPolicy": {
497                    "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",
498                    "type": "string",
499                },
500                "lifecycle": ({
501                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::Lifecycle>();
502                    schema_obj.ensure_object().insert("description".into(), "Actions that the management system should take in response to container lifecycle events. Cannot be updated.".into());
503                    schema_obj
504                }),
505                "livenessProbe": ({
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 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());
508                    schema_obj
509                }),
510                "name": {
511                    "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.",
512                    "type": "string",
513                },
514                "ports": {
515                    "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.",
516                    "type": "array",
517                    "items": (__gen.subschema_for::<crate::api::core::v1::ContainerPort>()),
518                },
519                "readinessProbe": ({
520                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::Probe>();
521                    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());
522                    schema_obj
523                }),
524                "resizePolicy": {
525                    "description": "Resources resize policy for the container.",
526                    "type": "array",
527                    "items": (__gen.subschema_for::<crate::api::core::v1::ContainerResizePolicy>()),
528                },
529                "resources": ({
530                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::ResourceRequirements>();
531                    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());
532                    schema_obj
533                }),
534                "restartPolicy": {
535                    "description": "RestartPolicy defines the restart behavior of individual containers in a pod. This overrides the pod-level restart policy. When this field is not specified, the restart behavior is defined by the Pod's restart policy and the container type. Additionally, 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.",
536                    "type": "string",
537                },
538                "restartPolicyRules": {
539                    "description": "Represents a list of rules to be checked to determine if the container should be restarted on exit. The rules are evaluated in order. Once a rule matches a container exit condition, the remaining rules are ignored. If no rule matches the container exit condition, the Container-level restart policy determines the whether the container is restarted or not. Constraints on the rules: - At most 20 rules are allowed. - Rules can have the same action. - Identical rules are not forbidden in validations. When rules are specified, container MUST set RestartPolicy explicitly even it if matches the Pod's RestartPolicy.",
540                    "type": "array",
541                    "items": (__gen.subschema_for::<crate::api::core::v1::ContainerRestartRule>()),
542                },
543                "securityContext": ({
544                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::SecurityContext>();
545                    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());
546                    schema_obj
547                }),
548                "startupProbe": ({
549                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::Probe>();
550                    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());
551                    schema_obj
552                }),
553                "stdin": {
554                    "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.",
555                    "type": "boolean",
556                },
557                "stdinOnce": {
558                    "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",
559                    "type": "boolean",
560                },
561                "terminationMessagePath": {
562                    "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.",
563                    "type": "string",
564                },
565                "terminationMessagePolicy": {
566                    "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.",
567                    "type": "string",
568                },
569                "tty": {
570                    "description": "Whether this container should allocate a TTY for itself, also requires 'stdin' to be true. Default is false.",
571                    "type": "boolean",
572                },
573                "volumeDevices": {
574                    "description": "volumeDevices is the list of block devices to be used by the container.",
575                    "type": "array",
576                    "items": (__gen.subschema_for::<crate::api::core::v1::VolumeDevice>()),
577                },
578                "volumeMounts": {
579                    "description": "Pod volumes to mount into the container's filesystem. Cannot be updated.",
580                    "type": "array",
581                    "items": (__gen.subschema_for::<crate::api::core::v1::VolumeMount>()),
582                },
583                "workingDir": {
584                    "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.",
585                    "type": "string",
586                },
587            },
588            "required": [
589                "name",
590            ],
591        })
592    }
593}