k8s_openapi/v1_35/api/core/v1/
ephemeral_volume_source.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct EphemeralVolumeSource {
6 pub volume_claim_template: Option<crate::api::core::v1::PersistentVolumeClaimTemplate>,
14}
15
16impl crate::DeepMerge for EphemeralVolumeSource {
17 fn merge_from(&mut self, other: Self) {
18 crate::DeepMerge::merge_from(&mut self.volume_claim_template, other.volume_claim_template);
19 }
20}
21
22impl<'de> crate::serde::Deserialize<'de> for EphemeralVolumeSource {
23 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
24 #[allow(non_camel_case_types)]
25 enum Field {
26 Key_volume_claim_template,
27 Other,
28 }
29
30 impl<'de> crate::serde::Deserialize<'de> for Field {
31 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
32 struct Visitor;
33
34 impl crate::serde::de::Visitor<'_> for Visitor {
35 type Value = Field;
36
37 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
38 f.write_str("field identifier")
39 }
40
41 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
42 Ok(match v {
43 "volumeClaimTemplate" => Field::Key_volume_claim_template,
44 _ => Field::Other,
45 })
46 }
47 }
48
49 deserializer.deserialize_identifier(Visitor)
50 }
51 }
52
53 struct Visitor;
54
55 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
56 type Value = EphemeralVolumeSource;
57
58 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
59 f.write_str("EphemeralVolumeSource")
60 }
61
62 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
63 let mut value_volume_claim_template: Option<crate::api::core::v1::PersistentVolumeClaimTemplate> = None;
64
65 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
66 match key {
67 Field::Key_volume_claim_template => value_volume_claim_template = crate::serde::de::MapAccess::next_value(&mut map)?,
68 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
69 }
70 }
71
72 Ok(EphemeralVolumeSource {
73 volume_claim_template: value_volume_claim_template,
74 })
75 }
76 }
77
78 deserializer.deserialize_struct(
79 "EphemeralVolumeSource",
80 &[
81 "volumeClaimTemplate",
82 ],
83 Visitor,
84 )
85 }
86}
87
88impl crate::serde::Serialize for EphemeralVolumeSource {
89 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
90 let mut state = serializer.serialize_struct(
91 "EphemeralVolumeSource",
92 self.volume_claim_template.as_ref().map_or(0, |_| 1),
93 )?;
94 if let Some(value) = &self.volume_claim_template {
95 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "volumeClaimTemplate", value)?;
96 }
97 crate::serde::ser::SerializeStruct::end(state)
98 }
99}
100
101#[cfg(feature = "schemars")]
102impl crate::schemars::JsonSchema for EphemeralVolumeSource {
103 fn schema_name() -> std::borrow::Cow<'static, str> {
104 "io.k8s.api.core.v1.EphemeralVolumeSource".into()
105 }
106
107 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
108 crate::schemars::json_schema!({
109 "description": "Represents an ephemeral volume that is handled by a normal storage driver.",
110 "type": "object",
111 "properties": {
112 "volumeClaimTemplate": ({
113 let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::PersistentVolumeClaimTemplate>();
114 schema_obj.ensure_object().insert("description".into(), "Will be used to create a stand-alone PVC to provision the volume. The pod in which this EphemeralVolumeSource is embedded will be the owner of the PVC, i.e. the PVC will be deleted together with the pod. The name of the PVC will be `<pod name>-<volume name>` where `<volume name>` is the name from the `PodSpec.Volumes` array entry. Pod validation will reject the pod if the concatenated name is not valid for a PVC (for example, too long).\n\nAn existing PVC with that name that is not owned by the pod will *not* be used for the pod to avoid using an unrelated volume by mistake. Starting the pod is then blocked until the unrelated PVC is removed. If such a pre-created PVC is meant to be used by the pod, the PVC has to updated with an owner reference to the pod once the pod exists. Normally this should not be necessary, but it may be useful when manually reconstructing a broken cluster.\n\nThis field is read-only and no changes will be made by Kubernetes to the PVC after it has been created.\n\nRequired, must not be nil.".into());
115 schema_obj
116 }),
117 },
118 })
119 }
120}