k8s_openapi/v1_36/api/storage/v1/
csi_node_driver.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct CSINodeDriver {
6 pub allocatable: Option<crate::api::storage::v1::VolumeNodeResources>,
8
9 pub name: std::string::String,
11
12 pub node_id: std::string::String,
14
15 pub topology_keys: Option<std::vec::Vec<std::string::String>>,
17}
18
19impl crate::DeepMerge for CSINodeDriver {
20 fn merge_from(&mut self, other: Self) {
21 crate::DeepMerge::merge_from(&mut self.allocatable, other.allocatable);
22 crate::DeepMerge::merge_from(&mut self.name, other.name);
23 crate::DeepMerge::merge_from(&mut self.node_id, other.node_id);
24 crate::merge_strategies::list::atomic(&mut self.topology_keys, other.topology_keys);
25 }
26}
27
28impl<'de> crate::serde::Deserialize<'de> for CSINodeDriver {
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_allocatable,
33 Key_name,
34 Key_node_id,
35 Key_topology_keys,
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 "allocatable" => Field::Key_allocatable,
53 "name" => Field::Key_name,
54 "nodeID" => Field::Key_node_id,
55 "topologyKeys" => Field::Key_topology_keys,
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 = CSINodeDriver;
69
70 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
71 f.write_str("CSINodeDriver")
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_allocatable: Option<crate::api::storage::v1::VolumeNodeResources> = None;
76 let mut value_name: Option<std::string::String> = None;
77 let mut value_node_id: Option<std::string::String> = None;
78 let mut value_topology_keys: Option<std::vec::Vec<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_allocatable => value_allocatable = crate::serde::de::MapAccess::next_value(&mut map)?,
83 Field::Key_name => value_name = crate::serde::de::MapAccess::next_value(&mut map)?,
84 Field::Key_node_id => value_node_id = crate::serde::de::MapAccess::next_value(&mut map)?,
85 Field::Key_topology_keys => value_topology_keys = 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(CSINodeDriver {
91 allocatable: value_allocatable,
92 name: value_name.unwrap_or_default(),
93 node_id: value_node_id.unwrap_or_default(),
94 topology_keys: value_topology_keys,
95 })
96 }
97 }
98
99 deserializer.deserialize_struct(
100 "CSINodeDriver",
101 &[
102 "allocatable",
103 "name",
104 "nodeID",
105 "topologyKeys",
106 ],
107 Visitor,
108 )
109 }
110}
111
112impl crate::serde::Serialize for CSINodeDriver {
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 "CSINodeDriver",
116 2 +
117 self.allocatable.as_ref().map_or(0, |_| 1) +
118 self.topology_keys.as_ref().map_or(0, |_| 1),
119 )?;
120 if let Some(value) = &self.allocatable {
121 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "allocatable", value)?;
122 }
123 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "name", &self.name)?;
124 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "nodeID", &self.node_id)?;
125 if let Some(value) = &self.topology_keys {
126 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "topologyKeys", value)?;
127 }
128 crate::serde::ser::SerializeStruct::end(state)
129 }
130}
131
132#[cfg(feature = "schemars")]
133impl crate::schemars::JsonSchema for CSINodeDriver {
134 fn schema_name() -> std::borrow::Cow<'static, str> {
135 "io.k8s.api.storage.v1.CSINodeDriver".into()
136 }
137
138 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
139 crate::schemars::json_schema!({
140 "description": "CSINodeDriver holds information about the specification of one CSI driver installed on a node",
141 "type": "object",
142 "properties": {
143 "allocatable": ({
144 let mut schema_obj = __gen.subschema_for::<crate::api::storage::v1::VolumeNodeResources>();
145 schema_obj.ensure_object().insert("description".into(), "allocatable represents the volume resources of a node that are available for scheduling. This field is beta.".into());
146 schema_obj
147 }),
148 "name": {
149 "description": "name represents the name of the CSI driver that this object refers to. This MUST be the same name returned by the CSI GetPluginName() call for that driver.",
150 "type": "string",
151 },
152 "nodeID": {
153 "description": "nodeID of the node from the driver point of view. This field enables Kubernetes to communicate with storage systems that do not share the same nomenclature for nodes. For example, Kubernetes may refer to a given node as \"node1\", but the storage system may refer to the same node as \"nodeA\". When Kubernetes issues a command to the storage system to attach a volume to a specific node, it can use this field to refer to the node name using the ID that the storage system will understand, e.g. \"nodeA\" instead of \"node1\". This field is required.",
154 "type": "string",
155 },
156 "topologyKeys": {
157 "description": "topologyKeys is the list of keys supported by the driver. When a driver is initialized on a cluster, it provides a set of topology keys that it understands (e.g. \"company.com/zone\", \"company.com/region\"). When a driver is initialized on a node, it provides the same topology keys along with values. Kubelet will expose these topology keys as labels on its own node object. When Kubernetes does topology aware provisioning, it can use this list to determine which labels it should retrieve from the node object and pass back to the driver. It is possible for different nodes to use different topology keys. This can be empty if driver does not support topology.",
158 "type": "array",
159 "items": {
160 "type": "string",
161 },
162 },
163 },
164 "required": [
165 "name",
166 "nodeID",
167 ],
168 })
169 }
170}
171
172#[cfg(feature = "schemars08")]
173impl crate::schemars08::JsonSchema for CSINodeDriver {
174 fn schema_name() -> std::string::String {
175 "io.k8s.api.storage.v1.CSINodeDriver".into()
176 }
177
178 fn json_schema(__gen: &mut crate::schemars08::gen::SchemaGenerator) -> crate::schemars08::schema::Schema {
179 crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
180 metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
181 description: Some("CSINodeDriver holds information about the specification of one CSI driver installed on a node".into()),
182 ..Default::default()
183 })),
184 instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Object))),
185 object: Some(std::boxed::Box::new(crate::schemars08::schema::ObjectValidation {
186 properties: [
187 (
188 "allocatable".into(),
189 {
190 let mut schema_obj = __gen.subschema_for::<crate::api::storage::v1::VolumeNodeResources>().into_object();
191 schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
192 description: Some("allocatable represents the volume resources of a node that are available for scheduling. This field is beta.".into()),
193 ..Default::default()
194 }));
195 crate::schemars08::schema::Schema::Object(schema_obj)
196 },
197 ),
198 (
199 "name".into(),
200 crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
201 metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
202 description: Some("name represents the name of the CSI driver that this object refers to. This MUST be the same name returned by the CSI GetPluginName() call for that driver.".into()),
203 ..Default::default()
204 })),
205 instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
206 ..Default::default()
207 }),
208 ),
209 (
210 "nodeID".into(),
211 crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
212 metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
213 description: Some("nodeID of the node from the driver point of view. This field enables Kubernetes to communicate with storage systems that do not share the same nomenclature for nodes. For example, Kubernetes may refer to a given node as \"node1\", but the storage system may refer to the same node as \"nodeA\". When Kubernetes issues a command to the storage system to attach a volume to a specific node, it can use this field to refer to the node name using the ID that the storage system will understand, e.g. \"nodeA\" instead of \"node1\". This field is required.".into()),
214 ..Default::default()
215 })),
216 instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
217 ..Default::default()
218 }),
219 ),
220 (
221 "topologyKeys".into(),
222 crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
223 metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
224 description: Some("topologyKeys is the list of keys supported by the driver. When a driver is initialized on a cluster, it provides a set of topology keys that it understands (e.g. \"company.com/zone\", \"company.com/region\"). When a driver is initialized on a node, it provides the same topology keys along with values. Kubelet will expose these topology keys as labels on its own node object. When Kubernetes does topology aware provisioning, it can use this list to determine which labels it should retrieve from the node object and pass back to the driver. It is possible for different nodes to use different topology keys. This can be empty if driver does not support topology.".into()),
225 ..Default::default()
226 })),
227 instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Array))),
228 array: Some(std::boxed::Box::new(crate::schemars08::schema::ArrayValidation {
229 items: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(
230 crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
231 instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
232 ..Default::default()
233 })
234 ))),
235 ..Default::default()
236 })),
237 ..Default::default()
238 }),
239 ),
240 ].into(),
241 required: [
242 "name".into(),
243 "nodeID".into(),
244 ].into(),
245 ..Default::default()
246 })),
247 ..Default::default()
248 })
249 }
250}