k8s_openapi/v1_34/api/apiserverinternal/v1alpha1/
storage_version_status.rs

1// Generated from definition io.k8s.api.apiserverinternal.v1alpha1.StorageVersionStatus
2
3/// API server instances report the versions they can decode and the version they encode objects to when persisting objects in the backend.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct StorageVersionStatus {
6    /// 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.
7    pub common_encoding_version: Option<std::string::String>,
8
9    /// The latest available observations of the storageVersion's state.
10    pub conditions: Option<std::vec::Vec<crate::api::apiserverinternal::v1alpha1::StorageVersionCondition>>,
11
12    /// The reported versions per API server instance.
13    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::borrow::Cow<'static, str> {
140        "io.k8s.api.apiserverinternal.v1alpha1.StorageVersionStatus".into()
141    }
142
143    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
144        crate::schemars::json_schema!({
145            "description": "API server instances report the versions they can decode and the version they encode objects to when persisting objects in the backend.",
146            "type": "object",
147            "properties": {
148                "commonEncodingVersion": {
149                    "description": "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.",
150                    "type": "string",
151                },
152                "conditions": {
153                    "description": "The latest available observations of the storageVersion's state.",
154                    "type": "array",
155                    "items": (__gen.subschema_for::<crate::api::apiserverinternal::v1alpha1::StorageVersionCondition>()),
156                },
157                "storageVersions": {
158                    "description": "The reported versions per API server instance.",
159                    "type": "array",
160                    "items": (__gen.subschema_for::<crate::api::apiserverinternal::v1alpha1::ServerStorageVersion>()),
161                },
162            },
163        })
164    }
165}