k8s_openapi/v1_33/api/apiserverinternal/v1alpha1/
storage_version_status.rs
1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct StorageVersionStatus {
6 pub common_encoding_version: Option<std::string::String>,
8
9 pub conditions: Option<std::vec::Vec<crate::api::apiserverinternal::v1alpha1::StorageVersionCondition>>,
11
12 pub storage_versions: Option<std::vec::Vec<crate::api::apiserverinternal::v1alpha1::ServerStorageVersion>>,
14}
15
16impl crate::DeepMerge for StorageVersionStatus {
17 fn merge_from(&mut self, other: Self) {
18 crate::DeepMerge::merge_from(&mut self.common_encoding_version, other.common_encoding_version);
19 crate::merge_strategies::list::map(
20 &mut self.conditions,
21 other.conditions,
22 &[|lhs, rhs| lhs.type_ == rhs.type_],
23 |current_item, other_item| {
24 crate::DeepMerge::merge_from(current_item, other_item);
25 },
26 );
27 crate::merge_strategies::list::map(
28 &mut self.storage_versions,
29 other.storage_versions,
30 &[|lhs, rhs| lhs.api_server_id == rhs.api_server_id],
31 |current_item, other_item| {
32 crate::DeepMerge::merge_from(current_item, other_item);
33 },
34 );
35 }
36}
37
38impl<'de> crate::serde::Deserialize<'de> for StorageVersionStatus {
39 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
40 #[allow(non_camel_case_types)]
41 enum Field {
42 Key_common_encoding_version,
43 Key_conditions,
44 Key_storage_versions,
45 Other,
46 }
47
48 impl<'de> crate::serde::Deserialize<'de> for Field {
49 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
50 struct Visitor;
51
52 impl crate::serde::de::Visitor<'_> for Visitor {
53 type Value = Field;
54
55 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
56 f.write_str("field identifier")
57 }
58
59 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
60 Ok(match v {
61 "commonEncodingVersion" => Field::Key_common_encoding_version,
62 "conditions" => Field::Key_conditions,
63 "storageVersions" => Field::Key_storage_versions,
64 _ => Field::Other,
65 })
66 }
67 }
68
69 deserializer.deserialize_identifier(Visitor)
70 }
71 }
72
73 struct Visitor;
74
75 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
76 type Value = StorageVersionStatus;
77
78 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
79 f.write_str("StorageVersionStatus")
80 }
81
82 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
83 let mut value_common_encoding_version: Option<std::string::String> = None;
84 let mut value_conditions: Option<std::vec::Vec<crate::api::apiserverinternal::v1alpha1::StorageVersionCondition>> = None;
85 let mut value_storage_versions: Option<std::vec::Vec<crate::api::apiserverinternal::v1alpha1::ServerStorageVersion>> = None;
86
87 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
88 match key {
89 Field::Key_common_encoding_version => value_common_encoding_version = crate::serde::de::MapAccess::next_value(&mut map)?,
90 Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
91 Field::Key_storage_versions => value_storage_versions = crate::serde::de::MapAccess::next_value(&mut map)?,
92 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
93 }
94 }
95
96 Ok(StorageVersionStatus {
97 common_encoding_version: value_common_encoding_version,
98 conditions: value_conditions,
99 storage_versions: value_storage_versions,
100 })
101 }
102 }
103
104 deserializer.deserialize_struct(
105 "StorageVersionStatus",
106 &[
107 "commonEncodingVersion",
108 "conditions",
109 "storageVersions",
110 ],
111 Visitor,
112 )
113 }
114}
115
116impl crate::serde::Serialize for StorageVersionStatus {
117 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
118 let mut state = serializer.serialize_struct(
119 "StorageVersionStatus",
120 self.common_encoding_version.as_ref().map_or(0, |_| 1) +
121 self.conditions.as_ref().map_or(0, |_| 1) +
122 self.storage_versions.as_ref().map_or(0, |_| 1),
123 )?;
124 if let Some(value) = &self.common_encoding_version {
125 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "commonEncodingVersion", value)?;
126 }
127 if let Some(value) = &self.conditions {
128 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
129 }
130 if let Some(value) = &self.storage_versions {
131 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "storageVersions", value)?;
132 }
133 crate::serde::ser::SerializeStruct::end(state)
134 }
135}
136
137#[cfg(feature = "schemars")]
138impl crate::schemars::JsonSchema for StorageVersionStatus {
139 fn schema_name() -> std::string::String {
140 "io.k8s.api.apiserverinternal.v1alpha1.StorageVersionStatus".into()
141 }
142
143 fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
144 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
145 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
146 description: Some("API server instances report the versions they can decode and the version they encode objects to when persisting objects in the backend.".into()),
147 ..Default::default()
148 })),
149 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
150 object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
151 properties: [
152 (
153 "commonEncodingVersion".into(),
154 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
155 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
156 description: Some("If all API server instances agree on the same encoding storage version, then this field is set to that version. Otherwise this field is left empty. API servers should finish updating its storageVersionStatus entry before serving write operations, so that this field will be in sync with the reality.".into()),
157 ..Default::default()
158 })),
159 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
160 ..Default::default()
161 }),
162 ),
163 (
164 "conditions".into(),
165 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
166 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
167 description: Some("The latest available observations of the storageVersion's state.".into()),
168 ..Default::default()
169 })),
170 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Array))),
171 array: Some(std::boxed::Box::new(crate::schemars::schema::ArrayValidation {
172 items: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(__gen.subschema_for::<crate::api::apiserverinternal::v1alpha1::StorageVersionCondition>()))),
173 ..Default::default()
174 })),
175 ..Default::default()
176 }),
177 ),
178 (
179 "storageVersions".into(),
180 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
181 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
182 description: Some("The reported versions per API server instance.".into()),
183 ..Default::default()
184 })),
185 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Array))),
186 array: Some(std::boxed::Box::new(crate::schemars::schema::ArrayValidation {
187 items: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(__gen.subschema_for::<crate::api::apiserverinternal::v1alpha1::ServerStorageVersion>()))),
188 ..Default::default()
189 })),
190 ..Default::default()
191 }),
192 ),
193 ].into(),
194 ..Default::default()
195 })),
196 ..Default::default()
197 })
198 }
199}