1// Generated from definition io.k8s.api.storage.v1.CSINodeDriver
23/// CSINodeDriver holds information about the specification of one CSI driver installed on a node
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct CSINodeDriver {
6/// allocatable represents the volume resources of a node that are available for scheduling. This field is beta.
7pub allocatable: Option<crate::api::storage::v1::VolumeNodeResources>,
89/// 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.
10pub name: std::string::String,
1112/// 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.
13pub node_id: std::string::String,
1415/// 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.
16pub topology_keys: Option<std::vec::Vec<std::string::String>>,
17}
1819impl crate::DeepMerge for CSINodeDriver {
20fn merge_from(&mut self, other: Self) {
21crate::DeepMerge::merge_from(&mut self.allocatable, other.allocatable);
22crate::DeepMerge::merge_from(&mut self.name, other.name);
23crate::DeepMerge::merge_from(&mut self.node_id, other.node_id);
24crate::merge_strategies::list::atomic(&mut self.topology_keys, other.topology_keys);
25 }
26}
2728impl<'de> crate::serde::Deserialize<'de> for CSINodeDriver {
29fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
30#[allow(non_camel_case_types)]
31enum Field {
32 Key_allocatable,
33 Key_name,
34 Key_node_id,
35 Key_topology_keys,
36 Other,
37 }
3839impl<'de> crate::serde::Deserialize<'de> for Field {
40fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
41struct Visitor;
4243impl crate::serde::de::Visitor<'_> for Visitor {
44type Value = Field;
4546fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
47 f.write_str("field identifier")
48 }
4950fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
51Ok(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 }
6061 deserializer.deserialize_identifier(Visitor)
62 }
63 }
6465struct Visitor;
6667impl<'de> crate::serde::de::Visitor<'de> for Visitor {
68type Value = CSINodeDriver;
6970fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
71 f.write_str("CSINodeDriver")
72 }
7374fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
75let mut value_allocatable: Option<crate::api::storage::v1::VolumeNodeResources> = None;
76let mut value_name: Option<std::string::String> = None;
77let mut value_node_id: Option<std::string::String> = None;
78let mut value_topology_keys: Option<std::vec::Vec<std::string::String>> = None;
7980while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
81match 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 }
8990Ok(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 }
9899 deserializer.deserialize_struct(
100"CSINodeDriver",
101&[
102"allocatable",
103"name",
104"nodeID",
105"topologyKeys",
106 ],
107 Visitor,
108 )
109 }
110}
111112impl crate::serde::Serialize for CSINodeDriver {
113fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
114let mut state = serializer.serialize_struct(
115"CSINodeDriver",
1162 +
117self.allocatable.as_ref().map_or(0, |_| 1) +
118self.topology_keys.as_ref().map_or(0, |_| 1),
119 )?;
120if let Some(value) = &self.allocatable {
121crate::serde::ser::SerializeStruct::serialize_field(&mut state, "allocatable", value)?;
122 }
123crate::serde::ser::SerializeStruct::serialize_field(&mut state, "name", &self.name)?;
124crate::serde::ser::SerializeStruct::serialize_field(&mut state, "nodeID", &self.node_id)?;
125if let Some(value) = &self.topology_keys {
126crate::serde::ser::SerializeStruct::serialize_field(&mut state, "topologyKeys", value)?;
127 }
128crate::serde::ser::SerializeStruct::end(state)
129 }
130}
131132#[cfg(feature = "schemars")]
133impl crate::schemars::JsonSchema for CSINodeDriver {
134fn schema_name() -> std::string::String {
135"io.k8s.api.storage.v1.CSINodeDriver".into()
136 }
137138fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
139crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
140 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
141 description: Some("CSINodeDriver holds information about the specification of one CSI driver installed on a node".into()),
142 ..Default::default()
143 })),
144 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
145 object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
146 properties: [
147 (
148"allocatable".into(),
149 {
150let mut schema_obj = __gen.subschema_for::<crate::api::storage::v1::VolumeNodeResources>().into_object();
151 schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
152 description: Some("allocatable represents the volume resources of a node that are available for scheduling. This field is beta.".into()),
153 ..Default::default()
154 }));
155crate::schemars::schema::Schema::Object(schema_obj)
156 },
157 ),
158 (
159"name".into(),
160crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
161 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
162 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()),
163 ..Default::default()
164 })),
165 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
166 ..Default::default()
167 }),
168 ),
169 (
170"nodeID".into(),
171crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
172 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
173 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()),
174 ..Default::default()
175 })),
176 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
177 ..Default::default()
178 }),
179 ),
180 (
181"topologyKeys".into(),
182crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
183 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
184 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()),
185 ..Default::default()
186 })),
187 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Array))),
188 array: Some(std::boxed::Box::new(crate::schemars::schema::ArrayValidation {
189 items: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(
190crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
191 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
192 ..Default::default()
193 })
194 ))),
195 ..Default::default()
196 })),
197 ..Default::default()
198 }),
199 ),
200 ].into(),
201 required: [
202"name".into(),
203"nodeID".into(),
204 ].into(),
205 ..Default::default()
206 })),
207 ..Default::default()
208 })
209 }
210}