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

1// Generated from definition io.k8s.api.core.v1.FCVolumeSource
2
3/// Represents a Fibre Channel volume. Fibre Channel volumes can only be mounted as read/write once. Fibre Channel volumes support ownership management and SELinux relabeling.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct FCVolumeSource {
6    /// fsType is the filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified.
7    pub fs_type: Option<std::string::String>,
8
9    /// lun is Optional: FC target lun number
10    pub lun: Option<i32>,
11
12    /// readOnly is Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.
13    pub read_only: Option<bool>,
14
15    /// targetWWNs is Optional: FC target worldwide names (WWNs)
16    pub target_wwns: Option<std::vec::Vec<std::string::String>>,
17
18    /// wwids Optional: FC volume world wide identifiers (wwids) Either wwids or combination of targetWWNs and lun must be set, but not both simultaneously.
19    pub wwids: Option<std::vec::Vec<std::string::String>>,
20}
21
22impl crate::DeepMerge for FCVolumeSource {
23    fn merge_from(&mut self, other: Self) {
24        crate::DeepMerge::merge_from(&mut self.fs_type, other.fs_type);
25        crate::DeepMerge::merge_from(&mut self.lun, other.lun);
26        crate::DeepMerge::merge_from(&mut self.read_only, other.read_only);
27        crate::merge_strategies::list::atomic(&mut self.target_wwns, other.target_wwns);
28        crate::merge_strategies::list::atomic(&mut self.wwids, other.wwids);
29    }
30}
31
32impl<'de> crate::serde::Deserialize<'de> for FCVolumeSource {
33    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
34        #[allow(non_camel_case_types)]
35        enum Field {
36            Key_fs_type,
37            Key_lun,
38            Key_read_only,
39            Key_target_wwns,
40            Key_wwids,
41            Other,
42        }
43
44        impl<'de> crate::serde::Deserialize<'de> for Field {
45            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
46                struct Visitor;
47
48                impl crate::serde::de::Visitor<'_> for Visitor {
49                    type Value = Field;
50
51                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
52                        f.write_str("field identifier")
53                    }
54
55                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
56                        Ok(match v {
57                            "fsType" => Field::Key_fs_type,
58                            "lun" => Field::Key_lun,
59                            "readOnly" => Field::Key_read_only,
60                            "targetWWNs" => Field::Key_target_wwns,
61                            "wwids" => Field::Key_wwids,
62                            _ => Field::Other,
63                        })
64                    }
65                }
66
67                deserializer.deserialize_identifier(Visitor)
68            }
69        }
70
71        struct Visitor;
72
73        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
74            type Value = FCVolumeSource;
75
76            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
77                f.write_str("FCVolumeSource")
78            }
79
80            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
81                let mut value_fs_type: Option<std::string::String> = None;
82                let mut value_lun: Option<i32> = None;
83                let mut value_read_only: Option<bool> = None;
84                let mut value_target_wwns: Option<std::vec::Vec<std::string::String>> = None;
85                let mut value_wwids: Option<std::vec::Vec<std::string::String>> = None;
86
87                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
88                    match key {
89                        Field::Key_fs_type => value_fs_type = crate::serde::de::MapAccess::next_value(&mut map)?,
90                        Field::Key_lun => value_lun = crate::serde::de::MapAccess::next_value(&mut map)?,
91                        Field::Key_read_only => value_read_only = crate::serde::de::MapAccess::next_value(&mut map)?,
92                        Field::Key_target_wwns => value_target_wwns = crate::serde::de::MapAccess::next_value(&mut map)?,
93                        Field::Key_wwids => value_wwids = crate::serde::de::MapAccess::next_value(&mut map)?,
94                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
95                    }
96                }
97
98                Ok(FCVolumeSource {
99                    fs_type: value_fs_type,
100                    lun: value_lun,
101                    read_only: value_read_only,
102                    target_wwns: value_target_wwns,
103                    wwids: value_wwids,
104                })
105            }
106        }
107
108        deserializer.deserialize_struct(
109            "FCVolumeSource",
110            &[
111                "fsType",
112                "lun",
113                "readOnly",
114                "targetWWNs",
115                "wwids",
116            ],
117            Visitor,
118        )
119    }
120}
121
122impl crate::serde::Serialize for FCVolumeSource {
123    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
124        let mut state = serializer.serialize_struct(
125            "FCVolumeSource",
126            self.fs_type.as_ref().map_or(0, |_| 1) +
127            self.lun.as_ref().map_or(0, |_| 1) +
128            self.read_only.as_ref().map_or(0, |_| 1) +
129            self.target_wwns.as_ref().map_or(0, |_| 1) +
130            self.wwids.as_ref().map_or(0, |_| 1),
131        )?;
132        if let Some(value) = &self.fs_type {
133            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "fsType", value)?;
134        }
135        if let Some(value) = &self.lun {
136            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "lun", value)?;
137        }
138        if let Some(value) = &self.read_only {
139            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readOnly", value)?;
140        }
141        if let Some(value) = &self.target_wwns {
142            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "targetWWNs", value)?;
143        }
144        if let Some(value) = &self.wwids {
145            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "wwids", value)?;
146        }
147        crate::serde::ser::SerializeStruct::end(state)
148    }
149}
150
151#[cfg(feature = "schemars")]
152impl crate::schemars::JsonSchema for FCVolumeSource {
153    fn schema_name() -> std::borrow::Cow<'static, str> {
154        "io.k8s.api.core.v1.FCVolumeSource".into()
155    }
156
157    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
158        crate::schemars::json_schema!({
159            "description": "Represents a Fibre Channel volume. Fibre Channel volumes can only be mounted as read/write once. Fibre Channel volumes support ownership management and SELinux relabeling.",
160            "type": "object",
161            "properties": {
162                "fsType": {
163                    "description": "fsType is the filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.",
164                    "type": "string",
165                },
166                "lun": {
167                    "description": "lun is Optional: FC target lun number",
168                    "type": "integer",
169                    "format": "int32",
170                },
171                "readOnly": {
172                    "description": "readOnly is Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.",
173                    "type": "boolean",
174                },
175                "targetWWNs": {
176                    "description": "targetWWNs is Optional: FC target worldwide names (WWNs)",
177                    "type": "array",
178                    "items": {
179                        "type": "string",
180                    },
181                },
182                "wwids": {
183                    "description": "wwids Optional: FC volume world wide identifiers (wwids) Either wwids or combination of targetWWNs and lun must be set, but not both simultaneously.",
184                    "type": "array",
185                    "items": {
186                        "type": "string",
187                    },
188                },
189            },
190        })
191    }
192}