1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct ISCSIVolumeSource {
6 pub chap_auth_discovery: Option<bool>,
8
9 pub chap_auth_session: Option<bool>,
11
12 pub fs_type: Option<std::string::String>,
14
15 pub initiator_name: Option<std::string::String>,
17
18 pub iqn: std::string::String,
20
21 pub iscsi_interface: Option<std::string::String>,
23
24 pub lun: i32,
26
27 pub portals: Option<std::vec::Vec<std::string::String>>,
29
30 pub read_only: Option<bool>,
32
33 pub secret_ref: Option<crate::api::core::v1::LocalObjectReference>,
35
36 pub target_portal: std::string::String,
38}
39
40impl crate::DeepMerge for ISCSIVolumeSource {
41 fn merge_from(&mut self, other: Self) {
42 crate::DeepMerge::merge_from(&mut self.chap_auth_discovery, other.chap_auth_discovery);
43 crate::DeepMerge::merge_from(&mut self.chap_auth_session, other.chap_auth_session);
44 crate::DeepMerge::merge_from(&mut self.fs_type, other.fs_type);
45 crate::DeepMerge::merge_from(&mut self.initiator_name, other.initiator_name);
46 crate::DeepMerge::merge_from(&mut self.iqn, other.iqn);
47 crate::DeepMerge::merge_from(&mut self.iscsi_interface, other.iscsi_interface);
48 crate::DeepMerge::merge_from(&mut self.lun, other.lun);
49 crate::merge_strategies::list::atomic(&mut self.portals, other.portals);
50 crate::DeepMerge::merge_from(&mut self.read_only, other.read_only);
51 crate::DeepMerge::merge_from(&mut self.secret_ref, other.secret_ref);
52 crate::DeepMerge::merge_from(&mut self.target_portal, other.target_portal);
53 }
54}
55
56impl<'de> crate::serde::Deserialize<'de> for ISCSIVolumeSource {
57 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
58 #[allow(non_camel_case_types)]
59 enum Field {
60 Key_chap_auth_discovery,
61 Key_chap_auth_session,
62 Key_fs_type,
63 Key_initiator_name,
64 Key_iqn,
65 Key_iscsi_interface,
66 Key_lun,
67 Key_portals,
68 Key_read_only,
69 Key_secret_ref,
70 Key_target_portal,
71 Other,
72 }
73
74 impl<'de> crate::serde::Deserialize<'de> for Field {
75 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
76 struct Visitor;
77
78 impl crate::serde::de::Visitor<'_> for Visitor {
79 type Value = Field;
80
81 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
82 f.write_str("field identifier")
83 }
84
85 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
86 Ok(match v {
87 "chapAuthDiscovery" => Field::Key_chap_auth_discovery,
88 "chapAuthSession" => Field::Key_chap_auth_session,
89 "fsType" => Field::Key_fs_type,
90 "initiatorName" => Field::Key_initiator_name,
91 "iqn" => Field::Key_iqn,
92 "iscsiInterface" => Field::Key_iscsi_interface,
93 "lun" => Field::Key_lun,
94 "portals" => Field::Key_portals,
95 "readOnly" => Field::Key_read_only,
96 "secretRef" => Field::Key_secret_ref,
97 "targetPortal" => Field::Key_target_portal,
98 _ => Field::Other,
99 })
100 }
101 }
102
103 deserializer.deserialize_identifier(Visitor)
104 }
105 }
106
107 struct Visitor;
108
109 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
110 type Value = ISCSIVolumeSource;
111
112 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
113 f.write_str("ISCSIVolumeSource")
114 }
115
116 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
117 let mut value_chap_auth_discovery: Option<bool> = None;
118 let mut value_chap_auth_session: Option<bool> = None;
119 let mut value_fs_type: Option<std::string::String> = None;
120 let mut value_initiator_name: Option<std::string::String> = None;
121 let mut value_iqn: Option<std::string::String> = None;
122 let mut value_iscsi_interface: Option<std::string::String> = None;
123 let mut value_lun: Option<i32> = None;
124 let mut value_portals: Option<std::vec::Vec<std::string::String>> = None;
125 let mut value_read_only: Option<bool> = None;
126 let mut value_secret_ref: Option<crate::api::core::v1::LocalObjectReference> = None;
127 let mut value_target_portal: Option<std::string::String> = None;
128
129 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
130 match key {
131 Field::Key_chap_auth_discovery => value_chap_auth_discovery = crate::serde::de::MapAccess::next_value(&mut map)?,
132 Field::Key_chap_auth_session => value_chap_auth_session = crate::serde::de::MapAccess::next_value(&mut map)?,
133 Field::Key_fs_type => value_fs_type = crate::serde::de::MapAccess::next_value(&mut map)?,
134 Field::Key_initiator_name => value_initiator_name = crate::serde::de::MapAccess::next_value(&mut map)?,
135 Field::Key_iqn => value_iqn = crate::serde::de::MapAccess::next_value(&mut map)?,
136 Field::Key_iscsi_interface => value_iscsi_interface = crate::serde::de::MapAccess::next_value(&mut map)?,
137 Field::Key_lun => value_lun = crate::serde::de::MapAccess::next_value(&mut map)?,
138 Field::Key_portals => value_portals = crate::serde::de::MapAccess::next_value(&mut map)?,
139 Field::Key_read_only => value_read_only = crate::serde::de::MapAccess::next_value(&mut map)?,
140 Field::Key_secret_ref => value_secret_ref = crate::serde::de::MapAccess::next_value(&mut map)?,
141 Field::Key_target_portal => value_target_portal = crate::serde::de::MapAccess::next_value(&mut map)?,
142 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
143 }
144 }
145
146 Ok(ISCSIVolumeSource {
147 chap_auth_discovery: value_chap_auth_discovery,
148 chap_auth_session: value_chap_auth_session,
149 fs_type: value_fs_type,
150 initiator_name: value_initiator_name,
151 iqn: value_iqn.unwrap_or_default(),
152 iscsi_interface: value_iscsi_interface,
153 lun: value_lun.unwrap_or_default(),
154 portals: value_portals,
155 read_only: value_read_only,
156 secret_ref: value_secret_ref,
157 target_portal: value_target_portal.unwrap_or_default(),
158 })
159 }
160 }
161
162 deserializer.deserialize_struct(
163 "ISCSIVolumeSource",
164 &[
165 "chapAuthDiscovery",
166 "chapAuthSession",
167 "fsType",
168 "initiatorName",
169 "iqn",
170 "iscsiInterface",
171 "lun",
172 "portals",
173 "readOnly",
174 "secretRef",
175 "targetPortal",
176 ],
177 Visitor,
178 )
179 }
180}
181
182impl crate::serde::Serialize for ISCSIVolumeSource {
183 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
184 let mut state = serializer.serialize_struct(
185 "ISCSIVolumeSource",
186 3 +
187 self.chap_auth_discovery.as_ref().map_or(0, |_| 1) +
188 self.chap_auth_session.as_ref().map_or(0, |_| 1) +
189 self.fs_type.as_ref().map_or(0, |_| 1) +
190 self.initiator_name.as_ref().map_or(0, |_| 1) +
191 self.iscsi_interface.as_ref().map_or(0, |_| 1) +
192 self.portals.as_ref().map_or(0, |_| 1) +
193 self.read_only.as_ref().map_or(0, |_| 1) +
194 self.secret_ref.as_ref().map_or(0, |_| 1),
195 )?;
196 if let Some(value) = &self.chap_auth_discovery {
197 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "chapAuthDiscovery", value)?;
198 }
199 if let Some(value) = &self.chap_auth_session {
200 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "chapAuthSession", value)?;
201 }
202 if let Some(value) = &self.fs_type {
203 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "fsType", value)?;
204 }
205 if let Some(value) = &self.initiator_name {
206 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "initiatorName", value)?;
207 }
208 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "iqn", &self.iqn)?;
209 if let Some(value) = &self.iscsi_interface {
210 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "iscsiInterface", value)?;
211 }
212 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "lun", &self.lun)?;
213 if let Some(value) = &self.portals {
214 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "portals", value)?;
215 }
216 if let Some(value) = &self.read_only {
217 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readOnly", value)?;
218 }
219 if let Some(value) = &self.secret_ref {
220 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "secretRef", value)?;
221 }
222 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "targetPortal", &self.target_portal)?;
223 crate::serde::ser::SerializeStruct::end(state)
224 }
225}
226
227#[cfg(feature = "schemars")]
228impl crate::schemars::JsonSchema for ISCSIVolumeSource {
229 fn schema_name() -> std::borrow::Cow<'static, str> {
230 "io.k8s.api.core.v1.ISCSIVolumeSource".into()
231 }
232
233 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
234 crate::schemars::json_schema!({
235 "description": "Represents an ISCSI disk. ISCSI volumes can only be mounted as read/write once. ISCSI volumes support ownership management and SELinux relabeling.",
236 "type": "object",
237 "properties": {
238 "chapAuthDiscovery": {
239 "description": "chapAuthDiscovery defines whether support iSCSI Discovery CHAP authentication",
240 "type": "boolean",
241 },
242 "chapAuthSession": {
243 "description": "chapAuthSession defines whether support iSCSI Session CHAP authentication",
244 "type": "boolean",
245 },
246 "fsType": {
247 "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#iscsi",
248 "type": "string",
249 },
250 "initiatorName": {
251 "description": "initiatorName is the custom iSCSI Initiator Name. If initiatorName is specified with iscsiInterface simultaneously, new iSCSI interface <target portal>:<volume name> will be created for the connection.",
252 "type": "string",
253 },
254 "iqn": {
255 "description": "iqn is the target iSCSI Qualified Name.",
256 "type": "string",
257 },
258 "iscsiInterface": {
259 "description": "iscsiInterface is the interface Name that uses an iSCSI transport. Defaults to 'default' (tcp).",
260 "type": "string",
261 },
262 "lun": {
263 "description": "lun represents iSCSI Target Lun number.",
264 "type": "integer",
265 "format": "int32",
266 },
267 "portals": {
268 "description": "portals is the iSCSI Target Portal List. The portal is either an IP or ip_addr:port if the port is other than default (typically TCP ports 860 and 3260).",
269 "type": "array",
270 "items": {
271 "type": "string",
272 },
273 },
274 "readOnly": {
275 "description": "readOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false.",
276 "type": "boolean",
277 },
278 "secretRef": ({
279 let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::LocalObjectReference>();
280 schema_obj.ensure_object().insert("description".into(), "secretRef is the CHAP Secret for iSCSI target and initiator authentication".into());
281 schema_obj
282 }),
283 "targetPortal": {
284 "description": "targetPortal is iSCSI Target Portal. The Portal is either an IP or ip_addr:port if the port is other than default (typically TCP ports 860 and 3260).",
285 "type": "string",
286 },
287 },
288 "required": [
289 "iqn",
290 "lun",
291 "targetPortal",
292 ],
293 })
294 }
295}