k8s_openapi/v1_35/api/core/v1/
storage_os_persistent_volume_source.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct StorageOSPersistentVolumeSource {
6 pub fs_type: Option<std::string::String>,
8
9 pub read_only: Option<bool>,
11
12 pub secret_ref: Option<crate::api::core::v1::ObjectReference>,
14
15 pub volume_name: Option<std::string::String>,
17
18 pub volume_namespace: Option<std::string::String>,
20}
21
22impl crate::DeepMerge for StorageOSPersistentVolumeSource {
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.read_only, other.read_only);
26 crate::DeepMerge::merge_from(&mut self.secret_ref, other.secret_ref);
27 crate::DeepMerge::merge_from(&mut self.volume_name, other.volume_name);
28 crate::DeepMerge::merge_from(&mut self.volume_namespace, other.volume_namespace);
29 }
30}
31
32impl<'de> crate::serde::Deserialize<'de> for StorageOSPersistentVolumeSource {
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_read_only,
38 Key_secret_ref,
39 Key_volume_name,
40 Key_volume_namespace,
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 "readOnly" => Field::Key_read_only,
59 "secretRef" => Field::Key_secret_ref,
60 "volumeName" => Field::Key_volume_name,
61 "volumeNamespace" => Field::Key_volume_namespace,
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 = StorageOSPersistentVolumeSource;
75
76 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
77 f.write_str("StorageOSPersistentVolumeSource")
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_read_only: Option<bool> = None;
83 let mut value_secret_ref: Option<crate::api::core::v1::ObjectReference> = None;
84 let mut value_volume_name: Option<std::string::String> = None;
85 let mut value_volume_namespace: Option<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_read_only => value_read_only = crate::serde::de::MapAccess::next_value(&mut map)?,
91 Field::Key_secret_ref => value_secret_ref = crate::serde::de::MapAccess::next_value(&mut map)?,
92 Field::Key_volume_name => value_volume_name = crate::serde::de::MapAccess::next_value(&mut map)?,
93 Field::Key_volume_namespace => value_volume_namespace = 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(StorageOSPersistentVolumeSource {
99 fs_type: value_fs_type,
100 read_only: value_read_only,
101 secret_ref: value_secret_ref,
102 volume_name: value_volume_name,
103 volume_namespace: value_volume_namespace,
104 })
105 }
106 }
107
108 deserializer.deserialize_struct(
109 "StorageOSPersistentVolumeSource",
110 &[
111 "fsType",
112 "readOnly",
113 "secretRef",
114 "volumeName",
115 "volumeNamespace",
116 ],
117 Visitor,
118 )
119 }
120}
121
122impl crate::serde::Serialize for StorageOSPersistentVolumeSource {
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 "StorageOSPersistentVolumeSource",
126 self.fs_type.as_ref().map_or(0, |_| 1) +
127 self.read_only.as_ref().map_or(0, |_| 1) +
128 self.secret_ref.as_ref().map_or(0, |_| 1) +
129 self.volume_name.as_ref().map_or(0, |_| 1) +
130 self.volume_namespace.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.read_only {
136 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readOnly", value)?;
137 }
138 if let Some(value) = &self.secret_ref {
139 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "secretRef", value)?;
140 }
141 if let Some(value) = &self.volume_name {
142 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "volumeName", value)?;
143 }
144 if let Some(value) = &self.volume_namespace {
145 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "volumeNamespace", value)?;
146 }
147 crate::serde::ser::SerializeStruct::end(state)
148 }
149}
150
151#[cfg(feature = "schemars")]
152impl crate::schemars::JsonSchema for StorageOSPersistentVolumeSource {
153 fn schema_name() -> std::borrow::Cow<'static, str> {
154 "io.k8s.api.core.v1.StorageOSPersistentVolumeSource".into()
155 }
156
157 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
158 crate::schemars::json_schema!({
159 "description": "Represents a StorageOS persistent volume resource.",
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 "readOnly": {
167 "description": "readOnly defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.",
168 "type": "boolean",
169 },
170 "secretRef": ({
171 let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::ObjectReference>();
172 schema_obj.ensure_object().insert("description".into(), "secretRef specifies the secret to use for obtaining the StorageOS API credentials. If not specified, default values will be attempted.".into());
173 schema_obj
174 }),
175 "volumeName": {
176 "description": "volumeName is the human-readable name of the StorageOS volume. Volume names are only unique within a namespace.",
177 "type": "string",
178 },
179 "volumeNamespace": {
180 "description": "volumeNamespace specifies the scope of the volume within StorageOS. If no namespace is specified then the Pod's namespace will be used. This allows the Kubernetes name scoping to be mirrored within StorageOS for tighter integration. Set VolumeName to any name to override the default behaviour. Set to \"default\" if you are not using namespaces within StorageOS. Namespaces that do not pre-exist within StorageOS will be created.",
181 "type": "string",
182 },
183 },
184 })
185 }
186}