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

1// Generated from definition io.k8s.api.core.v1.CinderPersistentVolumeSource
2
3/// Represents a cinder volume resource in Openstack. A Cinder volume must exist before mounting to a container. The volume must also be in the same region as the kubelet. Cinder volumes support ownership management and SELinux relabeling.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct CinderPersistentVolumeSource {
6    /// fsType Filesystem type to mount. Must be a filesystem type supported by the host operating system. Examples: "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified. More info: https://examples.k8s.io/mysql-cinder-pd/README.md
7    pub fs_type: Option<std::string::String>,
8
9    /// readOnly is Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. More info: https://examples.k8s.io/mysql-cinder-pd/README.md
10    pub read_only: Option<bool>,
11
12    /// secretRef is Optional: points to a secret object containing parameters used to connect to OpenStack.
13    pub secret_ref: Option<crate::api::core::v1::SecretReference>,
14
15    /// volumeID used to identify the volume in cinder. More info: https://examples.k8s.io/mysql-cinder-pd/README.md
16    pub volume_id: std::string::String,
17}
18
19impl crate::DeepMerge for CinderPersistentVolumeSource {
20    fn merge_from(&mut self, other: Self) {
21        crate::DeepMerge::merge_from(&mut self.fs_type, other.fs_type);
22        crate::DeepMerge::merge_from(&mut self.read_only, other.read_only);
23        crate::DeepMerge::merge_from(&mut self.secret_ref, other.secret_ref);
24        crate::DeepMerge::merge_from(&mut self.volume_id, other.volume_id);
25    }
26}
27
28impl<'de> crate::serde::Deserialize<'de> for CinderPersistentVolumeSource {
29    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
30        #[allow(non_camel_case_types)]
31        enum Field {
32            Key_fs_type,
33            Key_read_only,
34            Key_secret_ref,
35            Key_volume_id,
36            Other,
37        }
38
39        impl<'de> crate::serde::Deserialize<'de> for Field {
40            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
41                struct Visitor;
42
43                impl crate::serde::de::Visitor<'_> for Visitor {
44                    type Value = Field;
45
46                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
47                        f.write_str("field identifier")
48                    }
49
50                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
51                        Ok(match v {
52                            "fsType" => Field::Key_fs_type,
53                            "readOnly" => Field::Key_read_only,
54                            "secretRef" => Field::Key_secret_ref,
55                            "volumeID" => Field::Key_volume_id,
56                            _ => Field::Other,
57                        })
58                    }
59                }
60
61                deserializer.deserialize_identifier(Visitor)
62            }
63        }
64
65        struct Visitor;
66
67        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
68            type Value = CinderPersistentVolumeSource;
69
70            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
71                f.write_str("CinderPersistentVolumeSource")
72            }
73
74            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
75                let mut value_fs_type: Option<std::string::String> = None;
76                let mut value_read_only: Option<bool> = None;
77                let mut value_secret_ref: Option<crate::api::core::v1::SecretReference> = None;
78                let mut value_volume_id: Option<std::string::String> = None;
79
80                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
81                    match key {
82                        Field::Key_fs_type => value_fs_type = crate::serde::de::MapAccess::next_value(&mut map)?,
83                        Field::Key_read_only => value_read_only = crate::serde::de::MapAccess::next_value(&mut map)?,
84                        Field::Key_secret_ref => value_secret_ref = crate::serde::de::MapAccess::next_value(&mut map)?,
85                        Field::Key_volume_id => value_volume_id = crate::serde::de::MapAccess::next_value(&mut map)?,
86                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
87                    }
88                }
89
90                Ok(CinderPersistentVolumeSource {
91                    fs_type: value_fs_type,
92                    read_only: value_read_only,
93                    secret_ref: value_secret_ref,
94                    volume_id: value_volume_id.unwrap_or_default(),
95                })
96            }
97        }
98
99        deserializer.deserialize_struct(
100            "CinderPersistentVolumeSource",
101            &[
102                "fsType",
103                "readOnly",
104                "secretRef",
105                "volumeID",
106            ],
107            Visitor,
108        )
109    }
110}
111
112impl crate::serde::Serialize for CinderPersistentVolumeSource {
113    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
114        let mut state = serializer.serialize_struct(
115            "CinderPersistentVolumeSource",
116            1 +
117            self.fs_type.as_ref().map_or(0, |_| 1) +
118            self.read_only.as_ref().map_or(0, |_| 1) +
119            self.secret_ref.as_ref().map_or(0, |_| 1),
120        )?;
121        if let Some(value) = &self.fs_type {
122            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "fsType", value)?;
123        }
124        if let Some(value) = &self.read_only {
125            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readOnly", value)?;
126        }
127        if let Some(value) = &self.secret_ref {
128            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "secretRef", value)?;
129        }
130        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "volumeID", &self.volume_id)?;
131        crate::serde::ser::SerializeStruct::end(state)
132    }
133}
134
135#[cfg(feature = "schemars")]
136impl crate::schemars::JsonSchema for CinderPersistentVolumeSource {
137    fn schema_name() -> std::borrow::Cow<'static, str> {
138        "io.k8s.api.core.v1.CinderPersistentVolumeSource".into()
139    }
140
141    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
142        crate::schemars::json_schema!({
143            "description": "Represents a cinder volume resource in Openstack. A Cinder volume must exist before mounting to a container. The volume must also be in the same region as the kubelet. Cinder volumes support ownership management and SELinux relabeling.",
144            "type": "object",
145            "properties": {
146                "fsType": {
147                    "description": "fsType Filesystem type to mount. Must be a filesystem type supported by the host operating system. Examples: \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified. More info: https://examples.k8s.io/mysql-cinder-pd/README.md",
148                    "type": "string",
149                },
150                "readOnly": {
151                    "description": "readOnly is Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. More info: https://examples.k8s.io/mysql-cinder-pd/README.md",
152                    "type": "boolean",
153                },
154                "secretRef": ({
155                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::SecretReference>();
156                    schema_obj.ensure_object().insert("description".into(), "secretRef is Optional: points to a secret object containing parameters used to connect to OpenStack.".into());
157                    schema_obj
158                }),
159                "volumeID": {
160                    "description": "volumeID used to identify the volume in cinder. More info: https://examples.k8s.io/mysql-cinder-pd/README.md",
161                    "type": "string",
162                },
163            },
164            "required": [
165                "volumeID",
166            ],
167        })
168    }
169}