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

    1// Generated from definition io.k8s.api.core.v1.GCEPersistentDiskVolumeSource
    2
    3/// Represents a Persistent Disk resource in Google Compute Engine.
    4///
    5/// A GCE PD must exist before mounting to a container. The disk must also be in the same GCE project and zone as the kubelet. A GCE PD can only be mounted as read/write once or read-only many times. GCE PDs support ownership management and SELinux relabeling.
    6#[derive(Clone, Debug, Default, PartialEq)]
    7pub struct GCEPersistentDiskVolumeSource {
    8    /// fsType is filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk
    9    pub fs_type: Option<std::string::String>,
    10
    11    /// partition is the partition in the volume that you want to mount. If omitted, the default is to mount by volume name. Examples: For volume /dev/sda1, you specify the partition as "1". Similarly, the volume partition for /dev/sda is "0" (or you can leave the property empty). More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk
    12    pub partition: Option<i32>,
    13
    14    /// pdName is unique name of the PD resource in GCE. Used to identify the disk in GCE. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk
    15    pub pd_name: std::string::String,
    16
    17    /// readOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk
    18    pub read_only: Option<bool>,
    19}
    20
    21impl crate::DeepMerge for GCEPersistentDiskVolumeSource {
    22    fn merge_from(&mut self, other: Self) {
    23        crate::DeepMerge::merge_from(&mut self.fs_type, other.fs_type);
    24        crate::DeepMerge::merge_from(&mut self.partition, other.partition);
    25        crate::DeepMerge::merge_from(&mut self.pd_name, other.pd_name);
    26        crate::DeepMerge::merge_from(&mut self.read_only, other.read_only);
    27    }
    28}
    29
    30impl<'de> crate::serde::Deserialize<'de> for GCEPersistentDiskVolumeSource {
    31    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    32        #[allow(non_camel_case_types)]
    33        enum Field {
    34            Key_fs_type,
    35            Key_partition,
    36            Key_pd_name,
    37            Key_read_only,
    38            Other,
    39        }
    40
    41        impl<'de> crate::serde::Deserialize<'de> for Field {
    42            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    43                struct Visitor;
    44
    45                impl crate::serde::de::Visitor<'_> for Visitor {
    46                    type Value = Field;
    47
    48                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    49                        f.write_str("field identifier")
    50                    }
    51
    52                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
    53                        Ok(match v {
    54                            "fsType" => Field::Key_fs_type,
    55                            "partition" => Field::Key_partition,
    56                            "pdName" => Field::Key_pd_name,
    57                            "readOnly" => Field::Key_read_only,
    58                            _ => Field::Other,
    59                        })
    60                    }
    61                }
    62
    63                deserializer.deserialize_identifier(Visitor)
    64            }
    65        }
    66
    67        struct Visitor;
    68
    69        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
    70            type Value = GCEPersistentDiskVolumeSource;
    71
    72            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    73                f.write_str("GCEPersistentDiskVolumeSource")
    74            }
    75
    76            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
    77                let mut value_fs_type: Option<std::string::String> = None;
    78                let mut value_partition: Option<i32> = None;
    79                let mut value_pd_name: Option<std::string::String> = None;
    80                let mut value_read_only: Option<bool> = None;
    81
    82                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
    83                    match key {
    84                        Field::Key_fs_type => value_fs_type = crate::serde::de::MapAccess::next_value(&mut map)?,
    85                        Field::Key_partition => value_partition = crate::serde::de::MapAccess::next_value(&mut map)?,
    86                        Field::Key_pd_name => value_pd_name = crate::serde::de::MapAccess::next_value(&mut map)?,
    87                        Field::Key_read_only => value_read_only = crate::serde::de::MapAccess::next_value(&mut map)?,
    88                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
    89                    }
    90                }
    91
    92                Ok(GCEPersistentDiskVolumeSource {
    93                    fs_type: value_fs_type,
    94                    partition: value_partition,
    95                    pd_name: value_pd_name.unwrap_or_default(),
    96                    read_only: value_read_only,
    97                })
    98            }
    99        }
    100
    101        deserializer.deserialize_struct(
    102            "GCEPersistentDiskVolumeSource",
    103            &[
    104                "fsType",
    105                "partition",
    106                "pdName",
    107                "readOnly",
    108            ],
    109            Visitor,
    110        )
    111    }
    112}
    113
    114impl crate::serde::Serialize for GCEPersistentDiskVolumeSource {
    115    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
    116        let mut state = serializer.serialize_struct(
    117            "GCEPersistentDiskVolumeSource",
    118            1 +
    119            self.fs_type.as_ref().map_or(0, |_| 1) +
    120            self.partition.as_ref().map_or(0, |_| 1) +
    121            self.read_only.as_ref().map_or(0, |_| 1),
    122        )?;
    123        if let Some(value) = &self.fs_type {
    124            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "fsType", value)?;
    125        }
    126        if let Some(value) = &self.partition {
    127            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "partition", value)?;
    128        }
    129        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "pdName", &self.pd_name)?;
    130        if let Some(value) = &self.read_only {
    131            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readOnly", value)?;
    132        }
    133        crate::serde::ser::SerializeStruct::end(state)
    134    }
    135}
    136
    137#[cfg(feature = "schemars")]
    138impl crate::schemars::JsonSchema for GCEPersistentDiskVolumeSource {
    139    fn schema_name() -> std::borrow::Cow<'static, str> {
    140        "io.k8s.api.core.v1.GCEPersistentDiskVolumeSource".into()
    141    }
    142
    143    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    144        crate::schemars::json_schema!({
    145            "description": "Represents a Persistent Disk resource in Google Compute Engine.\n\nA GCE PD must exist before mounting to a container. The disk must also be in the same GCE project and zone as the kubelet. A GCE PD can only be mounted as read/write once or read-only many times. GCE PDs support ownership management and SELinux relabeling.",
    146            "type": "object",
    147            "properties": {
    148                "fsType": {
    149                    "description": "fsType is filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk",
    150                    "type": "string",
    151                },
    152                "partition": {
    153                    "description": "partition is the partition in the volume that you want to mount. If omitted, the default is to mount by volume name. Examples: For volume /dev/sda1, you specify the partition as \"1\". Similarly, the volume partition for /dev/sda is \"0\" (or you can leave the property empty). More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk",
    154                    "type": "integer",
    155                    "format": "int32",
    156                },
    157                "pdName": {
    158                    "description": "pdName is unique name of the PD resource in GCE. Used to identify the disk in GCE. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk",
    159                    "type": "string",
    160                },
    161                "readOnly": {
    162                    "description": "readOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk",
    163                    "type": "boolean",
    164                },
    165            },
    166            "required": [
    167                "pdName",
    168            ],
    169        })
    170    }
    171}