#[derive(Clone, Debug, Default, PartialEq)]
pub struct RollingDeploymentStrategyParams {
pub interval_seconds: Option<i64>,
pub max_surge: Option<k8s_openapi::apimachinery::pkg::util::intstr::IntOrString>,
pub max_unavailable: Option<k8s_openapi::apimachinery::pkg::util::intstr::IntOrString>,
pub post: Option<crate::api::apps::v1::LifecycleHook>,
pub pre: Option<crate::api::apps::v1::LifecycleHook>,
pub timeout_seconds: Option<i64>,
pub update_period_seconds: Option<i64>,
}
impl<'de> serde::Deserialize<'de> for RollingDeploymentStrategyParams {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
#[allow(non_camel_case_types)]
enum Field {
Key_interval_seconds,
Key_max_surge,
Key_max_unavailable,
Key_post,
Key_pre,
Key_timeout_seconds,
Key_update_period_seconds,
Other,
}
impl<'de> serde::Deserialize<'de> for Field {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
type Value = Field;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("field identifier")
}
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: serde::de::Error {
Ok(match v {
"intervalSeconds" => Field::Key_interval_seconds,
"maxSurge" => Field::Key_max_surge,
"maxUnavailable" => Field::Key_max_unavailable,
"post" => Field::Key_post,
"pre" => Field::Key_pre,
"timeoutSeconds" => Field::Key_timeout_seconds,
"updatePeriodSeconds" => Field::Key_update_period_seconds,
_ => Field::Other,
})
}
}
deserializer.deserialize_identifier(Visitor)
}
}
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
type Value = RollingDeploymentStrategyParams;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("RollingDeploymentStrategyParams")
}
fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: serde::de::MapAccess<'de> {
let mut value_interval_seconds: Option<i64> = None;
let mut value_max_surge: Option<k8s_openapi::apimachinery::pkg::util::intstr::IntOrString> = None;
let mut value_max_unavailable: Option<k8s_openapi::apimachinery::pkg::util::intstr::IntOrString> = None;
let mut value_post: Option<crate::api::apps::v1::LifecycleHook> = None;
let mut value_pre: Option<crate::api::apps::v1::LifecycleHook> = None;
let mut value_timeout_seconds: Option<i64> = None;
let mut value_update_period_seconds: Option<i64> = None;
while let Some(key) = serde::de::MapAccess::next_key::<Field>(&mut map)? {
match key {
Field::Key_interval_seconds => value_interval_seconds = serde::de::MapAccess::next_value(&mut map)?,
Field::Key_max_surge => value_max_surge = serde::de::MapAccess::next_value(&mut map)?,
Field::Key_max_unavailable => value_max_unavailable = serde::de::MapAccess::next_value(&mut map)?,
Field::Key_post => value_post = serde::de::MapAccess::next_value(&mut map)?,
Field::Key_pre => value_pre = serde::de::MapAccess::next_value(&mut map)?,
Field::Key_timeout_seconds => value_timeout_seconds = serde::de::MapAccess::next_value(&mut map)?,
Field::Key_update_period_seconds => value_update_period_seconds = serde::de::MapAccess::next_value(&mut map)?,
Field::Other => { let _: serde::de::IgnoredAny = serde::de::MapAccess::next_value(&mut map)?; },
}
}
Ok(RollingDeploymentStrategyParams {
interval_seconds: value_interval_seconds,
max_surge: value_max_surge,
max_unavailable: value_max_unavailable,
post: value_post,
pre: value_pre,
timeout_seconds: value_timeout_seconds,
update_period_seconds: value_update_period_seconds,
})
}
}
deserializer.deserialize_struct(
"RollingDeploymentStrategyParams",
&[
"intervalSeconds",
"maxSurge",
"maxUnavailable",
"post",
"pre",
"timeoutSeconds",
"updatePeriodSeconds",
],
Visitor,
)
}
}
impl serde::Serialize for RollingDeploymentStrategyParams {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
let mut state = serializer.serialize_struct(
"RollingDeploymentStrategyParams",
self.interval_seconds.as_ref().map_or(0, |_| 1) +
self.max_surge.as_ref().map_or(0, |_| 1) +
self.max_unavailable.as_ref().map_or(0, |_| 1) +
self.post.as_ref().map_or(0, |_| 1) +
self.pre.as_ref().map_or(0, |_| 1) +
self.timeout_seconds.as_ref().map_or(0, |_| 1) +
self.update_period_seconds.as_ref().map_or(0, |_| 1),
)?;
if let Some(value) = &self.interval_seconds {
serde::ser::SerializeStruct::serialize_field(&mut state, "intervalSeconds", value)?;
}
if let Some(value) = &self.max_surge {
serde::ser::SerializeStruct::serialize_field(&mut state, "maxSurge", value)?;
}
if let Some(value) = &self.max_unavailable {
serde::ser::SerializeStruct::serialize_field(&mut state, "maxUnavailable", value)?;
}
if let Some(value) = &self.post {
serde::ser::SerializeStruct::serialize_field(&mut state, "post", value)?;
}
if let Some(value) = &self.pre {
serde::ser::SerializeStruct::serialize_field(&mut state, "pre", value)?;
}
if let Some(value) = &self.timeout_seconds {
serde::ser::SerializeStruct::serialize_field(&mut state, "timeoutSeconds", value)?;
}
if let Some(value) = &self.update_period_seconds {
serde::ser::SerializeStruct::serialize_field(&mut state, "updatePeriodSeconds", value)?;
}
serde::ser::SerializeStruct::end(state)
}
}