1// Generated from definition io.k8s.api.apps.v1.StatefulSetOrdinals
23/// StatefulSetOrdinals describes the policy used for replica ordinal assignment in this StatefulSet.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct StatefulSetOrdinals {
6/// start is the number representing the first replica's index. It may be used to number replicas from an alternate index (eg: 1-indexed) over the default 0-indexed names, or to orchestrate progressive movement of replicas from one StatefulSet to another. If set, replica indices will be in the range:
7 /// \[.spec.ordinals.start, .spec.ordinals.start + .spec.replicas).
8 /// If unset, defaults to 0. Replica indices will be in the range:
9 /// \[0, .spec.replicas).
10pub start: Option<i32>,
11}
1213impl crate::DeepMerge for StatefulSetOrdinals {
14fn merge_from(&mut self, other: Self) {
15crate::DeepMerge::merge_from(&mut self.start, other.start);
16 }
17}
1819impl<'de> crate::serde::Deserialize<'de> for StatefulSetOrdinals {
20fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
21#[allow(non_camel_case_types)]
22enum Field {
23 Key_start,
24 Other,
25 }
2627impl<'de> crate::serde::Deserialize<'de> for Field {
28fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
29struct Visitor;
3031impl crate::serde::de::Visitor<'_> for Visitor {
32type Value = Field;
3334fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
35 f.write_str("field identifier")
36 }
3738fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
39Ok(match v {
40"start" => Field::Key_start,
41_ => Field::Other,
42 })
43 }
44 }
4546 deserializer.deserialize_identifier(Visitor)
47 }
48 }
4950struct Visitor;
5152impl<'de> crate::serde::de::Visitor<'de> for Visitor {
53type Value = StatefulSetOrdinals;
5455fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
56 f.write_str("StatefulSetOrdinals")
57 }
5859fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
60let mut value_start: Option<i32> = None;
6162while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
63match key {
64 Field::Key_start => value_start = crate::serde::de::MapAccess::next_value(&mut map)?,
65 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
66 }
67 }
6869Ok(StatefulSetOrdinals {
70 start: value_start,
71 })
72 }
73 }
7475 deserializer.deserialize_struct(
76"StatefulSetOrdinals",
77&[
78"start",
79 ],
80 Visitor,
81 )
82 }
83}
8485impl crate::serde::Serialize for StatefulSetOrdinals {
86fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
87let mut state = serializer.serialize_struct(
88"StatefulSetOrdinals",
89self.start.as_ref().map_or(0, |_| 1),
90 )?;
91if let Some(value) = &self.start {
92crate::serde::ser::SerializeStruct::serialize_field(&mut state, "start", value)?;
93 }
94crate::serde::ser::SerializeStruct::end(state)
95 }
96}
9798#[cfg(feature = "schemars")]
99impl crate::schemars::JsonSchema for StatefulSetOrdinals {
100fn schema_name() -> std::string::String {
101"io.k8s.api.apps.v1.StatefulSetOrdinals".into()
102 }
103104fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
105crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
106 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
107 description: Some("StatefulSetOrdinals describes the policy used for replica ordinal assignment in this StatefulSet.".into()),
108 ..Default::default()
109 })),
110 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
111 object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
112 properties: [
113 (
114"start".into(),
115crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
116 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
117 description: Some("start is the number representing the first replica's index. It may be used to number replicas from an alternate index (eg: 1-indexed) over the default 0-indexed names, or to orchestrate progressive movement of replicas from one StatefulSet to another. If set, replica indices will be in the range:\n [.spec.ordinals.start, .spec.ordinals.start + .spec.replicas).\nIf unset, defaults to 0. Replica indices will be in the range:\n [0, .spec.replicas).".into()),
118 ..Default::default()
119 })),
120 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
121 format: Some("int32".into()),
122 ..Default::default()
123 }),
124 ),
125 ].into(),
126 ..Default::default()
127 })),
128 ..Default::default()
129 })
130 }
131}