k8s_openapi/v1_37/api/lifecycle/v1alpha1/
eviction_request_status.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct EvictionRequestStatus {
6 pub conditions: Option<std::vec::Vec<crate::apimachinery::pkg::apis::meta::v1::Condition>>,
17
18 pub observed_generation: Option<i64>,
20}
21
22impl crate::DeepMerge for EvictionRequestStatus {
23 fn merge_from(&mut self, other: Self) {
24 crate::merge_strategies::list::map(
25 &mut self.conditions,
26 other.conditions,
27 &[|lhs, rhs| lhs.type_ == rhs.type_],
28 |current_item, other_item| {
29 crate::DeepMerge::merge_from(current_item, other_item);
30 },
31 );
32 crate::DeepMerge::merge_from(&mut self.observed_generation, other.observed_generation);
33 }
34}
35
36impl<'de> crate::serde::Deserialize<'de> for EvictionRequestStatus {
37 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
38 #[allow(non_camel_case_types)]
39 enum Field {
40 Key_conditions,
41 Key_observed_generation,
42 Other,
43 }
44
45 impl<'de> crate::serde::Deserialize<'de> for Field {
46 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
47 struct Visitor;
48
49 impl crate::serde::de::Visitor<'_> for Visitor {
50 type Value = Field;
51
52 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
53 f.write_str("field identifier")
54 }
55
56 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
57 Ok(match v {
58 "conditions" => Field::Key_conditions,
59 "observedGeneration" => Field::Key_observed_generation,
60 _ => Field::Other,
61 })
62 }
63 }
64
65 deserializer.deserialize_identifier(Visitor)
66 }
67 }
68
69 struct Visitor;
70
71 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
72 type Value = EvictionRequestStatus;
73
74 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
75 f.write_str("EvictionRequestStatus")
76 }
77
78 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
79 let mut value_conditions: Option<std::vec::Vec<crate::apimachinery::pkg::apis::meta::v1::Condition>> = None;
80 let mut value_observed_generation: Option<i64> = None;
81
82 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
83 match key {
84 Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
85 Field::Key_observed_generation => value_observed_generation = 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(EvictionRequestStatus {
91 conditions: value_conditions,
92 observed_generation: value_observed_generation,
93 })
94 }
95 }
96
97 deserializer.deserialize_struct(
98 "EvictionRequestStatus",
99 &[
100 "conditions",
101 "observedGeneration",
102 ],
103 Visitor,
104 )
105 }
106}
107
108impl crate::serde::Serialize for EvictionRequestStatus {
109 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
110 let mut state = serializer.serialize_struct(
111 "EvictionRequestStatus",
112 self.conditions.as_ref().map_or(0, |_| 1) +
113 self.observed_generation.as_ref().map_or(0, |_| 1),
114 )?;
115 if let Some(value) = &self.conditions {
116 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
117 }
118 if let Some(value) = &self.observed_generation {
119 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "observedGeneration", value)?;
120 }
121 crate::serde::ser::SerializeStruct::end(state)
122 }
123}
124
125#[cfg(feature = "schemars")]
126impl crate::schemars::JsonSchema for EvictionRequestStatus {
127 fn schema_name() -> std::borrow::Cow<'static, str> {
128 "io.k8s.api.lifecycle.v1alpha1.EvictionRequestStatus".into()
129 }
130
131 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
132 crate::schemars::json_schema!({
133 "description": "EvictionRequestStatus represents the last observed status of the eviction request.",
134 "type": "object",
135 "properties": {
136 "conditions": {
137 "description": "conditions contain information about the eviction request.\n\nEvictionRequest specific conditions are: TargetEvicted or Failed (managed by evictionrequest-controller). - Failed means that the eviction request is no longer being processed\n by any eviction responder. This can happen if the request is canceled or if no responder\n managed to evict the target (e.g. terminate or delete a pod).\n- TargetEvicted means that the target has been evicted (e.g. a pod has been terminated or deleted).\n\nThese conditions can be reset if the eviction was unsuccessful and a new Eviction intent has been submitted.\n\nThe maximum length of the conditions list is 100.",
138 "type": "array",
139 "items": (__gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Condition>()),
140 },
141 "observedGeneration": {
142 "description": "observedGeneration is EvictionRequest's .metadata.generation observed by the evictionrequest-controller. The observed generation value cannot be negative and can only be incremented. The minimum value is 1. This field is managed by evictionrequest-controller.",
143 "type": "integer",
144 "format": "int64",
145 },
146 },
147 })
148 }
149}