k8s_openapi/v1_35/api/core/v1/
glusterfs_persistent_volume_source.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct GlusterfsPersistentVolumeSource {
6 pub endpoints: std::string::String,
8
9 pub endpoints_namespace: Option<std::string::String>,
11
12 pub path: std::string::String,
14
15 pub read_only: Option<bool>,
17}
18
19impl crate::DeepMerge for GlusterfsPersistentVolumeSource {
20 fn merge_from(&mut self, other: Self) {
21 crate::DeepMerge::merge_from(&mut self.endpoints, other.endpoints);
22 crate::DeepMerge::merge_from(&mut self.endpoints_namespace, other.endpoints_namespace);
23 crate::DeepMerge::merge_from(&mut self.path, other.path);
24 crate::DeepMerge::merge_from(&mut self.read_only, other.read_only);
25 }
26}
27
28impl<'de> crate::serde::Deserialize<'de> for GlusterfsPersistentVolumeSource {
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_endpoints,
33 Key_endpoints_namespace,
34 Key_path,
35 Key_read_only,
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 "endpoints" => Field::Key_endpoints,
53 "endpointsNamespace" => Field::Key_endpoints_namespace,
54 "path" => Field::Key_path,
55 "readOnly" => Field::Key_read_only,
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 = GlusterfsPersistentVolumeSource;
69
70 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
71 f.write_str("GlusterfsPersistentVolumeSource")
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_endpoints: Option<std::string::String> = None;
76 let mut value_endpoints_namespace: Option<std::string::String> = None;
77 let mut value_path: Option<std::string::String> = None;
78 let mut value_read_only: Option<bool> = None;
79
80 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
81 match key {
82 Field::Key_endpoints => value_endpoints = crate::serde::de::MapAccess::next_value(&mut map)?,
83 Field::Key_endpoints_namespace => value_endpoints_namespace = crate::serde::de::MapAccess::next_value(&mut map)?,
84 Field::Key_path => value_path = crate::serde::de::MapAccess::next_value(&mut map)?,
85 Field::Key_read_only => value_read_only = 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(GlusterfsPersistentVolumeSource {
91 endpoints: value_endpoints.unwrap_or_default(),
92 endpoints_namespace: value_endpoints_namespace,
93 path: value_path.unwrap_or_default(),
94 read_only: value_read_only,
95 })
96 }
97 }
98
99 deserializer.deserialize_struct(
100 "GlusterfsPersistentVolumeSource",
101 &[
102 "endpoints",
103 "endpointsNamespace",
104 "path",
105 "readOnly",
106 ],
107 Visitor,
108 )
109 }
110}
111
112impl crate::serde::Serialize for GlusterfsPersistentVolumeSource {
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 "GlusterfsPersistentVolumeSource",
116 2 +
117 self.endpoints_namespace.as_ref().map_or(0, |_| 1) +
118 self.read_only.as_ref().map_or(0, |_| 1),
119 )?;
120 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "endpoints", &self.endpoints)?;
121 if let Some(value) = &self.endpoints_namespace {
122 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "endpointsNamespace", value)?;
123 }
124 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "path", &self.path)?;
125 if let Some(value) = &self.read_only {
126 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readOnly", value)?;
127 }
128 crate::serde::ser::SerializeStruct::end(state)
129 }
130}
131
132#[cfg(feature = "schemars")]
133impl crate::schemars::JsonSchema for GlusterfsPersistentVolumeSource {
134 fn schema_name() -> std::borrow::Cow<'static, str> {
135 "io.k8s.api.core.v1.GlusterfsPersistentVolumeSource".into()
136 }
137
138 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
139 crate::schemars::json_schema!({
140 "description": "Represents a Glusterfs mount that lasts the lifetime of a pod. Glusterfs volumes do not support ownership management or SELinux relabeling.",
141 "type": "object",
142 "properties": {
143 "endpoints": {
144 "description": "endpoints is the endpoint name that details Glusterfs topology. More info: https://examples.k8s.io/volumes/glusterfs/README.md#create-a-pod",
145 "type": "string",
146 },
147 "endpointsNamespace": {
148 "description": "endpointsNamespace is the namespace that contains Glusterfs endpoint. If this field is empty, the EndpointNamespace defaults to the same namespace as the bound PVC. More info: https://examples.k8s.io/volumes/glusterfs/README.md#create-a-pod",
149 "type": "string",
150 },
151 "path": {
152 "description": "path is the Glusterfs volume path. More info: https://examples.k8s.io/volumes/glusterfs/README.md#create-a-pod",
153 "type": "string",
154 },
155 "readOnly": {
156 "description": "readOnly here will force the Glusterfs volume to be mounted with read-only permissions. Defaults to false. More info: https://examples.k8s.io/volumes/glusterfs/README.md#create-a-pod",
157 "type": "boolean",
158 },
159 },
160 "required": [
161 "endpoints",
162 "path",
163 ],
164 })
165 }
166}