k8s_openapi/v1_30/api/apps/v1/
deployment_status.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct DeploymentStatus {
6 pub available_replicas: Option<i32>,
8
9 pub collision_count: Option<i32>,
11
12 pub conditions: Option<std::vec::Vec<crate::api::apps::v1::DeploymentCondition>>,
14
15 pub observed_generation: Option<i64>,
17
18 pub ready_replicas: Option<i32>,
20
21 pub replicas: Option<i32>,
23
24 pub unavailable_replicas: Option<i32>,
26
27 pub updated_replicas: Option<i32>,
29}
30
31impl crate::DeepMerge for DeploymentStatus {
32 fn merge_from(&mut self, other: Self) {
33 crate::DeepMerge::merge_from(&mut self.available_replicas, other.available_replicas);
34 crate::DeepMerge::merge_from(&mut self.collision_count, other.collision_count);
35 crate::merge_strategies::list::map(
36 &mut self.conditions,
37 other.conditions,
38 &[|lhs, rhs| lhs.type_ == rhs.type_],
39 |current_item, other_item| {
40 crate::DeepMerge::merge_from(current_item, other_item);
41 },
42 );
43 crate::DeepMerge::merge_from(&mut self.observed_generation, other.observed_generation);
44 crate::DeepMerge::merge_from(&mut self.ready_replicas, other.ready_replicas);
45 crate::DeepMerge::merge_from(&mut self.replicas, other.replicas);
46 crate::DeepMerge::merge_from(&mut self.unavailable_replicas, other.unavailable_replicas);
47 crate::DeepMerge::merge_from(&mut self.updated_replicas, other.updated_replicas);
48 }
49}
50
51impl<'de> crate::serde::Deserialize<'de> for DeploymentStatus {
52 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
53 #[allow(non_camel_case_types)]
54 enum Field {
55 Key_available_replicas,
56 Key_collision_count,
57 Key_conditions,
58 Key_observed_generation,
59 Key_ready_replicas,
60 Key_replicas,
61 Key_unavailable_replicas,
62 Key_updated_replicas,
63 Other,
64 }
65
66 impl<'de> crate::serde::Deserialize<'de> for Field {
67 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
68 struct Visitor;
69
70 impl crate::serde::de::Visitor<'_> for Visitor {
71 type Value = Field;
72
73 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
74 f.write_str("field identifier")
75 }
76
77 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
78 Ok(match v {
79 "availableReplicas" => Field::Key_available_replicas,
80 "collisionCount" => Field::Key_collision_count,
81 "conditions" => Field::Key_conditions,
82 "observedGeneration" => Field::Key_observed_generation,
83 "readyReplicas" => Field::Key_ready_replicas,
84 "replicas" => Field::Key_replicas,
85 "unavailableReplicas" => Field::Key_unavailable_replicas,
86 "updatedReplicas" => Field::Key_updated_replicas,
87 _ => Field::Other,
88 })
89 }
90 }
91
92 deserializer.deserialize_identifier(Visitor)
93 }
94 }
95
96 struct Visitor;
97
98 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
99 type Value = DeploymentStatus;
100
101 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
102 f.write_str("DeploymentStatus")
103 }
104
105 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
106 let mut value_available_replicas: Option<i32> = None;
107 let mut value_collision_count: Option<i32> = None;
108 let mut value_conditions: Option<std::vec::Vec<crate::api::apps::v1::DeploymentCondition>> = None;
109 let mut value_observed_generation: Option<i64> = None;
110 let mut value_ready_replicas: Option<i32> = None;
111 let mut value_replicas: Option<i32> = None;
112 let mut value_unavailable_replicas: Option<i32> = None;
113 let mut value_updated_replicas: Option<i32> = None;
114
115 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
116 match key {
117 Field::Key_available_replicas => value_available_replicas = crate::serde::de::MapAccess::next_value(&mut map)?,
118 Field::Key_collision_count => value_collision_count = crate::serde::de::MapAccess::next_value(&mut map)?,
119 Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
120 Field::Key_observed_generation => value_observed_generation = crate::serde::de::MapAccess::next_value(&mut map)?,
121 Field::Key_ready_replicas => value_ready_replicas = crate::serde::de::MapAccess::next_value(&mut map)?,
122 Field::Key_replicas => value_replicas = crate::serde::de::MapAccess::next_value(&mut map)?,
123 Field::Key_unavailable_replicas => value_unavailable_replicas = crate::serde::de::MapAccess::next_value(&mut map)?,
124 Field::Key_updated_replicas => value_updated_replicas = crate::serde::de::MapAccess::next_value(&mut map)?,
125 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
126 }
127 }
128
129 Ok(DeploymentStatus {
130 available_replicas: value_available_replicas,
131 collision_count: value_collision_count,
132 conditions: value_conditions,
133 observed_generation: value_observed_generation,
134 ready_replicas: value_ready_replicas,
135 replicas: value_replicas,
136 unavailable_replicas: value_unavailable_replicas,
137 updated_replicas: value_updated_replicas,
138 })
139 }
140 }
141
142 deserializer.deserialize_struct(
143 "DeploymentStatus",
144 &[
145 "availableReplicas",
146 "collisionCount",
147 "conditions",
148 "observedGeneration",
149 "readyReplicas",
150 "replicas",
151 "unavailableReplicas",
152 "updatedReplicas",
153 ],
154 Visitor,
155 )
156 }
157}
158
159impl crate::serde::Serialize for DeploymentStatus {
160 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
161 let mut state = serializer.serialize_struct(
162 "DeploymentStatus",
163 self.available_replicas.as_ref().map_or(0, |_| 1) +
164 self.collision_count.as_ref().map_or(0, |_| 1) +
165 self.conditions.as_ref().map_or(0, |_| 1) +
166 self.observed_generation.as_ref().map_or(0, |_| 1) +
167 self.ready_replicas.as_ref().map_or(0, |_| 1) +
168 self.replicas.as_ref().map_or(0, |_| 1) +
169 self.unavailable_replicas.as_ref().map_or(0, |_| 1) +
170 self.updated_replicas.as_ref().map_or(0, |_| 1),
171 )?;
172 if let Some(value) = &self.available_replicas {
173 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "availableReplicas", value)?;
174 }
175 if let Some(value) = &self.collision_count {
176 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "collisionCount", value)?;
177 }
178 if let Some(value) = &self.conditions {
179 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
180 }
181 if let Some(value) = &self.observed_generation {
182 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "observedGeneration", value)?;
183 }
184 if let Some(value) = &self.ready_replicas {
185 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readyReplicas", value)?;
186 }
187 if let Some(value) = &self.replicas {
188 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "replicas", value)?;
189 }
190 if let Some(value) = &self.unavailable_replicas {
191 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "unavailableReplicas", value)?;
192 }
193 if let Some(value) = &self.updated_replicas {
194 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "updatedReplicas", value)?;
195 }
196 crate::serde::ser::SerializeStruct::end(state)
197 }
198}
199
200#[cfg(feature = "schemars")]
201impl crate::schemars::JsonSchema for DeploymentStatus {
202 fn schema_name() -> std::borrow::Cow<'static, str> {
203 "io.k8s.api.apps.v1.DeploymentStatus".into()
204 }
205
206 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
207 crate::schemars::json_schema!({
208 "description": "DeploymentStatus is the most recently observed status of the Deployment.",
209 "type": "object",
210 "properties": {
211 "availableReplicas": {
212 "description": "Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.",
213 "type": "integer",
214 "format": "int32",
215 },
216 "collisionCount": {
217 "description": "Count of hash collisions for the Deployment. The Deployment controller uses this field as a collision avoidance mechanism when it needs to create the name for the newest ReplicaSet.",
218 "type": "integer",
219 "format": "int32",
220 },
221 "conditions": {
222 "description": "Represents the latest available observations of a deployment's current state.",
223 "type": "array",
224 "items": (__gen.subschema_for::<crate::api::apps::v1::DeploymentCondition>()),
225 },
226 "observedGeneration": {
227 "description": "The generation observed by the deployment controller.",
228 "type": "integer",
229 "format": "int64",
230 },
231 "readyReplicas": {
232 "description": "readyReplicas is the number of pods targeted by this Deployment with a Ready Condition.",
233 "type": "integer",
234 "format": "int32",
235 },
236 "replicas": {
237 "description": "Total number of non-terminated pods targeted by this deployment (their labels match the selector).",
238 "type": "integer",
239 "format": "int32",
240 },
241 "unavailableReplicas": {
242 "description": "Total number of unavailable pods targeted by this deployment. This is the total number of pods that are still required for the deployment to have 100% available capacity. They may either be pods that are running but not yet available or pods that still have not been created.",
243 "type": "integer",
244 "format": "int32",
245 },
246 "updatedReplicas": {
247 "description": "Total number of non-terminated pods targeted by this deployment that have the desired template spec.",
248 "type": "integer",
249 "format": "int32",
250 },
251 },
252 })
253 }
254}