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

1// Generated from definition io.k8s.api.core.v1.ISCSIVolumeSource
2
3/// Represents an ISCSI disk. ISCSI volumes can only be mounted as read/write once. ISCSI volumes support ownership management and SELinux relabeling.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct ISCSIVolumeSource {
6    /// chapAuthDiscovery defines whether support iSCSI Discovery CHAP authentication
7    pub chap_auth_discovery: Option<bool>,
8
9    /// chapAuthSession defines whether support iSCSI Session CHAP authentication
10    pub chap_auth_session: Option<bool>,
11
12    /// 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
13    pub fs_type: Option<String>,
14
15    /// 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.
16    pub initiator_name: Option<String>,
17
18    /// iqn is the target iSCSI Qualified Name.
19    pub iqn: String,
20
21    /// iscsiInterface is the interface Name that uses an iSCSI transport. Defaults to 'default' (tcp).
22    pub iscsi_interface: Option<String>,
23
24    /// lun represents iSCSI Target Lun number.
25    pub lun: i32,
26
27    /// 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).
28    pub portals: Option<Vec<String>>,
29
30    /// readOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false.
31    pub read_only: Option<bool>,
32
33    /// secretRef is the CHAP Secret for iSCSI target and initiator authentication
34    pub secret_ref: Option<crate::api::core::v1::LocalObjectReference>,
35
36    /// 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).
37    pub target_portal: 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 std::fmt::Formatter<'_>) -> std::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 std::fmt::Formatter<'_>) -> std::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<String> = None;
120                let mut value_initiator_name: Option<String> = None;
121                let mut value_iqn: Option<String> = None;
122                let mut value_iscsi_interface: Option<String> = None;
123                let mut value_lun: Option<i32> = None;
124                let mut value_portals: Option<Vec<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<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() -> String {
230        "io.k8s.api.core.v1.ISCSIVolumeSource".to_owned()
231    }
232
233    fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
234        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
235            metadata: Some(Box::new(crate::schemars::schema::Metadata {
236                description: Some("Represents an ISCSI disk. ISCSI volumes can only be mounted as read/write once. ISCSI volumes support ownership management and SELinux relabeling.".to_owned()),
237                ..Default::default()
238            })),
239            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
240            object: Some(Box::new(crate::schemars::schema::ObjectValidation {
241                properties: [
242                    (
243                        "chapAuthDiscovery".to_owned(),
244                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
245                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
246                                description: Some("chapAuthDiscovery defines whether support iSCSI Discovery CHAP authentication".to_owned()),
247                                ..Default::default()
248                            })),
249                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Boolean))),
250                            ..Default::default()
251                        }),
252                    ),
253                    (
254                        "chapAuthSession".to_owned(),
255                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
256                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
257                                description: Some("chapAuthSession defines whether support iSCSI Session CHAP authentication".to_owned()),
258                                ..Default::default()
259                            })),
260                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Boolean))),
261                            ..Default::default()
262                        }),
263                    ),
264                    (
265                        "fsType".to_owned(),
266                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
267                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
268                                description: Some("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".to_owned()),
269                                ..Default::default()
270                            })),
271                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
272                            ..Default::default()
273                        }),
274                    ),
275                    (
276                        "initiatorName".to_owned(),
277                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
278                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
279                                description: Some("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.".to_owned()),
280                                ..Default::default()
281                            })),
282                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
283                            ..Default::default()
284                        }),
285                    ),
286                    (
287                        "iqn".to_owned(),
288                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
289                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
290                                description: Some("iqn is the target iSCSI Qualified Name.".to_owned()),
291                                ..Default::default()
292                            })),
293                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
294                            ..Default::default()
295                        }),
296                    ),
297                    (
298                        "iscsiInterface".to_owned(),
299                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
300                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
301                                description: Some("iscsiInterface is the interface Name that uses an iSCSI transport. Defaults to 'default' (tcp).".to_owned()),
302                                ..Default::default()
303                            })),
304                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
305                            ..Default::default()
306                        }),
307                    ),
308                    (
309                        "lun".to_owned(),
310                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
311                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
312                                description: Some("lun represents iSCSI Target Lun number.".to_owned()),
313                                ..Default::default()
314                            })),
315                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Integer))),
316                            format: Some("int32".to_owned()),
317                            ..Default::default()
318                        }),
319                    ),
320                    (
321                        "portals".to_owned(),
322                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
323                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
324                                description: Some("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).".to_owned()),
325                                ..Default::default()
326                            })),
327                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Array))),
328                            array: Some(Box::new(crate::schemars::schema::ArrayValidation {
329                                items: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(
330                                    crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
331                                        instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
332                                        ..Default::default()
333                                    })
334                                ))),
335                                ..Default::default()
336                            })),
337                            ..Default::default()
338                        }),
339                    ),
340                    (
341                        "readOnly".to_owned(),
342                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
343                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
344                                description: Some("readOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false.".to_owned()),
345                                ..Default::default()
346                            })),
347                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Boolean))),
348                            ..Default::default()
349                        }),
350                    ),
351                    (
352                        "secretRef".to_owned(),
353                        {
354                            let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::LocalObjectReference>().into_object();
355                            schema_obj.metadata = Some(Box::new(crate::schemars::schema::Metadata {
356                                description: Some("secretRef is the CHAP Secret for iSCSI target and initiator authentication".to_owned()),
357                                ..Default::default()
358                            }));
359                            crate::schemars::schema::Schema::Object(schema_obj)
360                        },
361                    ),
362                    (
363                        "targetPortal".to_owned(),
364                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
365                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
366                                description: Some("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).".to_owned()),
367                                ..Default::default()
368                            })),
369                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
370                            ..Default::default()
371                        }),
372                    ),
373                ].into(),
374                required: [
375                    "iqn".to_owned(),
376                    "lun".to_owned(),
377                    "targetPortal".to_owned(),
378                ].into(),
379                ..Default::default()
380            })),
381            ..Default::default()
382        })
383    }
384}