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 declared_features: Option<std::vec::Vec<std::string::String>>,
26
27 pub features: Option<crate::api::core::v1::NodeFeatures>,
29
30 pub images: Option<std::vec::Vec<crate::api::core::v1::ContainerImage>>,
32
33 pub node_info: Option<crate::api::core::v1::NodeSystemInfo>,
35
36 pub phase: Option<std::string::String>,
38
39 pub runtime_handlers: Option<std::vec::Vec<crate::api::core::v1::NodeRuntimeHandler>>,
41
42 pub volumes_attached: Option<std::vec::Vec<crate::api::core::v1::AttachedVolume>>,
44
45 pub volumes_in_use: Option<std::vec::Vec<std::string::String>>,
47}
48
49impl crate::DeepMerge for NodeStatus {
50 fn merge_from(&mut self, other: Self) {
51 crate::merge_strategies::list::map(
52 &mut self.addresses,
53 other.addresses,
54 &[|lhs, rhs| lhs.type_ == rhs.type_],
55 |current_item, other_item| {
56 crate::DeepMerge::merge_from(current_item, other_item);
57 },
58 );
59 crate::merge_strategies::map::granular(&mut self.allocatable, other.allocatable, |current_item, other_item| {
60 crate::DeepMerge::merge_from(current_item, other_item);
61 });
62 crate::merge_strategies::map::granular(&mut self.capacity, other.capacity, |current_item, other_item| {
63 crate::DeepMerge::merge_from(current_item, other_item);
64 });
65 crate::merge_strategies::list::map(
66 &mut self.conditions,
67 other.conditions,
68 &[|lhs, rhs| lhs.type_ == rhs.type_],
69 |current_item, other_item| {
70 crate::DeepMerge::merge_from(current_item, other_item);
71 },
72 );
73 crate::DeepMerge::merge_from(&mut self.config, other.config);
74 crate::DeepMerge::merge_from(&mut self.daemon_endpoints, other.daemon_endpoints);
75 crate::merge_strategies::list::atomic(&mut self.declared_features, other.declared_features);
76 crate::DeepMerge::merge_from(&mut self.features, other.features);
77 crate::merge_strategies::list::atomic(&mut self.images, other.images);
78 crate::DeepMerge::merge_from(&mut self.node_info, other.node_info);
79 crate::DeepMerge::merge_from(&mut self.phase, other.phase);
80 crate::merge_strategies::list::atomic(&mut self.runtime_handlers, other.runtime_handlers);
81 crate::merge_strategies::list::atomic(&mut self.volumes_attached, other.volumes_attached);
82 crate::merge_strategies::list::atomic(&mut self.volumes_in_use, other.volumes_in_use);
83 }
84}
85
86impl<'de> crate::serde::Deserialize<'de> for NodeStatus {
87 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
88 #[allow(non_camel_case_types)]
89 enum Field {
90 Key_addresses,
91 Key_allocatable,
92 Key_capacity,
93 Key_conditions,
94 Key_config,
95 Key_daemon_endpoints,
96 Key_declared_features,
97 Key_features,
98 Key_images,
99 Key_node_info,
100 Key_phase,
101 Key_runtime_handlers,
102 Key_volumes_attached,
103 Key_volumes_in_use,
104 Other,
105 }
106
107 impl<'de> crate::serde::Deserialize<'de> for Field {
108 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
109 struct Visitor;
110
111 impl crate::serde::de::Visitor<'_> for Visitor {
112 type Value = Field;
113
114 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
115 f.write_str("field identifier")
116 }
117
118 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
119 Ok(match v {
120 "addresses" => Field::Key_addresses,
121 "allocatable" => Field::Key_allocatable,
122 "capacity" => Field::Key_capacity,
123 "conditions" => Field::Key_conditions,
124 "config" => Field::Key_config,
125 "daemonEndpoints" => Field::Key_daemon_endpoints,
126 "declaredFeatures" => Field::Key_declared_features,
127 "features" => Field::Key_features,
128 "images" => Field::Key_images,
129 "nodeInfo" => Field::Key_node_info,
130 "phase" => Field::Key_phase,
131 "runtimeHandlers" => Field::Key_runtime_handlers,
132 "volumesAttached" => Field::Key_volumes_attached,
133 "volumesInUse" => Field::Key_volumes_in_use,
134 _ => Field::Other,
135 })
136 }
137 }
138
139 deserializer.deserialize_identifier(Visitor)
140 }
141 }
142
143 struct Visitor;
144
145 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
146 type Value = NodeStatus;
147
148 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
149 f.write_str("NodeStatus")
150 }
151
152 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
153 let mut value_addresses: Option<std::vec::Vec<crate::api::core::v1::NodeAddress>> = None;
154 let mut value_allocatable: Option<std::collections::BTreeMap<std::string::String, crate::apimachinery::pkg::api::resource::Quantity>> = None;
155 let mut value_capacity: Option<std::collections::BTreeMap<std::string::String, crate::apimachinery::pkg::api::resource::Quantity>> = None;
156 let mut value_conditions: Option<std::vec::Vec<crate::api::core::v1::NodeCondition>> = None;
157 let mut value_config: Option<crate::api::core::v1::NodeConfigStatus> = None;
158 let mut value_daemon_endpoints: Option<crate::api::core::v1::NodeDaemonEndpoints> = None;
159 let mut value_declared_features: Option<std::vec::Vec<std::string::String>> = None;
160 let mut value_features: Option<crate::api::core::v1::NodeFeatures> = None;
161 let mut value_images: Option<std::vec::Vec<crate::api::core::v1::ContainerImage>> = None;
162 let mut value_node_info: Option<crate::api::core::v1::NodeSystemInfo> = None;
163 let mut value_phase: Option<std::string::String> = None;
164 let mut value_runtime_handlers: Option<std::vec::Vec<crate::api::core::v1::NodeRuntimeHandler>> = None;
165 let mut value_volumes_attached: Option<std::vec::Vec<crate::api::core::v1::AttachedVolume>> = None;
166 let mut value_volumes_in_use: Option<std::vec::Vec<std::string::String>> = None;
167
168 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
169 match key {
170 Field::Key_addresses => value_addresses = crate::serde::de::MapAccess::next_value(&mut map)?,
171 Field::Key_allocatable => value_allocatable = crate::serde::de::MapAccess::next_value(&mut map)?,
172 Field::Key_capacity => value_capacity = crate::serde::de::MapAccess::next_value(&mut map)?,
173 Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
174 Field::Key_config => value_config = crate::serde::de::MapAccess::next_value(&mut map)?,
175 Field::Key_daemon_endpoints => value_daemon_endpoints = crate::serde::de::MapAccess::next_value(&mut map)?,
176 Field::Key_declared_features => value_declared_features = crate::serde::de::MapAccess::next_value(&mut map)?,
177 Field::Key_features => value_features = crate::serde::de::MapAccess::next_value(&mut map)?,
178 Field::Key_images => value_images = crate::serde::de::MapAccess::next_value(&mut map)?,
179 Field::Key_node_info => value_node_info = crate::serde::de::MapAccess::next_value(&mut map)?,
180 Field::Key_phase => value_phase = crate::serde::de::MapAccess::next_value(&mut map)?,
181 Field::Key_runtime_handlers => value_runtime_handlers = crate::serde::de::MapAccess::next_value(&mut map)?,
182 Field::Key_volumes_attached => value_volumes_attached = crate::serde::de::MapAccess::next_value(&mut map)?,
183 Field::Key_volumes_in_use => value_volumes_in_use = crate::serde::de::MapAccess::next_value(&mut map)?,
184 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
185 }
186 }
187
188 Ok(NodeStatus {
189 addresses: value_addresses,
190 allocatable: value_allocatable,
191 capacity: value_capacity,
192 conditions: value_conditions,
193 config: value_config,
194 daemon_endpoints: value_daemon_endpoints,
195 declared_features: value_declared_features,
196 features: value_features,
197 images: value_images,
198 node_info: value_node_info,
199 phase: value_phase,
200 runtime_handlers: value_runtime_handlers,
201 volumes_attached: value_volumes_attached,
202 volumes_in_use: value_volumes_in_use,
203 })
204 }
205 }
206
207 deserializer.deserialize_struct(
208 "NodeStatus",
209 &[
210 "addresses",
211 "allocatable",
212 "capacity",
213 "conditions",
214 "config",
215 "daemonEndpoints",
216 "declaredFeatures",
217 "features",
218 "images",
219 "nodeInfo",
220 "phase",
221 "runtimeHandlers",
222 "volumesAttached",
223 "volumesInUse",
224 ],
225 Visitor,
226 )
227 }
228}
229
230impl crate::serde::Serialize for NodeStatus {
231 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
232 let mut state = serializer.serialize_struct(
233 "NodeStatus",
234 self.addresses.as_ref().map_or(0, |_| 1) +
235 self.allocatable.as_ref().map_or(0, |_| 1) +
236 self.capacity.as_ref().map_or(0, |_| 1) +
237 self.conditions.as_ref().map_or(0, |_| 1) +
238 self.config.as_ref().map_or(0, |_| 1) +
239 self.daemon_endpoints.as_ref().map_or(0, |_| 1) +
240 self.declared_features.as_ref().map_or(0, |_| 1) +
241 self.features.as_ref().map_or(0, |_| 1) +
242 self.images.as_ref().map_or(0, |_| 1) +
243 self.node_info.as_ref().map_or(0, |_| 1) +
244 self.phase.as_ref().map_or(0, |_| 1) +
245 self.runtime_handlers.as_ref().map_or(0, |_| 1) +
246 self.volumes_attached.as_ref().map_or(0, |_| 1) +
247 self.volumes_in_use.as_ref().map_or(0, |_| 1),
248 )?;
249 if let Some(value) = &self.addresses {
250 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "addresses", value)?;
251 }
252 if let Some(value) = &self.allocatable {
253 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "allocatable", value)?;
254 }
255 if let Some(value) = &self.capacity {
256 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "capacity", value)?;
257 }
258 if let Some(value) = &self.conditions {
259 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
260 }
261 if let Some(value) = &self.config {
262 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "config", value)?;
263 }
264 if let Some(value) = &self.daemon_endpoints {
265 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "daemonEndpoints", value)?;
266 }
267 if let Some(value) = &self.declared_features {
268 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "declaredFeatures", value)?;
269 }
270 if let Some(value) = &self.features {
271 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "features", value)?;
272 }
273 if let Some(value) = &self.images {
274 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "images", value)?;
275 }
276 if let Some(value) = &self.node_info {
277 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "nodeInfo", value)?;
278 }
279 if let Some(value) = &self.phase {
280 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "phase", value)?;
281 }
282 if let Some(value) = &self.runtime_handlers {
283 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "runtimeHandlers", value)?;
284 }
285 if let Some(value) = &self.volumes_attached {
286 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "volumesAttached", value)?;
287 }
288 if let Some(value) = &self.volumes_in_use {
289 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "volumesInUse", value)?;
290 }
291 crate::serde::ser::SerializeStruct::end(state)
292 }
293}
294
295#[cfg(feature = "schemars")]
296impl crate::schemars::JsonSchema for NodeStatus {
297 fn schema_name() -> std::borrow::Cow<'static, str> {
298 "io.k8s.api.core.v1.NodeStatus".into()
299 }
300
301 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
302 crate::schemars::json_schema!({
303 "description": "NodeStatus is information about the current status of a node.",
304 "type": "object",
305 "properties": {
306 "addresses": {
307 "description": "List of addresses reachable to the node. Queried from cloud provider, if available. More info: https://kubernetes.io/docs/reference/node/node-status/#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).",
308 "type": "array",
309 "items": (__gen.subschema_for::<crate::api::core::v1::NodeAddress>()),
310 },
311 "allocatable": {
312 "description": "Allocatable represents the resources of a node that are available for scheduling. Defaults to Capacity.",
313 "type": "object",
314 "additionalProperties": (__gen.subschema_for::<crate::apimachinery::pkg::api::resource::Quantity>()),
315 },
316 "capacity": {
317 "description": "Capacity represents the total resources of a node. More info: https://kubernetes.io/docs/reference/node/node-status/#capacity",
318 "type": "object",
319 "additionalProperties": (__gen.subschema_for::<crate::apimachinery::pkg::api::resource::Quantity>()),
320 },
321 "conditions": {
322 "description": "Conditions is an array of current observed node conditions. More info: https://kubernetes.io/docs/reference/node/node-status/#condition",
323 "type": "array",
324 "items": (__gen.subschema_for::<crate::api::core::v1::NodeCondition>()),
325 },
326 "config": ({
327 let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::NodeConfigStatus>();
328 schema_obj.ensure_object().insert("description".into(), "Status of the config assigned to the node via the dynamic Kubelet config feature.".into());
329 schema_obj
330 }),
331 "daemonEndpoints": ({
332 let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::NodeDaemonEndpoints>();
333 schema_obj.ensure_object().insert("description".into(), "Endpoints of daemons running on the Node.".into());
334 schema_obj
335 }),
336 "declaredFeatures": {
337 "description": "DeclaredFeatures represents the features related to feature gates that are declared by the node.",
338 "type": "array",
339 "items": {
340 "type": "string",
341 },
342 },
343 "features": ({
344 let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::NodeFeatures>();
345 schema_obj.ensure_object().insert("description".into(), "Features describes the set of features implemented by the CRI implementation.".into());
346 schema_obj
347 }),
348 "images": {
349 "description": "List of container images on this node",
350 "type": "array",
351 "items": (__gen.subschema_for::<crate::api::core::v1::ContainerImage>()),
352 },
353 "nodeInfo": ({
354 let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::NodeSystemInfo>();
355 schema_obj.ensure_object().insert("description".into(), "Set of ids/uuids to uniquely identify the node. More info: https://kubernetes.io/docs/reference/node/node-status/#info".into());
356 schema_obj
357 }),
358 "phase": {
359 "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.",
360 "type": "string",
361 },
362 "runtimeHandlers": {
363 "description": "The available runtime handlers.",
364 "type": "array",
365 "items": (__gen.subschema_for::<crate::api::core::v1::NodeRuntimeHandler>()),
366 },
367 "volumesAttached": {
368 "description": "List of volumes that are attached to the node.",
369 "type": "array",
370 "items": (__gen.subschema_for::<crate::api::core::v1::AttachedVolume>()),
371 },
372 "volumesInUse": {
373 "description": "List of attachable volumes in use (mounted) by the node.",
374 "type": "array",
375 "items": {
376 "type": "string",
377 },
378 },
379 },
380 })
381 }
382}