#
k8s_openapi/v1_35/api/core/v1/
component_status.rs

    1// Generated from definition io.k8s.api.core.v1.ComponentStatus
    2
    3/// ComponentStatus (and ComponentStatusList) holds the cluster validation info. Deprecated: This API is deprecated in v1.19+
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct ComponentStatus {
    6    /// List of component conditions observed
    7    pub conditions: Option<std::vec::Vec<crate::api::core::v1::ComponentCondition>>,
    8
    9    /// Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
    10    pub metadata: crate::apimachinery::pkg::apis::meta::v1::ObjectMeta,
    11}
    12
    13impl crate::Resource for ComponentStatus {
    14    const API_VERSION: &'static str = "v1";
    15    const GROUP: &'static str = "";
    16    const KIND: &'static str = "ComponentStatus";
    17    const VERSION: &'static str = "v1";
    18    const URL_PATH_SEGMENT: &'static str = "componentstatuses";
    19    type Scope = crate::ClusterResourceScope;
    20}
    21
    22impl crate::ListableResource for ComponentStatus {
    23    const LIST_KIND: &'static str = "ComponentStatusList";
    24}
    25
    26impl crate::Metadata for ComponentStatus {
    27    type Ty = crate::apimachinery::pkg::apis::meta::v1::ObjectMeta;
    28
    29    fn metadata(&self) -> &<Self as crate::Metadata>::Ty {
    30        &self.metadata
    31    }
    32
    33    fn metadata_mut(&mut self) -> &mut<Self as crate::Metadata>::Ty {
    34        &mut self.metadata
    35    }
    36}
    37
    38impl crate::DeepMerge for ComponentStatus {
    39    fn merge_from(&mut self, other: Self) {
    40        crate::merge_strategies::list::map(
    41            &mut self.conditions,
    42            other.conditions,
    43            &[|lhs, rhs| lhs.type_ == rhs.type_],
    44            |current_item, other_item| {
    45                crate::DeepMerge::merge_from(current_item, other_item);
    46            },
    47        );
    48        crate::DeepMerge::merge_from(&mut self.metadata, other.metadata);
    49    }
    50}
    51
    52impl<'de> crate::serde::Deserialize<'de> for ComponentStatus {
    53    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    54        #[allow(non_camel_case_types)]
    55        enum Field {
    56            Key_api_version,
    57            Key_kind,
    58            Key_conditions,
    59            Key_metadata,
    60            Other,
    61        }
    62
    63        impl<'de> crate::serde::Deserialize<'de> for Field {
    64            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    65                struct Visitor;
    66
    67                impl crate::serde::de::Visitor<'_> for Visitor {
    68                    type Value = Field;
    69
    70                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    71                        f.write_str("field identifier")
    72                    }
    73
    74                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
    75                        Ok(match v {
    76                            "apiVersion" => Field::Key_api_version,
    77                            "kind" => Field::Key_kind,
    78                            "conditions" => Field::Key_conditions,
    79                            "metadata" => Field::Key_metadata,
    80                            _ => Field::Other,
    81                        })
    82                    }
    83                }
    84
    85                deserializer.deserialize_identifier(Visitor)
    86            }
    87        }
    88
    89        struct Visitor;
    90
    91        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
    92            type Value = ComponentStatus;
    93
    94            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    95                f.write_str(<Self::Value as crate::Resource>::KIND)
    96            }
    97
    98            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
    99                let mut value_conditions: Option<std::vec::Vec<crate::api::core::v1::ComponentCondition>> = None;
    100                let mut value_metadata: Option<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta> = None;
    101
    102                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
    103                    match key {
    104                        Field::Key_api_version => {
    105                            let value_api_version: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
    106                            if value_api_version != <Self::Value as crate::Resource>::API_VERSION {
    107                                return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_api_version), &<Self::Value as crate::Resource>::API_VERSION));
    108                            }
    109                        },
    110                        Field::Key_kind => {
    111                            let value_kind: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
    112                            if value_kind != <Self::Value as crate::Resource>::KIND {
    113                                return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_kind), &<Self::Value as crate::Resource>::KIND));
    114                            }
    115                        },
    116                        Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
    117                        Field::Key_metadata => value_metadata = crate::serde::de::MapAccess::next_value(&mut map)?,
    118                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
    119                    }
    120                }
    121
    122                Ok(ComponentStatus {
    123                    conditions: value_conditions,
    124                    metadata: value_metadata.unwrap_or_default(),
    125                })
    126            }
    127        }
    128
    129        deserializer.deserialize_struct(
    130            <Self as crate::Resource>::KIND,
    131            &[
    132                "apiVersion",
    133                "kind",
    134                "conditions",
    135                "metadata",
    136            ],
    137            Visitor,
    138        )
    139    }
    140}
    141
    142impl crate::serde::Serialize for ComponentStatus {
    143    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
    144        let mut state = serializer.serialize_struct(
    145            <Self as crate::Resource>::KIND,
    146            3 +
    147            self.conditions.as_ref().map_or(0, |_| 1),
    148        )?;
    149        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", <Self as crate::Resource>::API_VERSION)?;
    150        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "kind", <Self as crate::Resource>::KIND)?;
    151        if let Some(value) = &self.conditions {
    152            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
    153        }
    154        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "metadata", &self.metadata)?;
    155        crate::serde::ser::SerializeStruct::end(state)
    156    }
    157}
    158
    159#[cfg(feature = "schemars")]
    160impl crate::schemars::JsonSchema for ComponentStatus {
    161    fn schema_name() -> std::borrow::Cow<'static, str> {
    162        "io.k8s.api.core.v1.ComponentStatus".into()
    163    }
    164
    165    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    166        crate::schemars::json_schema!({
    167            "description": "ComponentStatus (and ComponentStatusList) holds the cluster validation info. Deprecated: This API is deprecated in v1.19+",
    168            "type": "object",
    169            "properties": {
    170                "apiVersion": {
    171                    "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
    172                    "type": "string",
    173                },
    174                "conditions": {
    175                    "description": "List of component conditions observed",
    176                    "type": "array",
    177                    "items": (__gen.subschema_for::<crate::api::core::v1::ComponentCondition>()),
    178                },
    179                "kind": {
    180                    "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
    181                    "type": "string",
    182                },
    183                "metadata": ({
    184                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta>();
    185                    schema_obj.ensure_object().insert("description".into(), "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata".into());
    186                    schema_obj
    187                }),
    188            },
    189            "required": [
    190                "metadata",
    191            ],
    192        })
    193    }
    194}