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

1// Generated from definition io.k8s.api.core.v1.VolumeProjection
2
3/// Projection that may be projected along with other supported volume types
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct VolumeProjection {
6    /// ClusterTrustBundle allows a pod to access the `.spec.trustBundle` field of ClusterTrustBundle objects in an auto-updating file.
7    ///
8    /// Alpha, gated by the ClusterTrustBundleProjection feature gate.
9    ///
10    /// ClusterTrustBundle objects can either be selected by name, or by the combination of signer name and a label selector.
11    ///
12    /// Kubelet performs aggressive normalization of the PEM contents written into the pod filesystem.  Esoteric PEM features such as inter-block comments and block headers are stripped.  Certificates are deduplicated. The ordering of certificates within the file is arbitrary, and Kubelet may change the order over time.
13    pub cluster_trust_bundle: Option<crate::api::core::v1::ClusterTrustBundleProjection>,
14
15    /// configMap information about the configMap data to project
16    pub config_map: Option<crate::api::core::v1::ConfigMapProjection>,
17
18    /// downwardAPI information about the downwardAPI data to project
19    pub downward_api: Option<crate::api::core::v1::DownwardAPIProjection>,
20
21    /// secret information about the secret data to project
22    pub secret: Option<crate::api::core::v1::SecretProjection>,
23
24    /// serviceAccountToken is information about the serviceAccountToken data to project
25    pub service_account_token: Option<crate::api::core::v1::ServiceAccountTokenProjection>,
26}
27
28impl crate::DeepMerge for VolumeProjection {
29    fn merge_from(&mut self, other: Self) {
30        crate::DeepMerge::merge_from(&mut self.cluster_trust_bundle, other.cluster_trust_bundle);
31        crate::DeepMerge::merge_from(&mut self.config_map, other.config_map);
32        crate::DeepMerge::merge_from(&mut self.downward_api, other.downward_api);
33        crate::DeepMerge::merge_from(&mut self.secret, other.secret);
34        crate::DeepMerge::merge_from(&mut self.service_account_token, other.service_account_token);
35    }
36}
37
38impl<'de> crate::serde::Deserialize<'de> for VolumeProjection {
39    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
40        #[allow(non_camel_case_types)]
41        enum Field {
42            Key_cluster_trust_bundle,
43            Key_config_map,
44            Key_downward_api,
45            Key_secret,
46            Key_service_account_token,
47            Other,
48        }
49
50        impl<'de> crate::serde::Deserialize<'de> for Field {
51            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
52                struct Visitor;
53
54                impl crate::serde::de::Visitor<'_> for Visitor {
55                    type Value = Field;
56
57                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
58                        f.write_str("field identifier")
59                    }
60
61                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
62                        Ok(match v {
63                            "clusterTrustBundle" => Field::Key_cluster_trust_bundle,
64                            "configMap" => Field::Key_config_map,
65                            "downwardAPI" => Field::Key_downward_api,
66                            "secret" => Field::Key_secret,
67                            "serviceAccountToken" => Field::Key_service_account_token,
68                            _ => Field::Other,
69                        })
70                    }
71                }
72
73                deserializer.deserialize_identifier(Visitor)
74            }
75        }
76
77        struct Visitor;
78
79        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
80            type Value = VolumeProjection;
81
82            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
83                f.write_str("VolumeProjection")
84            }
85
86            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
87                let mut value_cluster_trust_bundle: Option<crate::api::core::v1::ClusterTrustBundleProjection> = None;
88                let mut value_config_map: Option<crate::api::core::v1::ConfigMapProjection> = None;
89                let mut value_downward_api: Option<crate::api::core::v1::DownwardAPIProjection> = None;
90                let mut value_secret: Option<crate::api::core::v1::SecretProjection> = None;
91                let mut value_service_account_token: Option<crate::api::core::v1::ServiceAccountTokenProjection> = None;
92
93                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
94                    match key {
95                        Field::Key_cluster_trust_bundle => value_cluster_trust_bundle = crate::serde::de::MapAccess::next_value(&mut map)?,
96                        Field::Key_config_map => value_config_map = crate::serde::de::MapAccess::next_value(&mut map)?,
97                        Field::Key_downward_api => value_downward_api = crate::serde::de::MapAccess::next_value(&mut map)?,
98                        Field::Key_secret => value_secret = crate::serde::de::MapAccess::next_value(&mut map)?,
99                        Field::Key_service_account_token => value_service_account_token = crate::serde::de::MapAccess::next_value(&mut map)?,
100                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
101                    }
102                }
103
104                Ok(VolumeProjection {
105                    cluster_trust_bundle: value_cluster_trust_bundle,
106                    config_map: value_config_map,
107                    downward_api: value_downward_api,
108                    secret: value_secret,
109                    service_account_token: value_service_account_token,
110                })
111            }
112        }
113
114        deserializer.deserialize_struct(
115            "VolumeProjection",
116            &[
117                "clusterTrustBundle",
118                "configMap",
119                "downwardAPI",
120                "secret",
121                "serviceAccountToken",
122            ],
123            Visitor,
124        )
125    }
126}
127
128impl crate::serde::Serialize for VolumeProjection {
129    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
130        let mut state = serializer.serialize_struct(
131            "VolumeProjection",
132            self.cluster_trust_bundle.as_ref().map_or(0, |_| 1) +
133            self.config_map.as_ref().map_or(0, |_| 1) +
134            self.downward_api.as_ref().map_or(0, |_| 1) +
135            self.secret.as_ref().map_or(0, |_| 1) +
136            self.service_account_token.as_ref().map_or(0, |_| 1),
137        )?;
138        if let Some(value) = &self.cluster_trust_bundle {
139            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "clusterTrustBundle", value)?;
140        }
141        if let Some(value) = &self.config_map {
142            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "configMap", value)?;
143        }
144        if let Some(value) = &self.downward_api {
145            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "downwardAPI", value)?;
146        }
147        if let Some(value) = &self.secret {
148            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "secret", value)?;
149        }
150        if let Some(value) = &self.service_account_token {
151            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "serviceAccountToken", value)?;
152        }
153        crate::serde::ser::SerializeStruct::end(state)
154    }
155}
156
157#[cfg(feature = "schemars")]
158impl crate::schemars::JsonSchema for VolumeProjection {
159    fn schema_name() -> std::borrow::Cow<'static, str> {
160        "io.k8s.api.core.v1.VolumeProjection".into()
161    }
162
163    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
164        crate::schemars::json_schema!({
165            "description": "Projection that may be projected along with other supported volume types",
166            "type": "object",
167            "properties": {
168                "clusterTrustBundle": ({
169                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::ClusterTrustBundleProjection>();
170                    schema_obj.ensure_object().insert("description".into(), "ClusterTrustBundle allows a pod to access the `.spec.trustBundle` field of ClusterTrustBundle objects in an auto-updating file.\n\nAlpha, gated by the ClusterTrustBundleProjection feature gate.\n\nClusterTrustBundle objects can either be selected by name, or by the combination of signer name and a label selector.\n\nKubelet performs aggressive normalization of the PEM contents written into the pod filesystem.  Esoteric PEM features such as inter-block comments and block headers are stripped.  Certificates are deduplicated. The ordering of certificates within the file is arbitrary, and Kubelet may change the order over time.".into());
171                    schema_obj
172                }),
173                "configMap": ({
174                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::ConfigMapProjection>();
175                    schema_obj.ensure_object().insert("description".into(), "configMap information about the configMap data to project".into());
176                    schema_obj
177                }),
178                "downwardAPI": ({
179                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::DownwardAPIProjection>();
180                    schema_obj.ensure_object().insert("description".into(), "downwardAPI information about the downwardAPI data to project".into());
181                    schema_obj
182                }),
183                "secret": ({
184                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::SecretProjection>();
185                    schema_obj.ensure_object().insert("description".into(), "secret information about the secret data to project".into());
186                    schema_obj
187                }),
188                "serviceAccountToken": ({
189                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::ServiceAccountTokenProjection>();
190                    schema_obj.ensure_object().insert("description".into(), "serviceAccountToken is information about the serviceAccountToken data to project".into());
191                    schema_obj
192                }),
193            },
194        })
195    }
196}