#
k8s_openapi/v1_35/apiextensions_apiserver/pkg/apis/apiextensions/v1/
custom_resource_definition_status.rs

    1// Generated from definition io.k8s.apiextensions-apiserver.pkg.apis.apiextensions.v1.CustomResourceDefinitionStatus
    2
    3/// CustomResourceDefinitionStatus indicates the state of the CustomResourceDefinition
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct CustomResourceDefinitionStatus {
    6    /// acceptedNames are the names that are actually being used to serve discovery. They may be different than the names in spec.
    7    pub accepted_names: Option<crate::apiextensions_apiserver::pkg::apis::apiextensions::v1::CustomResourceDefinitionNames>,
    8
    9    /// conditions indicate state for particular aspects of a CustomResourceDefinition
    10    pub conditions: Option<std::vec::Vec<crate::apiextensions_apiserver::pkg::apis::apiextensions::v1::CustomResourceDefinitionCondition>>,
    11
    12    /// The generation observed by the CRD controller.
    13    pub observed_generation: Option<i64>,
    14
    15    /// storedVersions lists all versions of CustomResources that were ever persisted. Tracking these versions allows a migration path for stored versions in etcd. The field is mutable so a migration controller can finish a migration to another version (ensuring no old objects are left in storage), and then remove the rest of the versions from this list. Versions may not be removed from `spec.versions` while they exist in this list.
    16    pub stored_versions: Option<std::vec::Vec<std::string::String>>,
    17}
    18
    19impl crate::DeepMerge for CustomResourceDefinitionStatus {
    20    fn merge_from(&mut self, other: Self) {
    21        crate::DeepMerge::merge_from(&mut self.accepted_names, other.accepted_names);
    22        crate::merge_strategies::list::map(
    23            &mut self.conditions,
    24            other.conditions,
    25            &[|lhs, rhs| lhs.type_ == rhs.type_],
    26            |current_item, other_item| {
    27                crate::DeepMerge::merge_from(current_item, other_item);
    28            },
    29        );
    30        crate::DeepMerge::merge_from(&mut self.observed_generation, other.observed_generation);
    31        crate::merge_strategies::list::atomic(&mut self.stored_versions, other.stored_versions);
    32    }
    33}
    34
    35impl<'de> crate::serde::Deserialize<'de> for CustomResourceDefinitionStatus {
    36    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    37        #[allow(non_camel_case_types)]
    38        enum Field {
    39            Key_accepted_names,
    40            Key_conditions,
    41            Key_observed_generation,
    42            Key_stored_versions,
    43            Other,
    44        }
    45
    46        impl<'de> crate::serde::Deserialize<'de> for Field {
    47            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    48                struct Visitor;
    49
    50                impl crate::serde::de::Visitor<'_> for Visitor {
    51                    type Value = Field;
    52
    53                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    54                        f.write_str("field identifier")
    55                    }
    56
    57                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
    58                        Ok(match v {
    59                            "acceptedNames" => Field::Key_accepted_names,
    60                            "conditions" => Field::Key_conditions,
    61                            "observedGeneration" => Field::Key_observed_generation,
    62                            "storedVersions" => Field::Key_stored_versions,
    63                            _ => Field::Other,
    64                        })
    65                    }
    66                }
    67
    68                deserializer.deserialize_identifier(Visitor)
    69            }
    70        }
    71
    72        struct Visitor;
    73
    74        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
    75            type Value = CustomResourceDefinitionStatus;
    76
    77            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    78                f.write_str("CustomResourceDefinitionStatus")
    79            }
    80
    81            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
    82                let mut value_accepted_names: Option<crate::apiextensions_apiserver::pkg::apis::apiextensions::v1::CustomResourceDefinitionNames> = None;
    83                let mut value_conditions: Option<std::vec::Vec<crate::apiextensions_apiserver::pkg::apis::apiextensions::v1::CustomResourceDefinitionCondition>> = None;
    84                let mut value_observed_generation: Option<i64> = None;
    85                let mut value_stored_versions: Option<std::vec::Vec<std::string::String>> = None;
    86
    87                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
    88                    match key {
    89                        Field::Key_accepted_names => value_accepted_names = 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_observed_generation => value_observed_generation = crate::serde::de::MapAccess::next_value(&mut map)?,
    92                        Field::Key_stored_versions => value_stored_versions = crate::serde::de::MapAccess::next_value(&mut map)?,
    93                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
    94                    }
    95                }
    96
    97                Ok(CustomResourceDefinitionStatus {
    98                    accepted_names: value_accepted_names,
    99                    conditions: value_conditions,
    100                    observed_generation: value_observed_generation,
    101                    stored_versions: value_stored_versions,
    102                })
    103            }
    104        }
    105
    106        deserializer.deserialize_struct(
    107            "CustomResourceDefinitionStatus",
    108            &[
    109                "acceptedNames",
    110                "conditions",
    111                "observedGeneration",
    112                "storedVersions",
    113            ],
    114            Visitor,
    115        )
    116    }
    117}
    118
    119impl crate::serde::Serialize for CustomResourceDefinitionStatus {
    120    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
    121        let mut state = serializer.serialize_struct(
    122            "CustomResourceDefinitionStatus",
    123            self.accepted_names.as_ref().map_or(0, |_| 1) +
    124            self.conditions.as_ref().map_or(0, |_| 1) +
    125            self.observed_generation.as_ref().map_or(0, |_| 1) +
    126            self.stored_versions.as_ref().map_or(0, |_| 1),
    127        )?;
    128        if let Some(value) = &self.accepted_names {
    129            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "acceptedNames", value)?;
    130        }
    131        if let Some(value) = &self.conditions {
    132            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
    133        }
    134        if let Some(value) = &self.observed_generation {
    135            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "observedGeneration", value)?;
    136        }
    137        if let Some(value) = &self.stored_versions {
    138            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "storedVersions", value)?;
    139        }
    140        crate::serde::ser::SerializeStruct::end(state)
    141    }
    142}
    143
    144#[cfg(feature = "schemars")]
    145impl crate::schemars::JsonSchema for CustomResourceDefinitionStatus {
    146    fn schema_name() -> std::borrow::Cow<'static, str> {
    147        "io.k8s.apiextensions-apiserver.pkg.apis.apiextensions.v1.CustomResourceDefinitionStatus".into()
    148    }
    149
    150    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    151        crate::schemars::json_schema!({
    152            "description": "CustomResourceDefinitionStatus indicates the state of the CustomResourceDefinition",
    153            "type": "object",
    154            "properties": {
    155                "acceptedNames": ({
    156                    let mut schema_obj = __gen.subschema_for::<crate::apiextensions_apiserver::pkg::apis::apiextensions::v1::CustomResourceDefinitionNames>();
    157                    schema_obj.ensure_object().insert("description".into(), "acceptedNames are the names that are actually being used to serve discovery. They may be different than the names in spec.".into());
    158                    schema_obj
    159                }),
    160                "conditions": {
    161                    "description": "conditions indicate state for particular aspects of a CustomResourceDefinition",
    162                    "type": "array",
    163                    "items": (__gen.subschema_for::<crate::apiextensions_apiserver::pkg::apis::apiextensions::v1::CustomResourceDefinitionCondition>()),
    164                },
    165                "observedGeneration": {
    166                    "description": "The generation observed by the CRD controller.",
    167                    "type": "integer",
    168                    "format": "int64",
    169                },
    170                "storedVersions": {
    171                    "description": "storedVersions lists all versions of CustomResources that were ever persisted. Tracking these versions allows a migration path for stored versions in etcd. The field is mutable so a migration controller can finish a migration to another version (ensuring no old objects are left in storage), and then remove the rest of the versions from this list. Versions may not be removed from `spec.versions` while they exist in this list.",
    172                    "type": "array",
    173                    "items": {
    174                        "type": "string",
    175                    },
    176                },
    177            },
    178        })
    179    }
    180}