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

    1// Generated from definition io.k8s.api.storage.v1.CSIDriver
    2
    3/// CSIDriver captures information about a Container Storage Interface (CSI) volume driver deployed on the cluster. Kubernetes attach detach controller uses this object to determine whether attach is required. Kubelet uses this object to determine whether pod information needs to be passed on mount. CSIDriver objects are non-namespaced.
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct CSIDriver {
    6    /// Standard object metadata. metadata.Name indicates the name of the CSI driver that this object refers to; it MUST be the same name returned by the CSI GetPluginName() call for that driver. The driver name must be 63 characters or less, beginning and ending with an alphanumeric character (\[a-z0-9A-Z\]) with dashes (-), dots (.), and alphanumerics between. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
    7    pub metadata: crate::apimachinery::pkg::apis::meta::v1::ObjectMeta,
    8
    9    /// spec represents the specification of the CSI Driver.
    10    pub spec: crate::api::storage::v1::CSIDriverSpec,
    11}
    12
    13impl crate::Resource for CSIDriver {
    14    const API_VERSION: &'static str = "storage.k8s.io/v1";
    15    const GROUP: &'static str = "storage.k8s.io";
    16    const KIND: &'static str = "CSIDriver";
    17    const VERSION: &'static str = "v1";
    18    const URL_PATH_SEGMENT: &'static str = "csidrivers";
    19    type Scope = crate::ClusterResourceScope;
    20}
    21
    22impl crate::ListableResource for CSIDriver {
    23    const LIST_KIND: &'static str = "CSIDriverList";
    24}
    25
    26impl crate::Metadata for CSIDriver {
    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 CSIDriver {
    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 CSIDriver {
    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 = CSIDriver;
    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::CSIDriverSpec> = 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(CSIDriver {
    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 CSIDriver {
    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 CSIDriver {
    151    fn schema_name() -> std::borrow::Cow<'static, str> {
    152        "io.k8s.api.storage.v1.CSIDriver".into()
    153    }
    154
    155    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    156        crate::schemars::json_schema!({
    157            "description": "CSIDriver captures information about a Container Storage Interface (CSI) volume driver deployed on the cluster. Kubernetes attach detach controller uses this object to determine whether attach is required. Kubelet uses this object to determine whether pod information needs to be passed on mount. CSIDriver objects are non-namespaced.",
    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 metadata. metadata.Name indicates the name of the CSI driver that this object refers to; it MUST be the same name returned by the CSI GetPluginName() call for that driver. The driver name must be 63 characters or less, beginning and ending with an alphanumeric character ([a-z0-9A-Z]) with dashes (-), dots (.), and alphanumerics between. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata".into());
    171                    schema_obj
    172                }),
    173                "spec": ({
    174                    let mut schema_obj = __gen.subschema_for::<crate::api::storage::v1::CSIDriverSpec>();
    175                    schema_obj.ensure_object().insert("description".into(), "spec represents the specification of the CSI Driver.".into());
    176                    schema_obj
    177                }),
    178            },
    179            "required": [
    180                "metadata",
    181                "spec",
    182            ],
    183        })
    184    }
    185}