1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct NodeStatus {
6 pub addresses: Option<std::vec::Vec<crate::api::core::v1::NodeAddress>>,
8
9 pub allocatable: Option<std::collections::BTreeMap<std::string::String, crate::apimachinery::pkg::api::resource::Quantity>>,
11
12 pub capacity: Option<std::collections::BTreeMap<std::string::String, crate::apimachinery::pkg::api::resource::Quantity>>,
14
15 pub conditions: Option<std::vec::Vec<crate::api::core::v1::NodeCondition>>,
17
18 pub config: Option<crate::api::core::v1::NodeConfigStatus>,
20
21 pub daemon_endpoints: Option<crate::api::core::v1::NodeDaemonEndpoints>,
23
24 pub images: Option<std::vec::Vec<crate::api::core::v1::ContainerImage>>,
26
27 pub node_info: Option<crate::api::core::v1::NodeSystemInfo>,
29
30 pub phase: Option<std::string::String>,
32
33 pub runtime_handlers: Option<std::vec::Vec<crate::api::core::v1::NodeRuntimeHandler>>,
35
36 pub volumes_attached: Option<std::vec::Vec<crate::api::core::v1::AttachedVolume>>,
38
39 pub volumes_in_use: Option<std::vec::Vec<std::string::String>>,
41}
42
43impl crate::DeepMerge for NodeStatus {
44 fn merge_from(&mut self, other: Self) {
45 crate::merge_strategies::list::map(
46 &mut self.addresses,
47 other.addresses,
48 &[|lhs, rhs| lhs.type_ == rhs.type_],
49 |current_item, other_item| {
50 crate::DeepMerge::merge_from(current_item, other_item);
51 },
52 );
53 crate::merge_strategies::map::granular(&mut self.allocatable, other.allocatable, |current_item, other_item| {
54 crate::DeepMerge::merge_from(current_item, other_item);
55 });
56 crate::merge_strategies::map::granular(&mut self.capacity, other.capacity, |current_item, other_item| {
57 crate::DeepMerge::merge_from(current_item, other_item);
58 });
59 crate::merge_strategies::list::map(
60 &mut self.conditions,
61 other.conditions,
62 &[|lhs, rhs| lhs.type_ == rhs.type_],
63 |current_item, other_item| {
64 crate::DeepMerge::merge_from(current_item, other_item);
65 },
66 );
67 crate::DeepMerge::merge_from(&mut self.config, other.config);
68 crate::DeepMerge::merge_from(&mut self.daemon_endpoints, other.daemon_endpoints);
69 crate::merge_strategies::list::atomic(&mut self.images, other.images);
70 crate::DeepMerge::merge_from(&mut self.node_info, other.node_info);
71 crate::DeepMerge::merge_from(&mut self.phase, other.phase);
72 crate::merge_strategies::list::atomic(&mut self.runtime_handlers, other.runtime_handlers);
73 crate::merge_strategies::list::atomic(&mut self.volumes_attached, other.volumes_attached);
74 crate::merge_strategies::list::atomic(&mut self.volumes_in_use, other.volumes_in_use);
75 }
76}
77
78impl<'de> crate::serde::Deserialize<'de> for NodeStatus {
79 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
80 #[allow(non_camel_case_types)]
81 enum Field {
82 Key_addresses,
83 Key_allocatable,
84 Key_capacity,
85 Key_conditions,
86 Key_config,
87 Key_daemon_endpoints,
88 Key_images,
89 Key_node_info,
90 Key_phase,
91 Key_runtime_handlers,
92 Key_volumes_attached,
93 Key_volumes_in_use,
94 Other,
95 }
96
97 impl<'de> crate::serde::Deserialize<'de> for Field {
98 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
99 struct Visitor;
100
101 impl crate::serde::de::Visitor<'_> for Visitor {
102 type Value = Field;
103
104 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
105 f.write_str("field identifier")
106 }
107
108 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
109 Ok(match v {
110 "addresses" => Field::Key_addresses,
111 "allocatable" => Field::Key_allocatable,
112 "capacity" => Field::Key_capacity,
113 "conditions" => Field::Key_conditions,
114 "config" => Field::Key_config,
115 "daemonEndpoints" => Field::Key_daemon_endpoints,
116 "images" => Field::Key_images,
117 "nodeInfo" => Field::Key_node_info,
118 "phase" => Field::Key_phase,
119 "runtimeHandlers" => Field::Key_runtime_handlers,
120 "volumesAttached" => Field::Key_volumes_attached,
121 "volumesInUse" => Field::Key_volumes_in_use,
122 _ => Field::Other,
123 })
124 }
125 }
126
127 deserializer.deserialize_identifier(Visitor)
128 }
129 }
130
131 struct Visitor;
132
133 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
134 type Value = NodeStatus;
135
136 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
137 f.write_str("NodeStatus")
138 }
139
140 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
141 let mut value_addresses: Option<std::vec::Vec<crate::api::core::v1::NodeAddress>> = None;
142 let mut value_allocatable: Option<std::collections::BTreeMap<std::string::String, crate::apimachinery::pkg::api::resource::Quantity>> = None;
143 let mut value_capacity: Option<std::collections::BTreeMap<std::string::String, crate::apimachinery::pkg::api::resource::Quantity>> = None;
144 let mut value_conditions: Option<std::vec::Vec<crate::api::core::v1::NodeCondition>> = None;
145 let mut value_config: Option<crate::api::core::v1::NodeConfigStatus> = None;
146 let mut value_daemon_endpoints: Option<crate::api::core::v1::NodeDaemonEndpoints> = None;
147 let mut value_images: Option<std::vec::Vec<crate::api::core::v1::ContainerImage>> = None;
148 let mut value_node_info: Option<crate::api::core::v1::NodeSystemInfo> = None;
149 let mut value_phase: Option<std::string::String> = None;
150 let mut value_runtime_handlers: Option<std::vec::Vec<crate::api::core::v1::NodeRuntimeHandler>> = None;
151 let mut value_volumes_attached: Option<std::vec::Vec<crate::api::core::v1::AttachedVolume>> = None;
152 let mut value_volumes_in_use: Option<std::vec::Vec<std::string::String>> = None;
153
154 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
155 match key {
156 Field::Key_addresses => value_addresses = crate::serde::de::MapAccess::next_value(&mut map)?,
157 Field::Key_allocatable => value_allocatable = crate::serde::de::MapAccess::next_value(&mut map)?,
158 Field::Key_capacity => value_capacity = crate::serde::de::MapAccess::next_value(&mut map)?,
159 Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
160 Field::Key_config => value_config = crate::serde::de::MapAccess::next_value(&mut map)?,
161 Field::Key_daemon_endpoints => value_daemon_endpoints = crate::serde::de::MapAccess::next_value(&mut map)?,
162 Field::Key_images => value_images = crate::serde::de::MapAccess::next_value(&mut map)?,
163 Field::Key_node_info => value_node_info = crate::serde::de::MapAccess::next_value(&mut map)?,
164 Field::Key_phase => value_phase = crate::serde::de::MapAccess::next_value(&mut map)?,
165 Field::Key_runtime_handlers => value_runtime_handlers = crate::serde::de::MapAccess::next_value(&mut map)?,
166 Field::Key_volumes_attached => value_volumes_attached = crate::serde::de::MapAccess::next_value(&mut map)?,
167 Field::Key_volumes_in_use => value_volumes_in_use = crate::serde::de::MapAccess::next_value(&mut map)?,
168 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
169 }
170 }
171
172 Ok(NodeStatus {
173 addresses: value_addresses,
174 allocatable: value_allocatable,
175 capacity: value_capacity,
176 conditions: value_conditions,
177 config: value_config,
178 daemon_endpoints: value_daemon_endpoints,
179 images: value_images,
180 node_info: value_node_info,
181 phase: value_phase,
182 runtime_handlers: value_runtime_handlers,
183 volumes_attached: value_volumes_attached,
184 volumes_in_use: value_volumes_in_use,
185 })
186 }
187 }
188
189 deserializer.deserialize_struct(
190 "NodeStatus",
191 &[
192 "addresses",
193 "allocatable",
194 "capacity",
195 "conditions",
196 "config",
197 "daemonEndpoints",
198 "images",
199 "nodeInfo",
200 "phase",
201 "runtimeHandlers",
202 "volumesAttached",
203 "volumesInUse",
204 ],
205 Visitor,
206 )
207 }
208}
209
210impl crate::serde::Serialize for NodeStatus {
211 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
212 let mut state = serializer.serialize_struct(
213 "NodeStatus",
214 self.addresses.as_ref().map_or(0, |_| 1) +
215 self.allocatable.as_ref().map_or(0, |_| 1) +
216 self.capacity.as_ref().map_or(0, |_| 1) +
217 self.conditions.as_ref().map_or(0, |_| 1) +
218 self.config.as_ref().map_or(0, |_| 1) +
219 self.daemon_endpoints.as_ref().map_or(0, |_| 1) +
220 self.images.as_ref().map_or(0, |_| 1) +
221 self.node_info.as_ref().map_or(0, |_| 1) +
222 self.phase.as_ref().map_or(0, |_| 1) +
223 self.runtime_handlers.as_ref().map_or(0, |_| 1) +
224 self.volumes_attached.as_ref().map_or(0, |_| 1) +
225 self.volumes_in_use.as_ref().map_or(0, |_| 1),
226 )?;
227 if let Some(value) = &self.addresses {
228 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "addresses", value)?;
229 }
230 if let Some(value) = &self.allocatable {
231 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "allocatable", value)?;
232 }
233 if let Some(value) = &self.capacity {
234 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "capacity", value)?;
235 }
236 if let Some(value) = &self.conditions {
237 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
238 }
239 if let Some(value) = &self.config {
240 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "config", value)?;
241 }
242 if let Some(value) = &self.daemon_endpoints {
243 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "daemonEndpoints", value)?;
244 }
245 if let Some(value) = &self.images {
246 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "images", value)?;
247 }
248 if let Some(value) = &self.node_info {
249 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "nodeInfo", value)?;
250 }
251 if let Some(value) = &self.phase {
252 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "phase", value)?;
253 }
254 if let Some(value) = &self.runtime_handlers {
255 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "runtimeHandlers", value)?;
256 }
257 if let Some(value) = &self.volumes_attached {
258 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "volumesAttached", value)?;
259 }
260 if let Some(value) = &self.volumes_in_use {
261 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "volumesInUse", value)?;
262 }
263 crate::serde::ser::SerializeStruct::end(state)
264 }
265}
266
267#[cfg(feature = "schemars")]
268impl crate::schemars::JsonSchema for NodeStatus {
269 fn schema_name() -> std::borrow::Cow<'static, str> {
270 "io.k8s.api.core.v1.NodeStatus".into()
271 }
272
273 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
274 crate::schemars::json_schema!({
275 "description": "NodeStatus is information about the current status of a node.",
276 "type": "object",
277 "properties": {
278 "addresses": {
279 "description": "List of addresses reachable to the node. Queried from cloud provider, if available. More info: https://kubernetes.io/docs/concepts/nodes/node/#addresses Note: This field is declared as mergeable, but the merge key is not sufficiently unique, which can cause data corruption when it is merged. Callers should instead use a full-replacement patch. See https://pr.k8s.io/79391 for an example. Consumers should assume that addresses can change during the lifetime of a Node. However, there are some exceptions where this may not be possible, such as Pods that inherit a Node's address in its own status or consumers of the downward API (status.hostIP).",
280 "type": "array",
281 "items": (__gen.subschema_for::<crate::api::core::v1::NodeAddress>()),
282 },
283 "allocatable": {
284 "description": "Allocatable represents the resources of a node that are available for scheduling. Defaults to Capacity.",
285 "type": "object",
286 "additionalProperties": (__gen.subschema_for::<crate::apimachinery::pkg::api::resource::Quantity>()),
287 },
288 "capacity": {
289 "description": "Capacity represents the total resources of a node. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#capacity",
290 "type": "object",
291 "additionalProperties": (__gen.subschema_for::<crate::apimachinery::pkg::api::resource::Quantity>()),
292 },
293 "conditions": {
294 "description": "Conditions is an array of current observed node conditions. More info: https://kubernetes.io/docs/concepts/nodes/node/#condition",
295 "type": "array",
296 "items": (__gen.subschema_for::<crate::api::core::v1::NodeCondition>()),
297 },
298 "config": ({
299 let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::NodeConfigStatus>();
300 schema_obj.ensure_object().insert("description".into(), "Status of the config assigned to the node via the dynamic Kubelet config feature.".into());
301 schema_obj
302 }),
303 "daemonEndpoints": ({
304 let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::NodeDaemonEndpoints>();
305 schema_obj.ensure_object().insert("description".into(), "Endpoints of daemons running on the Node.".into());
306 schema_obj
307 }),
308 "images": {
309 "description": "List of container images on this node",
310 "type": "array",
311 "items": (__gen.subschema_for::<crate::api::core::v1::ContainerImage>()),
312 },
313 "nodeInfo": ({
314 let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::NodeSystemInfo>();
315 schema_obj.ensure_object().insert("description".into(), "Set of ids/uuids to uniquely identify the node. More info: https://kubernetes.io/docs/concepts/nodes/node/#info".into());
316 schema_obj
317 }),
318 "phase": {
319 "description": "NodePhase is the recently observed lifecycle phase of the node. More info: https://kubernetes.io/docs/concepts/nodes/node/#phase The field is never populated, and now is deprecated.",
320 "type": "string",
321 },
322 "runtimeHandlers": {
323 "description": "The available runtime handlers.",
324 "type": "array",
325 "items": (__gen.subschema_for::<crate::api::core::v1::NodeRuntimeHandler>()),
326 },
327 "volumesAttached": {
328 "description": "List of volumes that are attached to the node.",
329 "type": "array",
330 "items": (__gen.subschema_for::<crate::api::core::v1::AttachedVolume>()),
331 },
332 "volumesInUse": {
333 "description": "List of attachable volumes in use (mounted) by the node.",
334 "type": "array",
335 "items": {
336 "type": "string",
337 },
338 },
339 },
340 })
341 }
342}