k8s_openapi/v1_32/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 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<Vec<crate::api::apps::v1::DeploymentCondition>>,
14
15    /// The generation observed by the deployment controller.
16    pub observed_generation: Option<i64>,
17
18    /// readyReplicas is the number of pods targeted by this Deployment with a Ready Condition.
19    pub ready_replicas: Option<i32>,
20
21    /// Total number of non-terminated pods targeted by this deployment (their labels match the selector).
22    pub replicas: Option<i32>,
23
24    /// 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.
25    pub unavailable_replicas: Option<i32>,
26
27    /// Total number of non-terminated pods targeted by this deployment that have the desired template spec.
28    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 std::fmt::Formatter<'_>) -> std::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 std::fmt::Formatter<'_>) -> std::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<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() -> String {
203        "io.k8s.api.apps.v1.DeploymentStatus".to_owned()
204    }
205
206    fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
207        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
208            metadata: Some(Box::new(crate::schemars::schema::Metadata {
209                description: Some("DeploymentStatus is the most recently observed status of the Deployment.".to_owned()),
210                ..Default::default()
211            })),
212            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
213            object: Some(Box::new(crate::schemars::schema::ObjectValidation {
214                properties: [
215                    (
216                        "availableReplicas".to_owned(),
217                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
218                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
219                                description: Some("Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.".to_owned()),
220                                ..Default::default()
221                            })),
222                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Integer))),
223                            format: Some("int32".to_owned()),
224                            ..Default::default()
225                        }),
226                    ),
227                    (
228                        "collisionCount".to_owned(),
229                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
230                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
231                                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.".to_owned()),
232                                ..Default::default()
233                            })),
234                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Integer))),
235                            format: Some("int32".to_owned()),
236                            ..Default::default()
237                        }),
238                    ),
239                    (
240                        "conditions".to_owned(),
241                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
242                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
243                                description: Some("Represents the latest available observations of a deployment's current state.".to_owned()),
244                                ..Default::default()
245                            })),
246                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Array))),
247                            array: Some(Box::new(crate::schemars::schema::ArrayValidation {
248                                items: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(__gen.subschema_for::<crate::api::apps::v1::DeploymentCondition>()))),
249                                ..Default::default()
250                            })),
251                            ..Default::default()
252                        }),
253                    ),
254                    (
255                        "observedGeneration".to_owned(),
256                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
257                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
258                                description: Some("The generation observed by the deployment controller.".to_owned()),
259                                ..Default::default()
260                            })),
261                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Integer))),
262                            format: Some("int64".to_owned()),
263                            ..Default::default()
264                        }),
265                    ),
266                    (
267                        "readyReplicas".to_owned(),
268                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
269                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
270                                description: Some("readyReplicas is the number of pods targeted by this Deployment with a Ready Condition.".to_owned()),
271                                ..Default::default()
272                            })),
273                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Integer))),
274                            format: Some("int32".to_owned()),
275                            ..Default::default()
276                        }),
277                    ),
278                    (
279                        "replicas".to_owned(),
280                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
281                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
282                                description: Some("Total number of non-terminated pods targeted by this deployment (their labels match the selector).".to_owned()),
283                                ..Default::default()
284                            })),
285                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Integer))),
286                            format: Some("int32".to_owned()),
287                            ..Default::default()
288                        }),
289                    ),
290                    (
291                        "unavailableReplicas".to_owned(),
292                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
293                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
294                                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.".to_owned()),
295                                ..Default::default()
296                            })),
297                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Integer))),
298                            format: Some("int32".to_owned()),
299                            ..Default::default()
300                        }),
301                    ),
302                    (
303                        "updatedReplicas".to_owned(),
304                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
305                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
306                                description: Some("Total number of non-terminated pods targeted by this deployment that have the desired template spec.".to_owned()),
307                                ..Default::default()
308                            })),
309                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Integer))),
310                            format: Some("int32".to_owned()),
311                            ..Default::default()
312                        }),
313                    ),
314                ].into(),
315                ..Default::default()
316            })),
317            ..Default::default()
318        })
319    }
320}