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

    1// Generated from definition io.k8s.api.core.v1.CephFSPersistentVolumeSource
    2
    3/// Represents a Ceph Filesystem mount that lasts the lifetime of a pod Cephfs volumes do not support ownership management or SELinux relabeling.
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct CephFSPersistentVolumeSource {
    6    /// monitors is Required: Monitors is a collection of Ceph monitors More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it
    7    pub monitors: std::vec::Vec<std::string::String>,
    8
    9    /// path is Optional: Used as the mounted root, rather than the full Ceph tree, default is /
    10    pub path: Option<std::string::String>,
    11
    12    /// readOnly is Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it
    13    pub read_only: Option<bool>,
    14
    15    /// secretFile is Optional: SecretFile is the path to key ring for User, default is /etc/ceph/user.secret More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it
    16    pub secret_file: Option<std::string::String>,
    17
    18    /// secretRef is Optional: SecretRef is reference to the authentication secret for User, default is empty. More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it
    19    pub secret_ref: Option<crate::api::core::v1::SecretReference>,
    20
    21    /// user is Optional: User is the rados user name, default is admin More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it
    22    pub user: Option<std::string::String>,
    23}
    24
    25impl crate::DeepMerge for CephFSPersistentVolumeSource {
    26    fn merge_from(&mut self, other: Self) {
    27        crate::merge_strategies::list::atomic(&mut self.monitors, other.monitors);
    28        crate::DeepMerge::merge_from(&mut self.path, other.path);
    29        crate::DeepMerge::merge_from(&mut self.read_only, other.read_only);
    30        crate::DeepMerge::merge_from(&mut self.secret_file, other.secret_file);
    31        crate::DeepMerge::merge_from(&mut self.secret_ref, other.secret_ref);
    32        crate::DeepMerge::merge_from(&mut self.user, other.user);
    33    }
    34}
    35
    36impl<'de> crate::serde::Deserialize<'de> for CephFSPersistentVolumeSource {
    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_monitors,
    41            Key_path,
    42            Key_read_only,
    43            Key_secret_file,
    44            Key_secret_ref,
    45            Key_user,
    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                            "monitors" => Field::Key_monitors,
    63                            "path" => Field::Key_path,
    64                            "readOnly" => Field::Key_read_only,
    65                            "secretFile" => Field::Key_secret_file,
    66                            "secretRef" => Field::Key_secret_ref,
    67                            "user" => Field::Key_user,
    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 = CephFSPersistentVolumeSource;
    81
    82            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    83                f.write_str("CephFSPersistentVolumeSource")
    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_monitors: Option<std::vec::Vec<std::string::String>> = None;
    88                let mut value_path: Option<std::string::String> = None;
    89                let mut value_read_only: Option<bool> = None;
    90                let mut value_secret_file: Option<std::string::String> = None;
    91                let mut value_secret_ref: Option<crate::api::core::v1::SecretReference> = None;
    92                let mut value_user: 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_monitors => value_monitors = crate::serde::de::MapAccess::next_value(&mut map)?,
    97                        Field::Key_path => value_path = crate::serde::de::MapAccess::next_value(&mut map)?,
    98                        Field::Key_read_only => value_read_only = crate::serde::de::MapAccess::next_value(&mut map)?,
    99                        Field::Key_secret_file => value_secret_file = crate::serde::de::MapAccess::next_value(&mut map)?,
    100                        Field::Key_secret_ref => value_secret_ref = crate::serde::de::MapAccess::next_value(&mut map)?,
    101                        Field::Key_user => value_user = 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(CephFSPersistentVolumeSource {
    107                    monitors: value_monitors.unwrap_or_default(),
    108                    path: value_path,
    109                    read_only: value_read_only,
    110                    secret_file: value_secret_file,
    111                    secret_ref: value_secret_ref,
    112                    user: value_user,
    113                })
    114            }
    115        }
    116
    117        deserializer.deserialize_struct(
    118            "CephFSPersistentVolumeSource",
    119            &[
    120                "monitors",
    121                "path",
    122                "readOnly",
    123                "secretFile",
    124                "secretRef",
    125                "user",
    126            ],
    127            Visitor,
    128        )
    129    }
    130}
    131
    132impl crate::serde::Serialize for CephFSPersistentVolumeSource {
    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            "CephFSPersistentVolumeSource",
    136            1 +
    137            self.path.as_ref().map_or(0, |_| 1) +
    138            self.read_only.as_ref().map_or(0, |_| 1) +
    139            self.secret_file.as_ref().map_or(0, |_| 1) +
    140            self.secret_ref.as_ref().map_or(0, |_| 1) +
    141            self.user.as_ref().map_or(0, |_| 1),
    142        )?;
    143        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "monitors", &self.monitors)?;
    144        if let Some(value) = &self.path {
    145            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "path", value)?;
    146        }
    147        if let Some(value) = &self.read_only {
    148            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readOnly", value)?;
    149        }
    150        if let Some(value) = &self.secret_file {
    151            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "secretFile", value)?;
    152        }
    153        if let Some(value) = &self.secret_ref {
    154            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "secretRef", value)?;
    155        }
    156        if let Some(value) = &self.user {
    157            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "user", value)?;
    158        }
    159        crate::serde::ser::SerializeStruct::end(state)
    160    }
    161}
    162
    163#[cfg(feature = "schemars")]
    164impl crate::schemars::JsonSchema for CephFSPersistentVolumeSource {
    165    fn schema_name() -> std::borrow::Cow<'static, str> {
    166        "io.k8s.api.core.v1.CephFSPersistentVolumeSource".into()
    167    }
    168
    169    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    170        crate::schemars::json_schema!({
    171            "description": "Represents a Ceph Filesystem mount that lasts the lifetime of a pod Cephfs volumes do not support ownership management or SELinux relabeling.",
    172            "type": "object",
    173            "properties": {
    174                "monitors": {
    175                    "description": "monitors is Required: Monitors is a collection of Ceph monitors More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it",
    176                    "type": "array",
    177                    "items": {
    178                        "type": "string",
    179                    },
    180                },
    181                "path": {
    182                    "description": "path is Optional: Used as the mounted root, rather than the full Ceph tree, default is /",
    183                    "type": "string",
    184                },
    185                "readOnly": {
    186                    "description": "readOnly is Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it",
    187                    "type": "boolean",
    188                },
    189                "secretFile": {
    190                    "description": "secretFile is Optional: SecretFile is the path to key ring for User, default is /etc/ceph/user.secret More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it",
    191                    "type": "string",
    192                },
    193                "secretRef": ({
    194                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::SecretReference>();
    195                    schema_obj.ensure_object().insert("description".into(), "secretRef is Optional: SecretRef is reference to the authentication secret for User, default is empty. More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it".into());
    196                    schema_obj
    197                }),
    198                "user": {
    199                    "description": "user is Optional: User is the rados user name, default is admin More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it",
    200                    "type": "string",
    201                },
    202            },
    203            "required": [
    204                "monitors",
    205            ],
    206        })
    207    }
    208}