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

    1// Generated from definition io.k8s.api.core.v1.QuobyteVolumeSource
    2
    3/// Represents a Quobyte mount that lasts the lifetime of a pod. Quobyte volumes do not support ownership management or SELinux relabeling.
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct QuobyteVolumeSource {
    6    /// group to map volume access to Default is no group
    7    pub group: Option<std::string::String>,
    8
    9    /// readOnly here will force the Quobyte volume to be mounted with read-only permissions. Defaults to false.
    10    pub read_only: Option<bool>,
    11
    12    /// registry represents a single or multiple Quobyte Registry services specified as a string as host:port pair (multiple entries are separated with commas) which acts as the central registry for volumes
    13    pub registry: std::string::String,
    14
    15    /// tenant owning the given Quobyte volume in the Backend Used with dynamically provisioned Quobyte volumes, value is set by the plugin
    16    pub tenant: Option<std::string::String>,
    17
    18    /// user to map volume access to Defaults to serivceaccount user
    19    pub user: Option<std::string::String>,
    20
    21    /// volume is a string that references an already created Quobyte volume by name.
    22    pub volume: std::string::String,
    23}
    24
    25impl crate::DeepMerge for QuobyteVolumeSource {
    26    fn merge_from(&mut self, other: Self) {
    27        crate::DeepMerge::merge_from(&mut self.group, other.group);
    28        crate::DeepMerge::merge_from(&mut self.read_only, other.read_only);
    29        crate::DeepMerge::merge_from(&mut self.registry, other.registry);
    30        crate::DeepMerge::merge_from(&mut self.tenant, other.tenant);
    31        crate::DeepMerge::merge_from(&mut self.user, other.user);
    32        crate::DeepMerge::merge_from(&mut self.volume, other.volume);
    33    }
    34}
    35
    36impl<'de> crate::serde::Deserialize<'de> for QuobyteVolumeSource {
    37    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    38        #[allow(non_camel_case_types)]
    39        enum Field {
    40            Key_group,
    41            Key_read_only,
    42            Key_registry,
    43            Key_tenant,
    44            Key_user,
    45            Key_volume,
    46            Other,
    47        }
    48
    49        impl<'de> crate::serde::Deserialize<'de> for Field {
    50            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    51                struct Visitor;
    52
    53                impl crate::serde::de::Visitor<'_> for Visitor {
    54                    type Value = Field;
    55
    56                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    57                        f.write_str("field identifier")
    58                    }
    59
    60                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
    61                        Ok(match v {
    62                            "group" => Field::Key_group,
    63                            "readOnly" => Field::Key_read_only,
    64                            "registry" => Field::Key_registry,
    65                            "tenant" => Field::Key_tenant,
    66                            "user" => Field::Key_user,
    67                            "volume" => Field::Key_volume,
    68                            _ => Field::Other,
    69                        })
    70                    }
    71                }
    72
    73                deserializer.deserialize_identifier(Visitor)
    74            }
    75        }
    76
    77        struct Visitor;
    78
    79        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
    80            type Value = QuobyteVolumeSource;
    81
    82            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    83                f.write_str("QuobyteVolumeSource")
    84            }
    85
    86            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
    87                let mut value_group: Option<std::string::String> = None;
    88                let mut value_read_only: Option<bool> = None;
    89                let mut value_registry: Option<std::string::String> = None;
    90                let mut value_tenant: Option<std::string::String> = None;
    91                let mut value_user: Option<std::string::String> = None;
    92                let mut value_volume: Option<std::string::String> = None;
    93
    94                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
    95                    match key {
    96                        Field::Key_group => value_group = crate::serde::de::MapAccess::next_value(&mut map)?,
    97                        Field::Key_read_only => value_read_only = crate::serde::de::MapAccess::next_value(&mut map)?,
    98                        Field::Key_registry => value_registry = crate::serde::de::MapAccess::next_value(&mut map)?,
    99                        Field::Key_tenant => value_tenant = crate::serde::de::MapAccess::next_value(&mut map)?,
    100                        Field::Key_user => value_user = crate::serde::de::MapAccess::next_value(&mut map)?,
    101                        Field::Key_volume => value_volume = crate::serde::de::MapAccess::next_value(&mut map)?,
    102                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
    103                    }
    104                }
    105
    106                Ok(QuobyteVolumeSource {
    107                    group: value_group,
    108                    read_only: value_read_only,
    109                    registry: value_registry.unwrap_or_default(),
    110                    tenant: value_tenant,
    111                    user: value_user,
    112                    volume: value_volume.unwrap_or_default(),
    113                })
    114            }
    115        }
    116
    117        deserializer.deserialize_struct(
    118            "QuobyteVolumeSource",
    119            &[
    120                "group",
    121                "readOnly",
    122                "registry",
    123                "tenant",
    124                "user",
    125                "volume",
    126            ],
    127            Visitor,
    128        )
    129    }
    130}
    131
    132impl crate::serde::Serialize for QuobyteVolumeSource {
    133    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
    134        let mut state = serializer.serialize_struct(
    135            "QuobyteVolumeSource",
    136            2 +
    137            self.group.as_ref().map_or(0, |_| 1) +
    138            self.read_only.as_ref().map_or(0, |_| 1) +
    139            self.tenant.as_ref().map_or(0, |_| 1) +
    140            self.user.as_ref().map_or(0, |_| 1),
    141        )?;
    142        if let Some(value) = &self.group {
    143            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "group", value)?;
    144        }
    145        if let Some(value) = &self.read_only {
    146            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readOnly", value)?;
    147        }
    148        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "registry", &self.registry)?;
    149        if let Some(value) = &self.tenant {
    150            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "tenant", value)?;
    151        }
    152        if let Some(value) = &self.user {
    153            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "user", value)?;
    154        }
    155        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "volume", &self.volume)?;
    156        crate::serde::ser::SerializeStruct::end(state)
    157    }
    158}
    159
    160#[cfg(feature = "schemars")]
    161impl crate::schemars::JsonSchema for QuobyteVolumeSource {
    162    fn schema_name() -> std::borrow::Cow<'static, str> {
    163        "io.k8s.api.core.v1.QuobyteVolumeSource".into()
    164    }
    165
    166    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    167        crate::schemars::json_schema!({
    168            "description": "Represents a Quobyte mount that lasts the lifetime of a pod. Quobyte volumes do not support ownership management or SELinux relabeling.",
    169            "type": "object",
    170            "properties": {
    171                "group": {
    172                    "description": "group to map volume access to Default is no group",
    173                    "type": "string",
    174                },
    175                "readOnly": {
    176                    "description": "readOnly here will force the Quobyte volume to be mounted with read-only permissions. Defaults to false.",
    177                    "type": "boolean",
    178                },
    179                "registry": {
    180                    "description": "registry represents a single or multiple Quobyte Registry services specified as a string as host:port pair (multiple entries are separated with commas) which acts as the central registry for volumes",
    181                    "type": "string",
    182                },
    183                "tenant": {
    184                    "description": "tenant owning the given Quobyte volume in the Backend Used with dynamically provisioned Quobyte volumes, value is set by the plugin",
    185                    "type": "string",
    186                },
    187                "user": {
    188                    "description": "user to map volume access to Defaults to serivceaccount user",
    189                    "type": "string",
    190                },
    191                "volume": {
    192                    "description": "volume is a string that references an already created Quobyte volume by name.",
    193                    "type": "string",
    194                },
    195            },
    196            "required": [
    197                "registry",
    198                "volume",
    199            ],
    200        })
    201    }
    202}