k8s_openapi/v1_35/api/core/v1/
csi_persistent_volume_source.rs

1// Generated from definition io.k8s.api.core.v1.CSIPersistentVolumeSource
2
3/// Represents storage that is managed by an external CSI volume driver
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct CSIPersistentVolumeSource {
6    /// controllerExpandSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI ControllerExpandVolume call. This field is optional, and may be empty if no secret is required. If the secret object contains more than one secret, all secrets are passed.
7    pub controller_expand_secret_ref: Option<crate::api::core::v1::SecretReference>,
8
9    /// controllerPublishSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI ControllerPublishVolume and ControllerUnpublishVolume calls. This field is optional, and may be empty if no secret is required. If the secret object contains more than one secret, all secrets are passed.
10    pub controller_publish_secret_ref: Option<crate::api::core::v1::SecretReference>,
11
12    /// driver is the name of the driver to use for this volume. Required.
13    pub driver: std::string::String,
14
15    /// fsType to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs".
16    pub fs_type: Option<std::string::String>,
17
18    /// nodeExpandSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI NodeExpandVolume call. This field is optional, may be omitted if no secret is required. If the secret object contains more than one secret, all secrets are passed.
19    pub node_expand_secret_ref: Option<crate::api::core::v1::SecretReference>,
20
21    /// nodePublishSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI NodePublishVolume and NodeUnpublishVolume calls. This field is optional, and may be empty if no secret is required. If the secret object contains more than one secret, all secrets are passed.
22    pub node_publish_secret_ref: Option<crate::api::core::v1::SecretReference>,
23
24    /// nodeStageSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI NodeStageVolume and NodeStageVolume and NodeUnstageVolume calls. This field is optional, and may be empty if no secret is required. If the secret object contains more than one secret, all secrets are passed.
25    pub node_stage_secret_ref: Option<crate::api::core::v1::SecretReference>,
26
27    /// readOnly value to pass to ControllerPublishVolumeRequest. Defaults to false (read/write).
28    pub read_only: Option<bool>,
29
30    /// volumeAttributes of the volume to publish.
31    pub volume_attributes: Option<std::collections::BTreeMap<std::string::String, std::string::String>>,
32
33    /// volumeHandle is the unique volume name returned by the CSI volume plugin’s CreateVolume to refer to the volume on all subsequent calls. Required.
34    pub volume_handle: std::string::String,
35}
36
37impl crate::DeepMerge for CSIPersistentVolumeSource {
38    fn merge_from(&mut self, other: Self) {
39        crate::DeepMerge::merge_from(&mut self.controller_expand_secret_ref, other.controller_expand_secret_ref);
40        crate::DeepMerge::merge_from(&mut self.controller_publish_secret_ref, other.controller_publish_secret_ref);
41        crate::DeepMerge::merge_from(&mut self.driver, other.driver);
42        crate::DeepMerge::merge_from(&mut self.fs_type, other.fs_type);
43        crate::DeepMerge::merge_from(&mut self.node_expand_secret_ref, other.node_expand_secret_ref);
44        crate::DeepMerge::merge_from(&mut self.node_publish_secret_ref, other.node_publish_secret_ref);
45        crate::DeepMerge::merge_from(&mut self.node_stage_secret_ref, other.node_stage_secret_ref);
46        crate::DeepMerge::merge_from(&mut self.read_only, other.read_only);
47        crate::merge_strategies::map::granular(&mut self.volume_attributes, other.volume_attributes, |current_item, other_item| {
48            crate::DeepMerge::merge_from(current_item, other_item);
49        });
50        crate::DeepMerge::merge_from(&mut self.volume_handle, other.volume_handle);
51    }
52}
53
54impl<'de> crate::serde::Deserialize<'de> for CSIPersistentVolumeSource {
55    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
56        #[allow(non_camel_case_types)]
57        enum Field {
58            Key_controller_expand_secret_ref,
59            Key_controller_publish_secret_ref,
60            Key_driver,
61            Key_fs_type,
62            Key_node_expand_secret_ref,
63            Key_node_publish_secret_ref,
64            Key_node_stage_secret_ref,
65            Key_read_only,
66            Key_volume_attributes,
67            Key_volume_handle,
68            Other,
69        }
70
71        impl<'de> crate::serde::Deserialize<'de> for Field {
72            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
73                struct Visitor;
74
75                impl crate::serde::de::Visitor<'_> for Visitor {
76                    type Value = Field;
77
78                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
79                        f.write_str("field identifier")
80                    }
81
82                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
83                        Ok(match v {
84                            "controllerExpandSecretRef" => Field::Key_controller_expand_secret_ref,
85                            "controllerPublishSecretRef" => Field::Key_controller_publish_secret_ref,
86                            "driver" => Field::Key_driver,
87                            "fsType" => Field::Key_fs_type,
88                            "nodeExpandSecretRef" => Field::Key_node_expand_secret_ref,
89                            "nodePublishSecretRef" => Field::Key_node_publish_secret_ref,
90                            "nodeStageSecretRef" => Field::Key_node_stage_secret_ref,
91                            "readOnly" => Field::Key_read_only,
92                            "volumeAttributes" => Field::Key_volume_attributes,
93                            "volumeHandle" => Field::Key_volume_handle,
94                            _ => Field::Other,
95                        })
96                    }
97                }
98
99                deserializer.deserialize_identifier(Visitor)
100            }
101        }
102
103        struct Visitor;
104
105        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
106            type Value = CSIPersistentVolumeSource;
107
108            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
109                f.write_str("CSIPersistentVolumeSource")
110            }
111
112            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
113                let mut value_controller_expand_secret_ref: Option<crate::api::core::v1::SecretReference> = None;
114                let mut value_controller_publish_secret_ref: Option<crate::api::core::v1::SecretReference> = None;
115                let mut value_driver: Option<std::string::String> = None;
116                let mut value_fs_type: Option<std::string::String> = None;
117                let mut value_node_expand_secret_ref: Option<crate::api::core::v1::SecretReference> = None;
118                let mut value_node_publish_secret_ref: Option<crate::api::core::v1::SecretReference> = None;
119                let mut value_node_stage_secret_ref: Option<crate::api::core::v1::SecretReference> = None;
120                let mut value_read_only: Option<bool> = None;
121                let mut value_volume_attributes: Option<std::collections::BTreeMap<std::string::String, std::string::String>> = None;
122                let mut value_volume_handle: Option<std::string::String> = None;
123
124                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
125                    match key {
126                        Field::Key_controller_expand_secret_ref => value_controller_expand_secret_ref = crate::serde::de::MapAccess::next_value(&mut map)?,
127                        Field::Key_controller_publish_secret_ref => value_controller_publish_secret_ref = crate::serde::de::MapAccess::next_value(&mut map)?,
128                        Field::Key_driver => value_driver = crate::serde::de::MapAccess::next_value(&mut map)?,
129                        Field::Key_fs_type => value_fs_type = crate::serde::de::MapAccess::next_value(&mut map)?,
130                        Field::Key_node_expand_secret_ref => value_node_expand_secret_ref = crate::serde::de::MapAccess::next_value(&mut map)?,
131                        Field::Key_node_publish_secret_ref => value_node_publish_secret_ref = crate::serde::de::MapAccess::next_value(&mut map)?,
132                        Field::Key_node_stage_secret_ref => value_node_stage_secret_ref = crate::serde::de::MapAccess::next_value(&mut map)?,
133                        Field::Key_read_only => value_read_only = crate::serde::de::MapAccess::next_value(&mut map)?,
134                        Field::Key_volume_attributes => value_volume_attributes = crate::serde::de::MapAccess::next_value(&mut map)?,
135                        Field::Key_volume_handle => value_volume_handle = crate::serde::de::MapAccess::next_value(&mut map)?,
136                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
137                    }
138                }
139
140                Ok(CSIPersistentVolumeSource {
141                    controller_expand_secret_ref: value_controller_expand_secret_ref,
142                    controller_publish_secret_ref: value_controller_publish_secret_ref,
143                    driver: value_driver.unwrap_or_default(),
144                    fs_type: value_fs_type,
145                    node_expand_secret_ref: value_node_expand_secret_ref,
146                    node_publish_secret_ref: value_node_publish_secret_ref,
147                    node_stage_secret_ref: value_node_stage_secret_ref,
148                    read_only: value_read_only,
149                    volume_attributes: value_volume_attributes,
150                    volume_handle: value_volume_handle.unwrap_or_default(),
151                })
152            }
153        }
154
155        deserializer.deserialize_struct(
156            "CSIPersistentVolumeSource",
157            &[
158                "controllerExpandSecretRef",
159                "controllerPublishSecretRef",
160                "driver",
161                "fsType",
162                "nodeExpandSecretRef",
163                "nodePublishSecretRef",
164                "nodeStageSecretRef",
165                "readOnly",
166                "volumeAttributes",
167                "volumeHandle",
168            ],
169            Visitor,
170        )
171    }
172}
173
174impl crate::serde::Serialize for CSIPersistentVolumeSource {
175    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
176        let mut state = serializer.serialize_struct(
177            "CSIPersistentVolumeSource",
178            2 +
179            self.controller_expand_secret_ref.as_ref().map_or(0, |_| 1) +
180            self.controller_publish_secret_ref.as_ref().map_or(0, |_| 1) +
181            self.fs_type.as_ref().map_or(0, |_| 1) +
182            self.node_expand_secret_ref.as_ref().map_or(0, |_| 1) +
183            self.node_publish_secret_ref.as_ref().map_or(0, |_| 1) +
184            self.node_stage_secret_ref.as_ref().map_or(0, |_| 1) +
185            self.read_only.as_ref().map_or(0, |_| 1) +
186            self.volume_attributes.as_ref().map_or(0, |_| 1),
187        )?;
188        if let Some(value) = &self.controller_expand_secret_ref {
189            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "controllerExpandSecretRef", value)?;
190        }
191        if let Some(value) = &self.controller_publish_secret_ref {
192            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "controllerPublishSecretRef", value)?;
193        }
194        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "driver", &self.driver)?;
195        if let Some(value) = &self.fs_type {
196            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "fsType", value)?;
197        }
198        if let Some(value) = &self.node_expand_secret_ref {
199            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "nodeExpandSecretRef", value)?;
200        }
201        if let Some(value) = &self.node_publish_secret_ref {
202            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "nodePublishSecretRef", value)?;
203        }
204        if let Some(value) = &self.node_stage_secret_ref {
205            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "nodeStageSecretRef", value)?;
206        }
207        if let Some(value) = &self.read_only {
208            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readOnly", value)?;
209        }
210        if let Some(value) = &self.volume_attributes {
211            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "volumeAttributes", value)?;
212        }
213        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "volumeHandle", &self.volume_handle)?;
214        crate::serde::ser::SerializeStruct::end(state)
215    }
216}
217
218#[cfg(feature = "schemars")]
219impl crate::schemars::JsonSchema for CSIPersistentVolumeSource {
220    fn schema_name() -> std::borrow::Cow<'static, str> {
221        "io.k8s.api.core.v1.CSIPersistentVolumeSource".into()
222    }
223
224    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
225        crate::schemars::json_schema!({
226            "description": "Represents storage that is managed by an external CSI volume driver",
227            "type": "object",
228            "properties": {
229                "controllerExpandSecretRef": ({
230                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::SecretReference>();
231                    schema_obj.ensure_object().insert("description".into(), "controllerExpandSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI ControllerExpandVolume call. This field is optional, and may be empty if no secret is required. If the secret object contains more than one secret, all secrets are passed.".into());
232                    schema_obj
233                }),
234                "controllerPublishSecretRef": ({
235                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::SecretReference>();
236                    schema_obj.ensure_object().insert("description".into(), "controllerPublishSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI ControllerPublishVolume and ControllerUnpublishVolume calls. This field is optional, and may be empty if no secret is required. If the secret object contains more than one secret, all secrets are passed.".into());
237                    schema_obj
238                }),
239                "driver": {
240                    "description": "driver is the name of the driver to use for this volume. Required.",
241                    "type": "string",
242                },
243                "fsType": {
244                    "description": "fsType to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\".",
245                    "type": "string",
246                },
247                "nodeExpandSecretRef": ({
248                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::SecretReference>();
249                    schema_obj.ensure_object().insert("description".into(), "nodeExpandSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI NodeExpandVolume call. This field is optional, may be omitted if no secret is required. If the secret object contains more than one secret, all secrets are passed.".into());
250                    schema_obj
251                }),
252                "nodePublishSecretRef": ({
253                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::SecretReference>();
254                    schema_obj.ensure_object().insert("description".into(), "nodePublishSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI NodePublishVolume and NodeUnpublishVolume calls. This field is optional, and may be empty if no secret is required. If the secret object contains more than one secret, all secrets are passed.".into());
255                    schema_obj
256                }),
257                "nodeStageSecretRef": ({
258                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::SecretReference>();
259                    schema_obj.ensure_object().insert("description".into(), "nodeStageSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI NodeStageVolume and NodeStageVolume and NodeUnstageVolume calls. This field is optional, and may be empty if no secret is required. If the secret object contains more than one secret, all secrets are passed.".into());
260                    schema_obj
261                }),
262                "readOnly": {
263                    "description": "readOnly value to pass to ControllerPublishVolumeRequest. Defaults to false (read/write).",
264                    "type": "boolean",
265                },
266                "volumeAttributes": {
267                    "description": "volumeAttributes of the volume to publish.",
268                    "type": "object",
269                    "additionalProperties": {
270                        "type": "string",
271                    },
272                },
273                "volumeHandle": {
274                    "description": "volumeHandle is the unique volume name returned by the CSI volume plugin’s CreateVolume to refer to the volume on all subsequent calls. Required.",
275                    "type": "string",
276                },
277            },
278            "required": [
279                "driver",
280                "volumeHandle",
281            ],
282        })
283    }
284}