k8s_openapi/v1_33/api/apps/v1/
deployment_status.rs

1// Generated from definition io.k8s.api.apps.v1.DeploymentStatus
2
3/// DeploymentStatus is the most recently observed status of the Deployment.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct DeploymentStatus {
6    /// Total number of available non-terminating pods (ready for at least minReadySeconds) targeted by this deployment.
7    pub available_replicas: Option<i32>,
8
9    /// 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.
10    pub collision_count: Option<i32>,
11
12    /// Represents the latest available observations of a deployment's current state.
13    pub conditions: Option<std::vec::Vec<crate::api::apps::v1::DeploymentCondition>>,
14
15    /// The generation observed by the deployment controller.
16    pub observed_generation: Option<i64>,
17
18    /// Total number of non-terminating pods targeted by this Deployment with a Ready Condition.
19    pub ready_replicas: Option<i32>,
20
21    /// Total number of non-terminating pods targeted by this deployment (their labels match the selector).
22    pub replicas: Option<i32>,
23
24    /// Total number of terminating pods targeted by this deployment. Terminating pods have a non-null .metadata.deletionTimestamp and have not yet reached the Failed or Succeeded .status.phase.
25    ///
26    /// This is an alpha field. Enable DeploymentReplicaSetTerminatingReplicas to be able to use this field.
27    pub terminating_replicas: Option<i32>,
28
29    /// 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.
30    pub unavailable_replicas: Option<i32>,
31
32    /// Total number of non-terminating pods targeted by this deployment that have the desired template spec.
33    pub updated_replicas: Option<i32>,
34}
35
36impl crate::DeepMerge for DeploymentStatus {
37    fn merge_from(&mut self, other: Self) {
38        crate::DeepMerge::merge_from(&mut self.available_replicas, other.available_replicas);
39        crate::DeepMerge::merge_from(&mut self.collision_count, other.collision_count);
40        crate::merge_strategies::list::map(
41            &mut self.conditions,
42            other.conditions,
43            &[|lhs, rhs| lhs.type_ == rhs.type_],
44            |current_item, other_item| {
45                crate::DeepMerge::merge_from(current_item, other_item);
46            },
47        );
48        crate::DeepMerge::merge_from(&mut self.observed_generation, other.observed_generation);
49        crate::DeepMerge::merge_from(&mut self.ready_replicas, other.ready_replicas);
50        crate::DeepMerge::merge_from(&mut self.replicas, other.replicas);
51        crate::DeepMerge::merge_from(&mut self.terminating_replicas, other.terminating_replicas);
52        crate::DeepMerge::merge_from(&mut self.unavailable_replicas, other.unavailable_replicas);
53        crate::DeepMerge::merge_from(&mut self.updated_replicas, other.updated_replicas);
54    }
55}
56
57impl<'de> crate::serde::Deserialize<'de> for DeploymentStatus {
58    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
59        #[allow(non_camel_case_types)]
60        enum Field {
61            Key_available_replicas,
62            Key_collision_count,
63            Key_conditions,
64            Key_observed_generation,
65            Key_ready_replicas,
66            Key_replicas,
67            Key_terminating_replicas,
68            Key_unavailable_replicas,
69            Key_updated_replicas,
70            Other,
71        }
72
73        impl<'de> crate::serde::Deserialize<'de> for Field {
74            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
75                struct Visitor;
76
77                impl crate::serde::de::Visitor<'_> for Visitor {
78                    type Value = Field;
79
80                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
81                        f.write_str("field identifier")
82                    }
83
84                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
85                        Ok(match v {
86                            "availableReplicas" => Field::Key_available_replicas,
87                            "collisionCount" => Field::Key_collision_count,
88                            "conditions" => Field::Key_conditions,
89                            "observedGeneration" => Field::Key_observed_generation,
90                            "readyReplicas" => Field::Key_ready_replicas,
91                            "replicas" => Field::Key_replicas,
92                            "terminatingReplicas" => Field::Key_terminating_replicas,
93                            "unavailableReplicas" => Field::Key_unavailable_replicas,
94                            "updatedReplicas" => Field::Key_updated_replicas,
95                            _ => Field::Other,
96                        })
97                    }
98                }
99
100                deserializer.deserialize_identifier(Visitor)
101            }
102        }
103
104        struct Visitor;
105
106        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
107            type Value = DeploymentStatus;
108
109            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
110                f.write_str("DeploymentStatus")
111            }
112
113            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
114                let mut value_available_replicas: Option<i32> = None;
115                let mut value_collision_count: Option<i32> = None;
116                let mut value_conditions: Option<std::vec::Vec<crate::api::apps::v1::DeploymentCondition>> = None;
117                let mut value_observed_generation: Option<i64> = None;
118                let mut value_ready_replicas: Option<i32> = None;
119                let mut value_replicas: Option<i32> = None;
120                let mut value_terminating_replicas: Option<i32> = None;
121                let mut value_unavailable_replicas: Option<i32> = None;
122                let mut value_updated_replicas: Option<i32> = None;
123
124                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
125                    match key {
126                        Field::Key_available_replicas => value_available_replicas = crate::serde::de::MapAccess::next_value(&mut map)?,
127                        Field::Key_collision_count => value_collision_count = crate::serde::de::MapAccess::next_value(&mut map)?,
128                        Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
129                        Field::Key_observed_generation => value_observed_generation = crate::serde::de::MapAccess::next_value(&mut map)?,
130                        Field::Key_ready_replicas => value_ready_replicas = crate::serde::de::MapAccess::next_value(&mut map)?,
131                        Field::Key_replicas => value_replicas = crate::serde::de::MapAccess::next_value(&mut map)?,
132                        Field::Key_terminating_replicas => value_terminating_replicas = crate::serde::de::MapAccess::next_value(&mut map)?,
133                        Field::Key_unavailable_replicas => value_unavailable_replicas = crate::serde::de::MapAccess::next_value(&mut map)?,
134                        Field::Key_updated_replicas => value_updated_replicas = crate::serde::de::MapAccess::next_value(&mut map)?,
135                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
136                    }
137                }
138
139                Ok(DeploymentStatus {
140                    available_replicas: value_available_replicas,
141                    collision_count: value_collision_count,
142                    conditions: value_conditions,
143                    observed_generation: value_observed_generation,
144                    ready_replicas: value_ready_replicas,
145                    replicas: value_replicas,
146                    terminating_replicas: value_terminating_replicas,
147                    unavailable_replicas: value_unavailable_replicas,
148                    updated_replicas: value_updated_replicas,
149                })
150            }
151        }
152
153        deserializer.deserialize_struct(
154            "DeploymentStatus",
155            &[
156                "availableReplicas",
157                "collisionCount",
158                "conditions",
159                "observedGeneration",
160                "readyReplicas",
161                "replicas",
162                "terminatingReplicas",
163                "unavailableReplicas",
164                "updatedReplicas",
165            ],
166            Visitor,
167        )
168    }
169}
170
171impl crate::serde::Serialize for DeploymentStatus {
172    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
173        let mut state = serializer.serialize_struct(
174            "DeploymentStatus",
175            self.available_replicas.as_ref().map_or(0, |_| 1) +
176            self.collision_count.as_ref().map_or(0, |_| 1) +
177            self.conditions.as_ref().map_or(0, |_| 1) +
178            self.observed_generation.as_ref().map_or(0, |_| 1) +
179            self.ready_replicas.as_ref().map_or(0, |_| 1) +
180            self.replicas.as_ref().map_or(0, |_| 1) +
181            self.terminating_replicas.as_ref().map_or(0, |_| 1) +
182            self.unavailable_replicas.as_ref().map_or(0, |_| 1) +
183            self.updated_replicas.as_ref().map_or(0, |_| 1),
184        )?;
185        if let Some(value) = &self.available_replicas {
186            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "availableReplicas", value)?;
187        }
188        if let Some(value) = &self.collision_count {
189            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "collisionCount", value)?;
190        }
191        if let Some(value) = &self.conditions {
192            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
193        }
194        if let Some(value) = &self.observed_generation {
195            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "observedGeneration", value)?;
196        }
197        if let Some(value) = &self.ready_replicas {
198            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readyReplicas", value)?;
199        }
200        if let Some(value) = &self.replicas {
201            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "replicas", value)?;
202        }
203        if let Some(value) = &self.terminating_replicas {
204            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "terminatingReplicas", value)?;
205        }
206        if let Some(value) = &self.unavailable_replicas {
207            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "unavailableReplicas", value)?;
208        }
209        if let Some(value) = &self.updated_replicas {
210            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "updatedReplicas", value)?;
211        }
212        crate::serde::ser::SerializeStruct::end(state)
213    }
214}
215
216#[cfg(feature = "schemars")]
217impl crate::schemars::JsonSchema for DeploymentStatus {
218    fn schema_name() -> std::string::String {
219        "io.k8s.api.apps.v1.DeploymentStatus".into()
220    }
221
222    fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
223        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
224            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
225                description: Some("DeploymentStatus is the most recently observed status of the Deployment.".into()),
226                ..Default::default()
227            })),
228            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
229            object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
230                properties: [
231                    (
232                        "availableReplicas".into(),
233                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
234                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
235                                description: Some("Total number of available non-terminating pods (ready for at least minReadySeconds) targeted by this deployment.".into()),
236                                ..Default::default()
237                            })),
238                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
239                            format: Some("int32".into()),
240                            ..Default::default()
241                        }),
242                    ),
243                    (
244                        "collisionCount".into(),
245                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
246                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
247                                description: Some("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.".into()),
248                                ..Default::default()
249                            })),
250                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
251                            format: Some("int32".into()),
252                            ..Default::default()
253                        }),
254                    ),
255                    (
256                        "conditions".into(),
257                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
258                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
259                                description: Some("Represents the latest available observations of a deployment's current state.".into()),
260                                ..Default::default()
261                            })),
262                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Array))),
263                            array: Some(std::boxed::Box::new(crate::schemars::schema::ArrayValidation {
264                                items: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(__gen.subschema_for::<crate::api::apps::v1::DeploymentCondition>()))),
265                                ..Default::default()
266                            })),
267                            ..Default::default()
268                        }),
269                    ),
270                    (
271                        "observedGeneration".into(),
272                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
273                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
274                                description: Some("The generation observed by the deployment controller.".into()),
275                                ..Default::default()
276                            })),
277                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
278                            format: Some("int64".into()),
279                            ..Default::default()
280                        }),
281                    ),
282                    (
283                        "readyReplicas".into(),
284                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
285                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
286                                description: Some("Total number of non-terminating pods targeted by this Deployment with a Ready Condition.".into()),
287                                ..Default::default()
288                            })),
289                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
290                            format: Some("int32".into()),
291                            ..Default::default()
292                        }),
293                    ),
294                    (
295                        "replicas".into(),
296                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
297                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
298                                description: Some("Total number of non-terminating pods targeted by this deployment (their labels match the selector).".into()),
299                                ..Default::default()
300                            })),
301                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
302                            format: Some("int32".into()),
303                            ..Default::default()
304                        }),
305                    ),
306                    (
307                        "terminatingReplicas".into(),
308                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
309                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
310                                description: Some("Total number of terminating pods targeted by this deployment. Terminating pods have a non-null .metadata.deletionTimestamp and have not yet reached the Failed or Succeeded .status.phase.\n\nThis is an alpha field. Enable DeploymentReplicaSetTerminatingReplicas to be able to use this field.".into()),
311                                ..Default::default()
312                            })),
313                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
314                            format: Some("int32".into()),
315                            ..Default::default()
316                        }),
317                    ),
318                    (
319                        "unavailableReplicas".into(),
320                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
321                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
322                                description: Some("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.".into()),
323                                ..Default::default()
324                            })),
325                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
326                            format: Some("int32".into()),
327                            ..Default::default()
328                        }),
329                    ),
330                    (
331                        "updatedReplicas".into(),
332                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
333                            metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
334                                description: Some("Total number of non-terminating pods targeted by this deployment that have the desired template spec.".into()),
335                                ..Default::default()
336                            })),
337                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
338                            format: Some("int32".into()),
339                            ..Default::default()
340                        }),
341                    ),
342                ].into(),
343                ..Default::default()
344            })),
345            ..Default::default()
346        })
347    }
348}