k8s_openapi/v1_35/api/core/v1/
csi_volume_source.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct CSIVolumeSource {
6 pub driver: std::string::String,
8
9 pub fs_type: Option<std::string::String>,
11
12 pub node_publish_secret_ref: Option<crate::api::core::v1::LocalObjectReference>,
14
15 pub read_only: Option<bool>,
17
18 pub volume_attributes: Option<std::collections::BTreeMap<std::string::String, std::string::String>>,
20}
21
22impl crate::DeepMerge for CSIVolumeSource {
23 fn merge_from(&mut self, other: Self) {
24 crate::DeepMerge::merge_from(&mut self.driver, other.driver);
25 crate::DeepMerge::merge_from(&mut self.fs_type, other.fs_type);
26 crate::DeepMerge::merge_from(&mut self.node_publish_secret_ref, other.node_publish_secret_ref);
27 crate::DeepMerge::merge_from(&mut self.read_only, other.read_only);
28 crate::merge_strategies::map::granular(&mut self.volume_attributes, other.volume_attributes, |current_item, other_item| {
29 crate::DeepMerge::merge_from(current_item, other_item);
30 });
31 }
32}
33
34impl<'de> crate::serde::Deserialize<'de> for CSIVolumeSource {
35 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
36 #[allow(non_camel_case_types)]
37 enum Field {
38 Key_driver,
39 Key_fs_type,
40 Key_node_publish_secret_ref,
41 Key_read_only,
42 Key_volume_attributes,
43 Other,
44 }
45
46 impl<'de> crate::serde::Deserialize<'de> for Field {
47 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
48 struct Visitor;
49
50 impl crate::serde::de::Visitor<'_> for Visitor {
51 type Value = Field;
52
53 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
54 f.write_str("field identifier")
55 }
56
57 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
58 Ok(match v {
59 "driver" => Field::Key_driver,
60 "fsType" => Field::Key_fs_type,
61 "nodePublishSecretRef" => Field::Key_node_publish_secret_ref,
62 "readOnly" => Field::Key_read_only,
63 "volumeAttributes" => Field::Key_volume_attributes,
64 _ => Field::Other,
65 })
66 }
67 }
68
69 deserializer.deserialize_identifier(Visitor)
70 }
71 }
72
73 struct Visitor;
74
75 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
76 type Value = CSIVolumeSource;
77
78 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
79 f.write_str("CSIVolumeSource")
80 }
81
82 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
83 let mut value_driver: Option<std::string::String> = None;
84 let mut value_fs_type: Option<std::string::String> = None;
85 let mut value_node_publish_secret_ref: Option<crate::api::core::v1::LocalObjectReference> = None;
86 let mut value_read_only: Option<bool> = None;
87 let mut value_volume_attributes: Option<std::collections::BTreeMap<std::string::String, std::string::String>> = None;
88
89 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
90 match key {
91 Field::Key_driver => value_driver = crate::serde::de::MapAccess::next_value(&mut map)?,
92 Field::Key_fs_type => value_fs_type = crate::serde::de::MapAccess::next_value(&mut map)?,
93 Field::Key_node_publish_secret_ref => value_node_publish_secret_ref = crate::serde::de::MapAccess::next_value(&mut map)?,
94 Field::Key_read_only => value_read_only = crate::serde::de::MapAccess::next_value(&mut map)?,
95 Field::Key_volume_attributes => value_volume_attributes = crate::serde::de::MapAccess::next_value(&mut map)?,
96 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
97 }
98 }
99
100 Ok(CSIVolumeSource {
101 driver: value_driver.unwrap_or_default(),
102 fs_type: value_fs_type,
103 node_publish_secret_ref: value_node_publish_secret_ref,
104 read_only: value_read_only,
105 volume_attributes: value_volume_attributes,
106 })
107 }
108 }
109
110 deserializer.deserialize_struct(
111 "CSIVolumeSource",
112 &[
113 "driver",
114 "fsType",
115 "nodePublishSecretRef",
116 "readOnly",
117 "volumeAttributes",
118 ],
119 Visitor,
120 )
121 }
122}
123
124impl crate::serde::Serialize for CSIVolumeSource {
125 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
126 let mut state = serializer.serialize_struct(
127 "CSIVolumeSource",
128 1 +
129 self.fs_type.as_ref().map_or(0, |_| 1) +
130 self.node_publish_secret_ref.as_ref().map_or(0, |_| 1) +
131 self.read_only.as_ref().map_or(0, |_| 1) +
132 self.volume_attributes.as_ref().map_or(0, |_| 1),
133 )?;
134 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "driver", &self.driver)?;
135 if let Some(value) = &self.fs_type {
136 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "fsType", value)?;
137 }
138 if let Some(value) = &self.node_publish_secret_ref {
139 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "nodePublishSecretRef", value)?;
140 }
141 if let Some(value) = &self.read_only {
142 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readOnly", value)?;
143 }
144 if let Some(value) = &self.volume_attributes {
145 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "volumeAttributes", value)?;
146 }
147 crate::serde::ser::SerializeStruct::end(state)
148 }
149}
150
151#[cfg(feature = "schemars")]
152impl crate::schemars::JsonSchema for CSIVolumeSource {
153 fn schema_name() -> std::borrow::Cow<'static, str> {
154 "io.k8s.api.core.v1.CSIVolumeSource".into()
155 }
156
157 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
158 crate::schemars::json_schema!({
159 "description": "Represents a source location of a volume to mount, managed by an external CSI driver",
160 "type": "object",
161 "properties": {
162 "driver": {
163 "description": "driver is the name of the CSI driver that handles this volume. Consult with your admin for the correct name as registered in the cluster.",
164 "type": "string",
165 },
166 "fsType": {
167 "description": "fsType to mount. Ex. \"ext4\", \"xfs\", \"ntfs\". If not provided, the empty value is passed to the associated CSI driver which will determine the default filesystem to apply.",
168 "type": "string",
169 },
170 "nodePublishSecretRef": ({
171 let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::LocalObjectReference>();
172 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 secret references are passed.".into());
173 schema_obj
174 }),
175 "readOnly": {
176 "description": "readOnly specifies a read-only configuration for the volume. Defaults to false (read/write).",
177 "type": "boolean",
178 },
179 "volumeAttributes": {
180 "description": "volumeAttributes stores driver-specific properties that are passed to the CSI driver. Consult your driver's documentation for supported values.",
181 "type": "object",
182 "additionalProperties": {
183 "type": "string",
184 },
185 },
186 },
187 "required": [
188 "driver",
189 ],
190 })
191 }
192}