k8s_openapi/v1_35/api/core/v1/
rbd_volume_source.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct RBDVolumeSource {
6 pub fs_type: Option<std::string::String>,
8
9 pub image: std::string::String,
11
12 pub keyring: Option<std::string::String>,
14
15 pub monitors: std::vec::Vec<std::string::String>,
17
18 pub pool: Option<std::string::String>,
20
21 pub read_only: Option<bool>,
23
24 pub secret_ref: Option<crate::api::core::v1::LocalObjectReference>,
26
27 pub user: Option<std::string::String>,
29}
30
31impl crate::DeepMerge for RBDVolumeSource {
32 fn merge_from(&mut self, other: Self) {
33 crate::DeepMerge::merge_from(&mut self.fs_type, other.fs_type);
34 crate::DeepMerge::merge_from(&mut self.image, other.image);
35 crate::DeepMerge::merge_from(&mut self.keyring, other.keyring);
36 crate::merge_strategies::list::atomic(&mut self.monitors, other.monitors);
37 crate::DeepMerge::merge_from(&mut self.pool, other.pool);
38 crate::DeepMerge::merge_from(&mut self.read_only, other.read_only);
39 crate::DeepMerge::merge_from(&mut self.secret_ref, other.secret_ref);
40 crate::DeepMerge::merge_from(&mut self.user, other.user);
41 }
42}
43
44impl<'de> crate::serde::Deserialize<'de> for RBDVolumeSource {
45 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
46 #[allow(non_camel_case_types)]
47 enum Field {
48 Key_fs_type,
49 Key_image,
50 Key_keyring,
51 Key_monitors,
52 Key_pool,
53 Key_read_only,
54 Key_secret_ref,
55 Key_user,
56 Other,
57 }
58
59 impl<'de> crate::serde::Deserialize<'de> for Field {
60 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
61 struct Visitor;
62
63 impl crate::serde::de::Visitor<'_> for Visitor {
64 type Value = Field;
65
66 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
67 f.write_str("field identifier")
68 }
69
70 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
71 Ok(match v {
72 "fsType" => Field::Key_fs_type,
73 "image" => Field::Key_image,
74 "keyring" => Field::Key_keyring,
75 "monitors" => Field::Key_monitors,
76 "pool" => Field::Key_pool,
77 "readOnly" => Field::Key_read_only,
78 "secretRef" => Field::Key_secret_ref,
79 "user" => Field::Key_user,
80 _ => Field::Other,
81 })
82 }
83 }
84
85 deserializer.deserialize_identifier(Visitor)
86 }
87 }
88
89 struct Visitor;
90
91 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
92 type Value = RBDVolumeSource;
93
94 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
95 f.write_str("RBDVolumeSource")
96 }
97
98 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
99 let mut value_fs_type: Option<std::string::String> = None;
100 let mut value_image: Option<std::string::String> = None;
101 let mut value_keyring: Option<std::string::String> = None;
102 let mut value_monitors: Option<std::vec::Vec<std::string::String>> = None;
103 let mut value_pool: Option<std::string::String> = None;
104 let mut value_read_only: Option<bool> = None;
105 let mut value_secret_ref: Option<crate::api::core::v1::LocalObjectReference> = None;
106 let mut value_user: Option<std::string::String> = None;
107
108 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
109 match key {
110 Field::Key_fs_type => value_fs_type = crate::serde::de::MapAccess::next_value(&mut map)?,
111 Field::Key_image => value_image = crate::serde::de::MapAccess::next_value(&mut map)?,
112 Field::Key_keyring => value_keyring = crate::serde::de::MapAccess::next_value(&mut map)?,
113 Field::Key_monitors => value_monitors = crate::serde::de::MapAccess::next_value(&mut map)?,
114 Field::Key_pool => value_pool = crate::serde::de::MapAccess::next_value(&mut map)?,
115 Field::Key_read_only => value_read_only = crate::serde::de::MapAccess::next_value(&mut map)?,
116 Field::Key_secret_ref => value_secret_ref = crate::serde::de::MapAccess::next_value(&mut map)?,
117 Field::Key_user => value_user = crate::serde::de::MapAccess::next_value(&mut map)?,
118 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
119 }
120 }
121
122 Ok(RBDVolumeSource {
123 fs_type: value_fs_type,
124 image: value_image.unwrap_or_default(),
125 keyring: value_keyring,
126 monitors: value_monitors.unwrap_or_default(),
127 pool: value_pool,
128 read_only: value_read_only,
129 secret_ref: value_secret_ref,
130 user: value_user,
131 })
132 }
133 }
134
135 deserializer.deserialize_struct(
136 "RBDVolumeSource",
137 &[
138 "fsType",
139 "image",
140 "keyring",
141 "monitors",
142 "pool",
143 "readOnly",
144 "secretRef",
145 "user",
146 ],
147 Visitor,
148 )
149 }
150}
151
152impl crate::serde::Serialize for RBDVolumeSource {
153 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
154 let mut state = serializer.serialize_struct(
155 "RBDVolumeSource",
156 2 +
157 self.fs_type.as_ref().map_or(0, |_| 1) +
158 self.keyring.as_ref().map_or(0, |_| 1) +
159 self.pool.as_ref().map_or(0, |_| 1) +
160 self.read_only.as_ref().map_or(0, |_| 1) +
161 self.secret_ref.as_ref().map_or(0, |_| 1) +
162 self.user.as_ref().map_or(0, |_| 1),
163 )?;
164 if let Some(value) = &self.fs_type {
165 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "fsType", value)?;
166 }
167 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "image", &self.image)?;
168 if let Some(value) = &self.keyring {
169 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "keyring", value)?;
170 }
171 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "monitors", &self.monitors)?;
172 if let Some(value) = &self.pool {
173 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "pool", value)?;
174 }
175 if let Some(value) = &self.read_only {
176 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readOnly", value)?;
177 }
178 if let Some(value) = &self.secret_ref {
179 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "secretRef", value)?;
180 }
181 if let Some(value) = &self.user {
182 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "user", value)?;
183 }
184 crate::serde::ser::SerializeStruct::end(state)
185 }
186}
187
188#[cfg(feature = "schemars")]
189impl crate::schemars::JsonSchema for RBDVolumeSource {
190 fn schema_name() -> std::borrow::Cow<'static, str> {
191 "io.k8s.api.core.v1.RBDVolumeSource".into()
192 }
193
194 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
195 crate::schemars::json_schema!({
196 "description": "Represents a Rados Block Device mount that lasts the lifetime of a pod. RBD volumes support ownership management and SELinux relabeling.",
197 "type": "object",
198 "properties": {
199 "fsType": {
200 "description": "fsType is the filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#rbd",
201 "type": "string",
202 },
203 "image": {
204 "description": "image is the rados image name. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it",
205 "type": "string",
206 },
207 "keyring": {
208 "description": "keyring is the path to key ring for RBDUser. Default is /etc/ceph/keyring. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it",
209 "type": "string",
210 },
211 "monitors": {
212 "description": "monitors is a collection of Ceph monitors. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it",
213 "type": "array",
214 "items": {
215 "type": "string",
216 },
217 },
218 "pool": {
219 "description": "pool is the rados pool name. Default is rbd. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it",
220 "type": "string",
221 },
222 "readOnly": {
223 "description": "readOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it",
224 "type": "boolean",
225 },
226 "secretRef": ({
227 let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::LocalObjectReference>();
228 schema_obj.ensure_object().insert("description".into(), "secretRef is name of the authentication secret for RBDUser. If provided overrides keyring. Default is nil. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it".into());
229 schema_obj
230 }),
231 "user": {
232 "description": "user is the rados user name. Default is admin. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it",
233 "type": "string",
234 },
235 },
236 "required": [
237 "image",
238 "monitors",
239 ],
240 })
241 }
242}