Skip to main content

k8s_openapi/v1_36/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 a beta field and requires enabling DeploymentReplicaSetTerminatingReplicas feature (enabled by default).
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::borrow::Cow<'static, str> {
219        "io.k8s.api.apps.v1.DeploymentStatus".into()
220    }
221
222    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
223        crate::schemars::json_schema!({
224            "description": "DeploymentStatus is the most recently observed status of the Deployment.",
225            "type": "object",
226            "properties": {
227                "availableReplicas": {
228                    "description": "Total number of available non-terminating pods (ready for at least minReadySeconds) targeted by this deployment.",
229                    "type": "integer",
230                    "format": "int32",
231                },
232                "collisionCount": {
233                    "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.",
234                    "type": "integer",
235                    "format": "int32",
236                },
237                "conditions": {
238                    "description": "Represents the latest available observations of a deployment's current state.",
239                    "type": "array",
240                    "items": (__gen.subschema_for::<crate::api::apps::v1::DeploymentCondition>()),
241                },
242                "observedGeneration": {
243                    "description": "The generation observed by the deployment controller.",
244                    "type": "integer",
245                    "format": "int64",
246                },
247                "readyReplicas": {
248                    "description": "Total number of non-terminating pods targeted by this Deployment with a Ready Condition.",
249                    "type": "integer",
250                    "format": "int32",
251                },
252                "replicas": {
253                    "description": "Total number of non-terminating pods targeted by this deployment (their labels match the selector).",
254                    "type": "integer",
255                    "format": "int32",
256                },
257                "terminatingReplicas": {
258                    "description": "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 a beta field and requires enabling DeploymentReplicaSetTerminatingReplicas feature (enabled by default).",
259                    "type": "integer",
260                    "format": "int32",
261                },
262                "unavailableReplicas": {
263                    "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.",
264                    "type": "integer",
265                    "format": "int32",
266                },
267                "updatedReplicas": {
268                    "description": "Total number of non-terminating pods targeted by this deployment that have the desired template spec.",
269                    "type": "integer",
270                    "format": "int32",
271                },
272            },
273        })
274    }
275}
276
277#[cfg(feature = "schemars08")]
278impl crate::schemars08::JsonSchema for DeploymentStatus {
279    fn schema_name() -> std::string::String {
280        "io.k8s.api.apps.v1.DeploymentStatus".into()
281    }
282
283    fn json_schema(__gen: &mut crate::schemars08::gen::SchemaGenerator) -> crate::schemars08::schema::Schema {
284        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
285            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
286                description: Some("DeploymentStatus is the most recently observed status of the Deployment.".into()),
287                ..Default::default()
288            })),
289            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Object))),
290            object: Some(std::boxed::Box::new(crate::schemars08::schema::ObjectValidation {
291                properties: [
292                    (
293                        "availableReplicas".into(),
294                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
295                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
296                                description: Some("Total number of available non-terminating pods (ready for at least minReadySeconds) targeted by this deployment.".into()),
297                                ..Default::default()
298                            })),
299                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
300                            format: Some("int32".into()),
301                            ..Default::default()
302                        }),
303                    ),
304                    (
305                        "collisionCount".into(),
306                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
307                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
308                                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()),
309                                ..Default::default()
310                            })),
311                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
312                            format: Some("int32".into()),
313                            ..Default::default()
314                        }),
315                    ),
316                    (
317                        "conditions".into(),
318                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
319                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
320                                description: Some("Represents the latest available observations of a deployment's current state.".into()),
321                                ..Default::default()
322                            })),
323                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Array))),
324                            array: Some(std::boxed::Box::new(crate::schemars08::schema::ArrayValidation {
325                                items: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(__gen.subschema_for::<crate::api::apps::v1::DeploymentCondition>()))),
326                                ..Default::default()
327                            })),
328                            ..Default::default()
329                        }),
330                    ),
331                    (
332                        "observedGeneration".into(),
333                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
334                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
335                                description: Some("The generation observed by the deployment controller.".into()),
336                                ..Default::default()
337                            })),
338                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
339                            format: Some("int64".into()),
340                            ..Default::default()
341                        }),
342                    ),
343                    (
344                        "readyReplicas".into(),
345                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
346                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
347                                description: Some("Total number of non-terminating pods targeted by this Deployment with a Ready Condition.".into()),
348                                ..Default::default()
349                            })),
350                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
351                            format: Some("int32".into()),
352                            ..Default::default()
353                        }),
354                    ),
355                    (
356                        "replicas".into(),
357                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
358                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
359                                description: Some("Total number of non-terminating pods targeted by this deployment (their labels match the selector).".into()),
360                                ..Default::default()
361                            })),
362                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
363                            format: Some("int32".into()),
364                            ..Default::default()
365                        }),
366                    ),
367                    (
368                        "terminatingReplicas".into(),
369                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
370                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
371                                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 a beta field and requires enabling DeploymentReplicaSetTerminatingReplicas feature (enabled by default).".into()),
372                                ..Default::default()
373                            })),
374                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
375                            format: Some("int32".into()),
376                            ..Default::default()
377                        }),
378                    ),
379                    (
380                        "unavailableReplicas".into(),
381                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
382                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
383                                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()),
384                                ..Default::default()
385                            })),
386                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
387                            format: Some("int32".into()),
388                            ..Default::default()
389                        }),
390                    ),
391                    (
392                        "updatedReplicas".into(),
393                        crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
394                            metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
395                                description: Some("Total number of non-terminating pods targeted by this deployment that have the desired template spec.".into()),
396                                ..Default::default()
397                            })),
398                            instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Integer))),
399                            format: Some("int32".into()),
400                            ..Default::default()
401                        }),
402                    ),
403                ].into(),
404                ..Default::default()
405            })),
406            ..Default::default()
407        })
408    }
409}