#
k8s_openapi/v1_35/api/storage/v1/
csi_node.rs

    1// Generated from definition io.k8s.api.storage.v1.CSINode
    2
    3/// CSINode holds information about all CSI drivers installed on a node. CSI drivers do not need to create the CSINode object directly. As long as they use the node-driver-registrar sidecar container, the kubelet will automatically populate the CSINode object for the CSI driver as part of kubelet plugin registration. CSINode has the same name as a node. If the object is missing, it means either there are no CSI Drivers available on the node, or the Kubelet version is low enough that it doesn't create this object. CSINode has an OwnerReference that points to the corresponding node object.
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct CSINode {
    6    /// Standard object's metadata. metadata.name must be the Kubernetes node name.
    7    pub metadata: crate::apimachinery::pkg::apis::meta::v1::ObjectMeta,
    8
    9    /// spec is the specification of CSINode
    10    pub spec: crate::api::storage::v1::CSINodeSpec,
    11}
    12
    13impl crate::Resource for CSINode {
    14    const API_VERSION: &'static str = "storage.k8s.io/v1";
    15    const GROUP: &'static str = "storage.k8s.io";
    16    const KIND: &'static str = "CSINode";
    17    const VERSION: &'static str = "v1";
    18    const URL_PATH_SEGMENT: &'static str = "csinodes";
    19    type Scope = crate::ClusterResourceScope;
    20}
    21
    22impl crate::ListableResource for CSINode {
    23    const LIST_KIND: &'static str = "CSINodeList";
    24}
    25
    26impl crate::Metadata for CSINode {
    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 CSINode {
    39    fn merge_from(&mut self, other: Self) {
    40        crate::DeepMerge::merge_from(&mut self.metadata, other.metadata);
    41        crate::DeepMerge::merge_from(&mut self.spec, other.spec);
    42    }
    43}
    44
    45impl<'de> crate::serde::Deserialize<'de> for CSINode {
    46    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    47        #[allow(non_camel_case_types)]
    48        enum Field {
    49            Key_api_version,
    50            Key_kind,
    51            Key_metadata,
    52            Key_spec,
    53            Other,
    54        }
    55
    56        impl<'de> crate::serde::Deserialize<'de> for Field {
    57            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    58                struct Visitor;
    59
    60                impl crate::serde::de::Visitor<'_> for Visitor {
    61                    type Value = Field;
    62
    63                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    64                        f.write_str("field identifier")
    65                    }
    66
    67                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
    68                        Ok(match v {
    69                            "apiVersion" => Field::Key_api_version,
    70                            "kind" => Field::Key_kind,
    71                            "metadata" => Field::Key_metadata,
    72                            "spec" => Field::Key_spec,
    73                            _ => Field::Other,
    74                        })
    75                    }
    76                }
    77
    78                deserializer.deserialize_identifier(Visitor)
    79            }
    80        }
    81
    82        struct Visitor;
    83
    84        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
    85            type Value = CSINode;
    86
    87            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    88                f.write_str(<Self::Value as crate::Resource>::KIND)
    89            }
    90
    91            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
    92                let mut value_metadata: Option<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta> = None;
    93                let mut value_spec: Option<crate::api::storage::v1::CSINodeSpec> = None;
    94
    95                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
    96                    match key {
    97                        Field::Key_api_version => {
    98                            let value_api_version: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
    99                            if value_api_version != <Self::Value as crate::Resource>::API_VERSION {
    100                                return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_api_version), &<Self::Value as crate::Resource>::API_VERSION));
    101                            }
    102                        },
    103                        Field::Key_kind => {
    104                            let value_kind: std::string::String = crate::serde::de::MapAccess::next_value(&mut map)?;
    105                            if value_kind != <Self::Value as crate::Resource>::KIND {
    106                                return Err(crate::serde::de::Error::invalid_value(crate::serde::de::Unexpected::Str(&value_kind), &<Self::Value as crate::Resource>::KIND));
    107                            }
    108                        },
    109                        Field::Key_metadata => value_metadata = crate::serde::de::MapAccess::next_value(&mut map)?,
    110                        Field::Key_spec => value_spec = crate::serde::de::MapAccess::next_value(&mut map)?,
    111                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
    112                    }
    113                }
    114
    115                Ok(CSINode {
    116                    metadata: value_metadata.unwrap_or_default(),
    117                    spec: value_spec.unwrap_or_default(),
    118                })
    119            }
    120        }
    121
    122        deserializer.deserialize_struct(
    123            <Self as crate::Resource>::KIND,
    124            &[
    125                "apiVersion",
    126                "kind",
    127                "metadata",
    128                "spec",
    129            ],
    130            Visitor,
    131        )
    132    }
    133}
    134
    135impl crate::serde::Serialize for CSINode {
    136    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
    137        let mut state = serializer.serialize_struct(
    138            <Self as crate::Resource>::KIND,
    139            4,
    140        )?;
    141        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "apiVersion", <Self as crate::Resource>::API_VERSION)?;
    142        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "kind", <Self as crate::Resource>::KIND)?;
    143        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "metadata", &self.metadata)?;
    144        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "spec", &self.spec)?;
    145        crate::serde::ser::SerializeStruct::end(state)
    146    }
    147}
    148
    149#[cfg(feature = "schemars")]
    150impl crate::schemars::JsonSchema for CSINode {
    151    fn schema_name() -> std::borrow::Cow<'static, str> {
    152        "io.k8s.api.storage.v1.CSINode".into()
    153    }
    154
    155    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    156        crate::schemars::json_schema!({
    157            "description": "CSINode holds information about all CSI drivers installed on a node. CSI drivers do not need to create the CSINode object directly. As long as they use the node-driver-registrar sidecar container, the kubelet will automatically populate the CSINode object for the CSI driver as part of kubelet plugin registration. CSINode has the same name as a node. If the object is missing, it means either there are no CSI Drivers available on the node, or the Kubelet version is low enough that it doesn't create this object. CSINode has an OwnerReference that points to the corresponding node object.",
    158            "type": "object",
    159            "properties": {
    160                "apiVersion": {
    161                    "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",
    162                    "type": "string",
    163                },
    164                "kind": {
    165                    "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",
    166                    "type": "string",
    167                },
    168                "metadata": ({
    169                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::ObjectMeta>();
    170                    schema_obj.ensure_object().insert("description".into(), "Standard object's metadata. metadata.name must be the Kubernetes node name.".into());
    171                    schema_obj
    172                }),
    173                "spec": ({
    174                    let mut schema_obj = __gen.subschema_for::<crate::api::storage::v1::CSINodeSpec>();
    175                    schema_obj.ensure_object().insert("description".into(), "spec is the specification of CSINode".into());
    176                    schema_obj
    177                }),
    178            },
    179            "required": [
    180                "metadata",
    181                "spec",
    182            ],
    183        })
    184    }
    185}