k8s_openapi/v1_30/api/core/v1/
ephemeral_container.rs

1// Generated from definition io.k8s.api.core.v1.EphemeralContainer
2
3/// An EphemeralContainer is a temporary container that you may add to an existing Pod for user-initiated activities such as debugging. Ephemeral containers have no resource or scheduling guarantees, and they will not be restarted when they exit or when a Pod is removed or restarted. The kubelet may evict a Pod if an ephemeral container causes the Pod to exceed its resource allocation.
4///
5/// To add an ephemeral container, use the ephemeralcontainers subresource of an existing Pod. Ephemeral containers may not be removed or restarted.
6#[derive(Clone, Debug, Default, PartialEq)]
7pub struct EphemeralContainer {
8    /// Arguments to the entrypoint. The 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
9    pub args: Option<std::vec::Vec<std::string::String>>,
10
11    /// Entrypoint array. Not executed within a shell. The 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
12    pub command: Option<std::vec::Vec<std::string::String>>,
13
14    /// List of environment variables to set in the container. Cannot be updated.
15    pub env: Option<std::vec::Vec<crate::api::core::v1::EnvVar>>,
16
17    /// 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.
18    pub env_from: Option<std::vec::Vec<crate::api::core::v1::EnvFromSource>>,
19
20    /// Container image name. More info: https://kubernetes.io/docs/concepts/containers/images
21    pub image: Option<std::string::String>,
22
23    /// 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
24    pub image_pull_policy: Option<std::string::String>,
25
26    /// Lifecycle is not allowed for ephemeral containers.
27    pub lifecycle: Option<crate::api::core::v1::Lifecycle>,
28
29    /// Probes are not allowed for ephemeral containers.
30    pub liveness_probe: Option<crate::api::core::v1::Probe>,
31
32    /// Name of the ephemeral container specified as a DNS_LABEL. This name must be unique among all containers, init containers and ephemeral containers.
33    pub name: std::string::String,
34
35    /// Ports are not allowed for ephemeral containers.
36    pub ports: Option<std::vec::Vec<crate::api::core::v1::ContainerPort>>,
37
38    /// Probes are not allowed for ephemeral containers.
39    pub readiness_probe: Option<crate::api::core::v1::Probe>,
40
41    /// Resources resize policy for the container.
42    pub resize_policy: Option<std::vec::Vec<crate::api::core::v1::ContainerResizePolicy>>,
43
44    /// Resources are not allowed for ephemeral containers. Ephemeral containers use spare resources already allocated to the pod.
45    pub resources: Option<crate::api::core::v1::ResourceRequirements>,
46
47    /// Restart policy for the container to manage the restart behavior of each container within a pod. This may only be set for init containers. You cannot set this field on ephemeral containers.
48    pub restart_policy: Option<std::string::String>,
49
50    /// Optional: SecurityContext defines the security options the ephemeral container should be run with. If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext.
51    pub security_context: Option<crate::api::core::v1::SecurityContext>,
52
53    /// Probes are not allowed for ephemeral containers.
54    pub startup_probe: Option<crate::api::core::v1::Probe>,
55
56    /// 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.
57    pub stdin: Option<bool>,
58
59    /// 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
60    pub stdin_once: Option<bool>,
61
62    /// If set, the name of the container from PodSpec that this ephemeral container targets. The ephemeral container will be run in the namespaces (IPC, PID, etc) of this container. If not set then the ephemeral container uses the namespaces configured in the Pod spec.
63    ///
64    /// The container runtime must implement support for this feature. If the runtime does not support namespace targeting then the result of setting this field is undefined.
65    pub target_container_name: Option<std::string::String>,
66
67    /// 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.
68    pub termination_message_path: Option<std::string::String>,
69
70    /// 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.
71    pub termination_message_policy: Option<std::string::String>,
72
73    /// Whether this container should allocate a TTY for itself, also requires 'stdin' to be true. Default is false.
74    pub tty: Option<bool>,
75
76    /// volumeDevices is the list of block devices to be used by the container.
77    pub volume_devices: Option<std::vec::Vec<crate::api::core::v1::VolumeDevice>>,
78
79    /// Pod volumes to mount into the container's filesystem. Subpath mounts are not allowed for ephemeral containers. Cannot be updated.
80    pub volume_mounts: Option<std::vec::Vec<crate::api::core::v1::VolumeMount>>,
81
82    /// 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.
83    pub working_dir: Option<std::string::String>,
84}
85
86impl crate::DeepMerge for EphemeralContainer {
87    fn merge_from(&mut self, other: Self) {
88        crate::merge_strategies::list::atomic(&mut self.args, other.args);
89        crate::merge_strategies::list::atomic(&mut self.command, other.command);
90        crate::merge_strategies::list::map(
91            &mut self.env,
92            other.env,
93            &[|lhs, rhs| lhs.name == rhs.name],
94            |current_item, other_item| {
95                crate::DeepMerge::merge_from(current_item, other_item);
96            },
97        );
98        crate::merge_strategies::list::atomic(&mut self.env_from, other.env_from);
99        crate::DeepMerge::merge_from(&mut self.image, other.image);
100        crate::DeepMerge::merge_from(&mut self.image_pull_policy, other.image_pull_policy);
101        crate::DeepMerge::merge_from(&mut self.lifecycle, other.lifecycle);
102        crate::DeepMerge::merge_from(&mut self.liveness_probe, other.liveness_probe);
103        crate::DeepMerge::merge_from(&mut self.name, other.name);
104        crate::merge_strategies::list::map(
105            &mut self.ports,
106            other.ports,
107            &[|lhs, rhs| lhs.container_port == rhs.container_port],
108            |current_item, other_item| {
109                crate::DeepMerge::merge_from(current_item, other_item);
110            },
111        );
112        crate::DeepMerge::merge_from(&mut self.readiness_probe, other.readiness_probe);
113        crate::merge_strategies::list::atomic(&mut self.resize_policy, other.resize_policy);
114        crate::DeepMerge::merge_from(&mut self.resources, other.resources);
115        crate::DeepMerge::merge_from(&mut self.restart_policy, other.restart_policy);
116        crate::DeepMerge::merge_from(&mut self.security_context, other.security_context);
117        crate::DeepMerge::merge_from(&mut self.startup_probe, other.startup_probe);
118        crate::DeepMerge::merge_from(&mut self.stdin, other.stdin);
119        crate::DeepMerge::merge_from(&mut self.stdin_once, other.stdin_once);
120        crate::DeepMerge::merge_from(&mut self.target_container_name, other.target_container_name);
121        crate::DeepMerge::merge_from(&mut self.termination_message_path, other.termination_message_path);
122        crate::DeepMerge::merge_from(&mut self.termination_message_policy, other.termination_message_policy);
123        crate::DeepMerge::merge_from(&mut self.tty, other.tty);
124        crate::merge_strategies::list::map(
125            &mut self.volume_devices,
126            other.volume_devices,
127            &[|lhs, rhs| lhs.device_path == rhs.device_path],
128            |current_item, other_item| {
129                crate::DeepMerge::merge_from(current_item, other_item);
130            },
131        );
132        crate::merge_strategies::list::map(
133            &mut self.volume_mounts,
134            other.volume_mounts,
135            &[|lhs, rhs| lhs.mount_path == rhs.mount_path],
136            |current_item, other_item| {
137                crate::DeepMerge::merge_from(current_item, other_item);
138            },
139        );
140        crate::DeepMerge::merge_from(&mut self.working_dir, other.working_dir);
141    }
142}
143
144impl<'de> crate::serde::Deserialize<'de> for EphemeralContainer {
145    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
146        #[allow(non_camel_case_types)]
147        enum Field {
148            Key_args,
149            Key_command,
150            Key_env,
151            Key_env_from,
152            Key_image,
153            Key_image_pull_policy,
154            Key_lifecycle,
155            Key_liveness_probe,
156            Key_name,
157            Key_ports,
158            Key_readiness_probe,
159            Key_resize_policy,
160            Key_resources,
161            Key_restart_policy,
162            Key_security_context,
163            Key_startup_probe,
164            Key_stdin,
165            Key_stdin_once,
166            Key_target_container_name,
167            Key_termination_message_path,
168            Key_termination_message_policy,
169            Key_tty,
170            Key_volume_devices,
171            Key_volume_mounts,
172            Key_working_dir,
173            Other,
174        }
175
176        impl<'de> crate::serde::Deserialize<'de> for Field {
177            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
178                struct Visitor;
179
180                impl crate::serde::de::Visitor<'_> for Visitor {
181                    type Value = Field;
182
183                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
184                        f.write_str("field identifier")
185                    }
186
187                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
188                        Ok(match v {
189                            "args" => Field::Key_args,
190                            "command" => Field::Key_command,
191                            "env" => Field::Key_env,
192                            "envFrom" => Field::Key_env_from,
193                            "image" => Field::Key_image,
194                            "imagePullPolicy" => Field::Key_image_pull_policy,
195                            "lifecycle" => Field::Key_lifecycle,
196                            "livenessProbe" => Field::Key_liveness_probe,
197                            "name" => Field::Key_name,
198                            "ports" => Field::Key_ports,
199                            "readinessProbe" => Field::Key_readiness_probe,
200                            "resizePolicy" => Field::Key_resize_policy,
201                            "resources" => Field::Key_resources,
202                            "restartPolicy" => Field::Key_restart_policy,
203                            "securityContext" => Field::Key_security_context,
204                            "startupProbe" => Field::Key_startup_probe,
205                            "stdin" => Field::Key_stdin,
206                            "stdinOnce" => Field::Key_stdin_once,
207                            "targetContainerName" => Field::Key_target_container_name,
208                            "terminationMessagePath" => Field::Key_termination_message_path,
209                            "terminationMessagePolicy" => Field::Key_termination_message_policy,
210                            "tty" => Field::Key_tty,
211                            "volumeDevices" => Field::Key_volume_devices,
212                            "volumeMounts" => Field::Key_volume_mounts,
213                            "workingDir" => Field::Key_working_dir,
214                            _ => Field::Other,
215                        })
216                    }
217                }
218
219                deserializer.deserialize_identifier(Visitor)
220            }
221        }
222
223        struct Visitor;
224
225        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
226            type Value = EphemeralContainer;
227
228            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
229                f.write_str("EphemeralContainer")
230            }
231
232            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
233                let mut value_args: Option<std::vec::Vec<std::string::String>> = None;
234                let mut value_command: Option<std::vec::Vec<std::string::String>> = None;
235                let mut value_env: Option<std::vec::Vec<crate::api::core::v1::EnvVar>> = None;
236                let mut value_env_from: Option<std::vec::Vec<crate::api::core::v1::EnvFromSource>> = None;
237                let mut value_image: Option<std::string::String> = None;
238                let mut value_image_pull_policy: Option<std::string::String> = None;
239                let mut value_lifecycle: Option<crate::api::core::v1::Lifecycle> = None;
240                let mut value_liveness_probe: Option<crate::api::core::v1::Probe> = None;
241                let mut value_name: Option<std::string::String> = None;
242                let mut value_ports: Option<std::vec::Vec<crate::api::core::v1::ContainerPort>> = None;
243                let mut value_readiness_probe: Option<crate::api::core::v1::Probe> = None;
244                let mut value_resize_policy: Option<std::vec::Vec<crate::api::core::v1::ContainerResizePolicy>> = None;
245                let mut value_resources: Option<crate::api::core::v1::ResourceRequirements> = None;
246                let mut value_restart_policy: Option<std::string::String> = None;
247                let mut value_security_context: Option<crate::api::core::v1::SecurityContext> = None;
248                let mut value_startup_probe: Option<crate::api::core::v1::Probe> = None;
249                let mut value_stdin: Option<bool> = None;
250                let mut value_stdin_once: Option<bool> = None;
251                let mut value_target_container_name: Option<std::string::String> = None;
252                let mut value_termination_message_path: Option<std::string::String> = None;
253                let mut value_termination_message_policy: Option<std::string::String> = None;
254                let mut value_tty: Option<bool> = None;
255                let mut value_volume_devices: Option<std::vec::Vec<crate::api::core::v1::VolumeDevice>> = None;
256                let mut value_volume_mounts: Option<std::vec::Vec<crate::api::core::v1::VolumeMount>> = None;
257                let mut value_working_dir: Option<std::string::String> = None;
258
259                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
260                    match key {
261                        Field::Key_args => value_args = crate::serde::de::MapAccess::next_value(&mut map)?,
262                        Field::Key_command => value_command = crate::serde::de::MapAccess::next_value(&mut map)?,
263                        Field::Key_env => value_env = crate::serde::de::MapAccess::next_value(&mut map)?,
264                        Field::Key_env_from => value_env_from = crate::serde::de::MapAccess::next_value(&mut map)?,
265                        Field::Key_image => value_image = crate::serde::de::MapAccess::next_value(&mut map)?,
266                        Field::Key_image_pull_policy => value_image_pull_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
267                        Field::Key_lifecycle => value_lifecycle = crate::serde::de::MapAccess::next_value(&mut map)?,
268                        Field::Key_liveness_probe => value_liveness_probe = crate::serde::de::MapAccess::next_value(&mut map)?,
269                        Field::Key_name => value_name = crate::serde::de::MapAccess::next_value(&mut map)?,
270                        Field::Key_ports => value_ports = crate::serde::de::MapAccess::next_value(&mut map)?,
271                        Field::Key_readiness_probe => value_readiness_probe = crate::serde::de::MapAccess::next_value(&mut map)?,
272                        Field::Key_resize_policy => value_resize_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
273                        Field::Key_resources => value_resources = crate::serde::de::MapAccess::next_value(&mut map)?,
274                        Field::Key_restart_policy => value_restart_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
275                        Field::Key_security_context => value_security_context = crate::serde::de::MapAccess::next_value(&mut map)?,
276                        Field::Key_startup_probe => value_startup_probe = crate::serde::de::MapAccess::next_value(&mut map)?,
277                        Field::Key_stdin => value_stdin = crate::serde::de::MapAccess::next_value(&mut map)?,
278                        Field::Key_stdin_once => value_stdin_once = crate::serde::de::MapAccess::next_value(&mut map)?,
279                        Field::Key_target_container_name => value_target_container_name = crate::serde::de::MapAccess::next_value(&mut map)?,
280                        Field::Key_termination_message_path => value_termination_message_path = crate::serde::de::MapAccess::next_value(&mut map)?,
281                        Field::Key_termination_message_policy => value_termination_message_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
282                        Field::Key_tty => value_tty = crate::serde::de::MapAccess::next_value(&mut map)?,
283                        Field::Key_volume_devices => value_volume_devices = crate::serde::de::MapAccess::next_value(&mut map)?,
284                        Field::Key_volume_mounts => value_volume_mounts = crate::serde::de::MapAccess::next_value(&mut map)?,
285                        Field::Key_working_dir => value_working_dir = crate::serde::de::MapAccess::next_value(&mut map)?,
286                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
287                    }
288                }
289
290                Ok(EphemeralContainer {
291                    args: value_args,
292                    command: value_command,
293                    env: value_env,
294                    env_from: value_env_from,
295                    image: value_image,
296                    image_pull_policy: value_image_pull_policy,
297                    lifecycle: value_lifecycle,
298                    liveness_probe: value_liveness_probe,
299                    name: value_name.unwrap_or_default(),
300                    ports: value_ports,
301                    readiness_probe: value_readiness_probe,
302                    resize_policy: value_resize_policy,
303                    resources: value_resources,
304                    restart_policy: value_restart_policy,
305                    security_context: value_security_context,
306                    startup_probe: value_startup_probe,
307                    stdin: value_stdin,
308                    stdin_once: value_stdin_once,
309                    target_container_name: value_target_container_name,
310                    termination_message_path: value_termination_message_path,
311                    termination_message_policy: value_termination_message_policy,
312                    tty: value_tty,
313                    volume_devices: value_volume_devices,
314                    volume_mounts: value_volume_mounts,
315                    working_dir: value_working_dir,
316                })
317            }
318        }
319
320        deserializer.deserialize_struct(
321            "EphemeralContainer",
322            &[
323                "args",
324                "command",
325                "env",
326                "envFrom",
327                "image",
328                "imagePullPolicy",
329                "lifecycle",
330                "livenessProbe",
331                "name",
332                "ports",
333                "readinessProbe",
334                "resizePolicy",
335                "resources",
336                "restartPolicy",
337                "securityContext",
338                "startupProbe",
339                "stdin",
340                "stdinOnce",
341                "targetContainerName",
342                "terminationMessagePath",
343                "terminationMessagePolicy",
344                "tty",
345                "volumeDevices",
346                "volumeMounts",
347                "workingDir",
348            ],
349            Visitor,
350        )
351    }
352}
353
354impl crate::serde::Serialize for EphemeralContainer {
355    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
356        let mut state = serializer.serialize_struct(
357            "EphemeralContainer",
358            1 +
359            self.args.as_ref().map_or(0, |_| 1) +
360            self.command.as_ref().map_or(0, |_| 1) +
361            self.env.as_ref().map_or(0, |_| 1) +
362            self.env_from.as_ref().map_or(0, |_| 1) +
363            self.image.as_ref().map_or(0, |_| 1) +
364            self.image_pull_policy.as_ref().map_or(0, |_| 1) +
365            self.lifecycle.as_ref().map_or(0, |_| 1) +
366            self.liveness_probe.as_ref().map_or(0, |_| 1) +
367            self.ports.as_ref().map_or(0, |_| 1) +
368            self.readiness_probe.as_ref().map_or(0, |_| 1) +
369            self.resize_policy.as_ref().map_or(0, |_| 1) +
370            self.resources.as_ref().map_or(0, |_| 1) +
371            self.restart_policy.as_ref().map_or(0, |_| 1) +
372            self.security_context.as_ref().map_or(0, |_| 1) +
373            self.startup_probe.as_ref().map_or(0, |_| 1) +
374            self.stdin.as_ref().map_or(0, |_| 1) +
375            self.stdin_once.as_ref().map_or(0, |_| 1) +
376            self.target_container_name.as_ref().map_or(0, |_| 1) +
377            self.termination_message_path.as_ref().map_or(0, |_| 1) +
378            self.termination_message_policy.as_ref().map_or(0, |_| 1) +
379            self.tty.as_ref().map_or(0, |_| 1) +
380            self.volume_devices.as_ref().map_or(0, |_| 1) +
381            self.volume_mounts.as_ref().map_or(0, |_| 1) +
382            self.working_dir.as_ref().map_or(0, |_| 1),
383        )?;
384        if let Some(value) = &self.args {
385            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "args", value)?;
386        }
387        if let Some(value) = &self.command {
388            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "command", value)?;
389        }
390        if let Some(value) = &self.env {
391            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "env", value)?;
392        }
393        if let Some(value) = &self.env_from {
394            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "envFrom", value)?;
395        }
396        if let Some(value) = &self.image {
397            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "image", value)?;
398        }
399        if let Some(value) = &self.image_pull_policy {
400            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "imagePullPolicy", value)?;
401        }
402        if let Some(value) = &self.lifecycle {
403            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "lifecycle", value)?;
404        }
405        if let Some(value) = &self.liveness_probe {
406            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "livenessProbe", value)?;
407        }
408        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "name", &self.name)?;
409        if let Some(value) = &self.ports {
410            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ports", value)?;
411        }
412        if let Some(value) = &self.readiness_probe {
413            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readinessProbe", value)?;
414        }
415        if let Some(value) = &self.resize_policy {
416            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resizePolicy", value)?;
417        }
418        if let Some(value) = &self.resources {
419            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resources", value)?;
420        }
421        if let Some(value) = &self.restart_policy {
422            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "restartPolicy", value)?;
423        }
424        if let Some(value) = &self.security_context {
425            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "securityContext", value)?;
426        }
427        if let Some(value) = &self.startup_probe {
428            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "startupProbe", value)?;
429        }
430        if let Some(value) = &self.stdin {
431            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "stdin", value)?;
432        }
433        if let Some(value) = &self.stdin_once {
434            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "stdinOnce", value)?;
435        }
436        if let Some(value) = &self.target_container_name {
437            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "targetContainerName", value)?;
438        }
439        if let Some(value) = &self.termination_message_path {
440            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "terminationMessagePath", value)?;
441        }
442        if let Some(value) = &self.termination_message_policy {
443            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "terminationMessagePolicy", value)?;
444        }
445        if let Some(value) = &self.tty {
446            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "tty", value)?;
447        }
448        if let Some(value) = &self.volume_devices {
449            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "volumeDevices", value)?;
450        }
451        if let Some(value) = &self.volume_mounts {
452            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "volumeMounts", value)?;
453        }
454        if let Some(value) = &self.working_dir {
455            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "workingDir", value)?;
456        }
457        crate::serde::ser::SerializeStruct::end(state)
458    }
459}
460
461#[cfg(feature = "schemars")]
462impl crate::schemars::JsonSchema for EphemeralContainer {
463    fn schema_name() -> std::borrow::Cow<'static, str> {
464        "io.k8s.api.core.v1.EphemeralContainer".into()
465    }
466
467    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
468        crate::schemars::json_schema!({
469            "description": "An EphemeralContainer is a temporary container that you may add to an existing Pod for user-initiated activities such as debugging. Ephemeral containers have no resource or scheduling guarantees, and they will not be restarted when they exit or when a Pod is removed or restarted. The kubelet may evict a Pod if an ephemeral container causes the Pod to exceed its resource allocation.\n\nTo add an ephemeral container, use the ephemeralcontainers subresource of an existing Pod. Ephemeral containers may not be removed or restarted.",
470            "type": "object",
471            "properties": {
472                "args": {
473                    "description": "Arguments to the entrypoint. The 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",
474                    "type": "array",
475                    "items": {
476                        "type": "string",
477                    },
478                },
479                "command": {
480                    "description": "Entrypoint array. Not executed within a shell. The 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",
481                    "type": "array",
482                    "items": {
483                        "type": "string",
484                    },
485                },
486                "env": {
487                    "description": "List of environment variables to set in the container. Cannot be updated.",
488                    "type": "array",
489                    "items": (__gen.subschema_for::<crate::api::core::v1::EnvVar>()),
490                },
491                "envFrom": {
492                    "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.",
493                    "type": "array",
494                    "items": (__gen.subschema_for::<crate::api::core::v1::EnvFromSource>()),
495                },
496                "image": {
497                    "description": "Container image name. More info: https://kubernetes.io/docs/concepts/containers/images",
498                    "type": "string",
499                },
500                "imagePullPolicy": {
501                    "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",
502                    "type": "string",
503                },
504                "lifecycle": ({
505                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::Lifecycle>();
506                    schema_obj.ensure_object().insert("description".into(), "Lifecycle is not allowed for ephemeral containers.".into());
507                    schema_obj
508                }),
509                "livenessProbe": ({
510                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::Probe>();
511                    schema_obj.ensure_object().insert("description".into(), "Probes are not allowed for ephemeral containers.".into());
512                    schema_obj
513                }),
514                "name": {
515                    "description": "Name of the ephemeral container specified as a DNS_LABEL. This name must be unique among all containers, init containers and ephemeral containers.",
516                    "type": "string",
517                },
518                "ports": {
519                    "description": "Ports are not allowed for ephemeral containers.",
520                    "type": "array",
521                    "items": (__gen.subschema_for::<crate::api::core::v1::ContainerPort>()),
522                },
523                "readinessProbe": ({
524                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::Probe>();
525                    schema_obj.ensure_object().insert("description".into(), "Probes are not allowed for ephemeral containers.".into());
526                    schema_obj
527                }),
528                "resizePolicy": {
529                    "description": "Resources resize policy for the container.",
530                    "type": "array",
531                    "items": (__gen.subschema_for::<crate::api::core::v1::ContainerResizePolicy>()),
532                },
533                "resources": ({
534                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::ResourceRequirements>();
535                    schema_obj.ensure_object().insert("description".into(), "Resources are not allowed for ephemeral containers. Ephemeral containers use spare resources already allocated to the pod.".into());
536                    schema_obj
537                }),
538                "restartPolicy": {
539                    "description": "Restart policy for the container to manage the restart behavior of each container within a pod. This may only be set for init containers. You cannot set this field on ephemeral containers.",
540                    "type": "string",
541                },
542                "securityContext": ({
543                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::SecurityContext>();
544                    schema_obj.ensure_object().insert("description".into(), "Optional: SecurityContext defines the security options the ephemeral container should be run with. If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext.".into());
545                    schema_obj
546                }),
547                "startupProbe": ({
548                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::Probe>();
549                    schema_obj.ensure_object().insert("description".into(), "Probes are not allowed for ephemeral containers.".into());
550                    schema_obj
551                }),
552                "stdin": {
553                    "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.",
554                    "type": "boolean",
555                },
556                "stdinOnce": {
557                    "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",
558                    "type": "boolean",
559                },
560                "targetContainerName": {
561                    "description": "If set, the name of the container from PodSpec that this ephemeral container targets. The ephemeral container will be run in the namespaces (IPC, PID, etc) of this container. If not set then the ephemeral container uses the namespaces configured in the Pod spec.\n\nThe container runtime must implement support for this feature. If the runtime does not support namespace targeting then the result of setting this field is undefined.",
562                    "type": "string",
563                },
564                "terminationMessagePath": {
565                    "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.",
566                    "type": "string",
567                },
568                "terminationMessagePolicy": {
569                    "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.",
570                    "type": "string",
571                },
572                "tty": {
573                    "description": "Whether this container should allocate a TTY for itself, also requires 'stdin' to be true. Default is false.",
574                    "type": "boolean",
575                },
576                "volumeDevices": {
577                    "description": "volumeDevices is the list of block devices to be used by the container.",
578                    "type": "array",
579                    "items": (__gen.subschema_for::<crate::api::core::v1::VolumeDevice>()),
580                },
581                "volumeMounts": {
582                    "description": "Pod volumes to mount into the container's filesystem. Subpath mounts are not allowed for ephemeral containers. Cannot be updated.",
583                    "type": "array",
584                    "items": (__gen.subschema_for::<crate::api::core::v1::VolumeMount>()),
585                },
586                "workingDir": {
587                    "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.",
588                    "type": "string",
589                },
590            },
591            "required": [
592                "name",
593            ],
594        })
595    }
596}