openshift_openapi/v4_5/api/apps/v1/
deployment_strategy.rs

1// Generated from definition com.github.openshift.api.apps.v1.DeploymentStrategy
2
3/// DeploymentStrategy describes how to perform a deployment.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct DeploymentStrategy {
6    /// ActiveDeadlineSeconds is the duration in seconds that the deployer pods for this deployment config may be active on a node before the system actively tries to terminate them.
7    pub active_deadline_seconds: Option<i64>,
8
9    /// Annotations is a set of key, value pairs added to custom deployer and lifecycle pre/post hook pods.
10    pub annotations: Option<std::collections::BTreeMap<String, String>>,
11
12    /// CustomParams are the input to the Custom deployment strategy, and may also be specified for the Recreate and Rolling strategies to customize the execution process that runs the deployment.
13    pub custom_params: Option<crate::api::apps::v1::CustomDeploymentStrategyParams>,
14
15    /// Labels is a set of key, value pairs added to custom deployer and lifecycle pre/post hook pods.
16    pub labels: Option<std::collections::BTreeMap<String, String>>,
17
18    /// RecreateParams are the input to the Recreate deployment strategy.
19    pub recreate_params: Option<crate::api::apps::v1::RecreateDeploymentStrategyParams>,
20
21    /// Resources contains resource requirements to execute the deployment and any hooks.
22    pub resources: Option<k8s_openapi::api::core::v1::ResourceRequirements>,
23
24    /// RollingParams are the input to the Rolling deployment strategy.
25    pub rolling_params: Option<crate::api::apps::v1::RollingDeploymentStrategyParams>,
26
27    /// Type is the name of a deployment strategy.
28    pub type_: Option<String>,
29}
30
31impl<'de> serde::Deserialize<'de> for DeploymentStrategy {
32    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
33        #[allow(non_camel_case_types)]
34        enum Field {
35            Key_active_deadline_seconds,
36            Key_annotations,
37            Key_custom_params,
38            Key_labels,
39            Key_recreate_params,
40            Key_resources,
41            Key_rolling_params,
42            Key_type_,
43            Other,
44        }
45
46        impl<'de> serde::Deserialize<'de> for Field {
47            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
48                struct Visitor;
49
50                impl<'de> serde::de::Visitor<'de> for Visitor {
51                    type Value = Field;
52
53                    fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
54                        f.write_str("field identifier")
55                    }
56
57                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: serde::de::Error {
58                        Ok(match v {
59                            "activeDeadlineSeconds" => Field::Key_active_deadline_seconds,
60                            "annotations" => Field::Key_annotations,
61                            "customParams" => Field::Key_custom_params,
62                            "labels" => Field::Key_labels,
63                            "recreateParams" => Field::Key_recreate_params,
64                            "resources" => Field::Key_resources,
65                            "rollingParams" => Field::Key_rolling_params,
66                            "type" => Field::Key_type_,
67                            _ => Field::Other,
68                        })
69                    }
70                }
71
72                deserializer.deserialize_identifier(Visitor)
73            }
74        }
75
76        struct Visitor;
77
78        impl<'de> serde::de::Visitor<'de> for Visitor {
79            type Value = DeploymentStrategy;
80
81            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
82                f.write_str("DeploymentStrategy")
83            }
84
85            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: serde::de::MapAccess<'de> {
86                let mut value_active_deadline_seconds: Option<i64> = None;
87                let mut value_annotations: Option<std::collections::BTreeMap<String, String>> = None;
88                let mut value_custom_params: Option<crate::api::apps::v1::CustomDeploymentStrategyParams> = None;
89                let mut value_labels: Option<std::collections::BTreeMap<String, String>> = None;
90                let mut value_recreate_params: Option<crate::api::apps::v1::RecreateDeploymentStrategyParams> = None;
91                let mut value_resources: Option<k8s_openapi::api::core::v1::ResourceRequirements> = None;
92                let mut value_rolling_params: Option<crate::api::apps::v1::RollingDeploymentStrategyParams> = None;
93                let mut value_type_: Option<String> = None;
94
95                while let Some(key) = serde::de::MapAccess::next_key::<Field>(&mut map)? {
96                    match key {
97                        Field::Key_active_deadline_seconds => value_active_deadline_seconds = serde::de::MapAccess::next_value(&mut map)?,
98                        Field::Key_annotations => value_annotations = serde::de::MapAccess::next_value(&mut map)?,
99                        Field::Key_custom_params => value_custom_params = serde::de::MapAccess::next_value(&mut map)?,
100                        Field::Key_labels => value_labels = serde::de::MapAccess::next_value(&mut map)?,
101                        Field::Key_recreate_params => value_recreate_params = serde::de::MapAccess::next_value(&mut map)?,
102                        Field::Key_resources => value_resources = serde::de::MapAccess::next_value(&mut map)?,
103                        Field::Key_rolling_params => value_rolling_params = serde::de::MapAccess::next_value(&mut map)?,
104                        Field::Key_type_ => value_type_ = serde::de::MapAccess::next_value(&mut map)?,
105                        Field::Other => { let _: serde::de::IgnoredAny = serde::de::MapAccess::next_value(&mut map)?; },
106                    }
107                }
108
109                Ok(DeploymentStrategy {
110                    active_deadline_seconds: value_active_deadline_seconds,
111                    annotations: value_annotations,
112                    custom_params: value_custom_params,
113                    labels: value_labels,
114                    recreate_params: value_recreate_params,
115                    resources: value_resources,
116                    rolling_params: value_rolling_params,
117                    type_: value_type_,
118                })
119            }
120        }
121
122        deserializer.deserialize_struct(
123            "DeploymentStrategy",
124            &[
125                "activeDeadlineSeconds",
126                "annotations",
127                "customParams",
128                "labels",
129                "recreateParams",
130                "resources",
131                "rollingParams",
132                "type",
133            ],
134            Visitor,
135        )
136    }
137}
138
139impl serde::Serialize for DeploymentStrategy {
140    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
141        let mut state = serializer.serialize_struct(
142            "DeploymentStrategy",
143            self.active_deadline_seconds.as_ref().map_or(0, |_| 1) +
144            self.annotations.as_ref().map_or(0, |_| 1) +
145            self.custom_params.as_ref().map_or(0, |_| 1) +
146            self.labels.as_ref().map_or(0, |_| 1) +
147            self.recreate_params.as_ref().map_or(0, |_| 1) +
148            self.resources.as_ref().map_or(0, |_| 1) +
149            self.rolling_params.as_ref().map_or(0, |_| 1) +
150            self.type_.as_ref().map_or(0, |_| 1),
151        )?;
152        if let Some(value) = &self.active_deadline_seconds {
153            serde::ser::SerializeStruct::serialize_field(&mut state, "activeDeadlineSeconds", value)?;
154        }
155        if let Some(value) = &self.annotations {
156            serde::ser::SerializeStruct::serialize_field(&mut state, "annotations", value)?;
157        }
158        if let Some(value) = &self.custom_params {
159            serde::ser::SerializeStruct::serialize_field(&mut state, "customParams", value)?;
160        }
161        if let Some(value) = &self.labels {
162            serde::ser::SerializeStruct::serialize_field(&mut state, "labels", value)?;
163        }
164        if let Some(value) = &self.recreate_params {
165            serde::ser::SerializeStruct::serialize_field(&mut state, "recreateParams", value)?;
166        }
167        if let Some(value) = &self.resources {
168            serde::ser::SerializeStruct::serialize_field(&mut state, "resources", value)?;
169        }
170        if let Some(value) = &self.rolling_params {
171            serde::ser::SerializeStruct::serialize_field(&mut state, "rollingParams", value)?;
172        }
173        if let Some(value) = &self.type_ {
174            serde::ser::SerializeStruct::serialize_field(&mut state, "type", value)?;
175        }
176        serde::ser::SerializeStruct::end(state)
177    }
178}