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

    1// Generated from definition io.k8s.api.core.v1.ScaleIOVolumeSource
    2
    3/// ScaleIOVolumeSource represents a persistent ScaleIO volume
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct ScaleIOVolumeSource {
    6    /// fsType is the filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". Default is "xfs".
    7    pub fs_type: Option<std::string::String>,
    8
    9    /// gateway is the host address of the ScaleIO API Gateway.
    10    pub gateway: std::string::String,
    11
    12    /// protectionDomain is the name of the ScaleIO Protection Domain for the configured storage.
    13    pub protection_domain: Option<std::string::String>,
    14
    15    /// readOnly Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.
    16    pub read_only: Option<bool>,
    17
    18    /// secretRef references to the secret for ScaleIO user and other sensitive information. If this is not provided, Login operation will fail.
    19    pub secret_ref: crate::api::core::v1::LocalObjectReference,
    20
    21    /// sslEnabled Flag enable/disable SSL communication with Gateway, default false
    22    pub ssl_enabled: Option<bool>,
    23
    24    /// storageMode indicates whether the storage for a volume should be ThickProvisioned or ThinProvisioned. Default is ThinProvisioned.
    25    pub storage_mode: Option<std::string::String>,
    26
    27    /// storagePool is the ScaleIO Storage Pool associated with the protection domain.
    28    pub storage_pool: Option<std::string::String>,
    29
    30    /// system is the name of the storage system as configured in ScaleIO.
    31    pub system: std::string::String,
    32
    33    /// volumeName is the name of a volume already created in the ScaleIO system that is associated with this volume source.
    34    pub volume_name: Option<std::string::String>,
    35}
    36
    37impl crate::DeepMerge for ScaleIOVolumeSource {
    38    fn merge_from(&mut self, other: Self) {
    39        crate::DeepMerge::merge_from(&mut self.fs_type, other.fs_type);
    40        crate::DeepMerge::merge_from(&mut self.gateway, other.gateway);
    41        crate::DeepMerge::merge_from(&mut self.protection_domain, other.protection_domain);
    42        crate::DeepMerge::merge_from(&mut self.read_only, other.read_only);
    43        crate::DeepMerge::merge_from(&mut self.secret_ref, other.secret_ref);
    44        crate::DeepMerge::merge_from(&mut self.ssl_enabled, other.ssl_enabled);
    45        crate::DeepMerge::merge_from(&mut self.storage_mode, other.storage_mode);
    46        crate::DeepMerge::merge_from(&mut self.storage_pool, other.storage_pool);
    47        crate::DeepMerge::merge_from(&mut self.system, other.system);
    48        crate::DeepMerge::merge_from(&mut self.volume_name, other.volume_name);
    49    }
    50}
    51
    52impl<'de> crate::serde::Deserialize<'de> for ScaleIOVolumeSource {
    53    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    54        #[allow(non_camel_case_types)]
    55        enum Field {
    56            Key_fs_type,
    57            Key_gateway,
    58            Key_protection_domain,
    59            Key_read_only,
    60            Key_secret_ref,
    61            Key_ssl_enabled,
    62            Key_storage_mode,
    63            Key_storage_pool,
    64            Key_system,
    65            Key_volume_name,
    66            Other,
    67        }
    68
    69        impl<'de> crate::serde::Deserialize<'de> for Field {
    70            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    71                struct Visitor;
    72
    73                impl crate::serde::de::Visitor<'_> for Visitor {
    74                    type Value = Field;
    75
    76                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    77                        f.write_str("field identifier")
    78                    }
    79
    80                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
    81                        Ok(match v {
    82                            "fsType" => Field::Key_fs_type,
    83                            "gateway" => Field::Key_gateway,
    84                            "protectionDomain" => Field::Key_protection_domain,
    85                            "readOnly" => Field::Key_read_only,
    86                            "secretRef" => Field::Key_secret_ref,
    87                            "sslEnabled" => Field::Key_ssl_enabled,
    88                            "storageMode" => Field::Key_storage_mode,
    89                            "storagePool" => Field::Key_storage_pool,
    90                            "system" => Field::Key_system,
    91                            "volumeName" => Field::Key_volume_name,
    92                            _ => Field::Other,
    93                        })
    94                    }
    95                }
    96
    97                deserializer.deserialize_identifier(Visitor)
    98            }
    99        }
    100
    101        struct Visitor;
    102
    103        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
    104            type Value = ScaleIOVolumeSource;
    105
    106            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    107                f.write_str("ScaleIOVolumeSource")
    108            }
    109
    110            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
    111                let mut value_fs_type: Option<std::string::String> = None;
    112                let mut value_gateway: Option<std::string::String> = None;
    113                let mut value_protection_domain: Option<std::string::String> = None;
    114                let mut value_read_only: Option<bool> = None;
    115                let mut value_secret_ref: Option<crate::api::core::v1::LocalObjectReference> = None;
    116                let mut value_ssl_enabled: Option<bool> = None;
    117                let mut value_storage_mode: Option<std::string::String> = None;
    118                let mut value_storage_pool: Option<std::string::String> = None;
    119                let mut value_system: Option<std::string::String> = None;
    120                let mut value_volume_name: Option<std::string::String> = None;
    121
    122                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
    123                    match key {
    124                        Field::Key_fs_type => value_fs_type = crate::serde::de::MapAccess::next_value(&mut map)?,
    125                        Field::Key_gateway => value_gateway = crate::serde::de::MapAccess::next_value(&mut map)?,
    126                        Field::Key_protection_domain => value_protection_domain = crate::serde::de::MapAccess::next_value(&mut map)?,
    127                        Field::Key_read_only => value_read_only = crate::serde::de::MapAccess::next_value(&mut map)?,
    128                        Field::Key_secret_ref => value_secret_ref = crate::serde::de::MapAccess::next_value(&mut map)?,
    129                        Field::Key_ssl_enabled => value_ssl_enabled = crate::serde::de::MapAccess::next_value(&mut map)?,
    130                        Field::Key_storage_mode => value_storage_mode = crate::serde::de::MapAccess::next_value(&mut map)?,
    131                        Field::Key_storage_pool => value_storage_pool = crate::serde::de::MapAccess::next_value(&mut map)?,
    132                        Field::Key_system => value_system = crate::serde::de::MapAccess::next_value(&mut map)?,
    133                        Field::Key_volume_name => value_volume_name = crate::serde::de::MapAccess::next_value(&mut map)?,
    134                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
    135                    }
    136                }
    137
    138                Ok(ScaleIOVolumeSource {
    139                    fs_type: value_fs_type,
    140                    gateway: value_gateway.unwrap_or_default(),
    141                    protection_domain: value_protection_domain,
    142                    read_only: value_read_only,
    143                    secret_ref: value_secret_ref.unwrap_or_default(),
    144                    ssl_enabled: value_ssl_enabled,
    145                    storage_mode: value_storage_mode,
    146                    storage_pool: value_storage_pool,
    147                    system: value_system.unwrap_or_default(),
    148                    volume_name: value_volume_name,
    149                })
    150            }
    151        }
    152
    153        deserializer.deserialize_struct(
    154            "ScaleIOVolumeSource",
    155            &[
    156                "fsType",
    157                "gateway",
    158                "protectionDomain",
    159                "readOnly",
    160                "secretRef",
    161                "sslEnabled",
    162                "storageMode",
    163                "storagePool",
    164                "system",
    165                "volumeName",
    166            ],
    167            Visitor,
    168        )
    169    }
    170}
    171
    172impl crate::serde::Serialize for ScaleIOVolumeSource {
    173    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
    174        let mut state = serializer.serialize_struct(
    175            "ScaleIOVolumeSource",
    176            3 +
    177            self.fs_type.as_ref().map_or(0, |_| 1) +
    178            self.protection_domain.as_ref().map_or(0, |_| 1) +
    179            self.read_only.as_ref().map_or(0, |_| 1) +
    180            self.ssl_enabled.as_ref().map_or(0, |_| 1) +
    181            self.storage_mode.as_ref().map_or(0, |_| 1) +
    182            self.storage_pool.as_ref().map_or(0, |_| 1) +
    183            self.volume_name.as_ref().map_or(0, |_| 1),
    184        )?;
    185        if let Some(value) = &self.fs_type {
    186            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "fsType", value)?;
    187        }
    188        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "gateway", &self.gateway)?;
    189        if let Some(value) = &self.protection_domain {
    190            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "protectionDomain", value)?;
    191        }
    192        if let Some(value) = &self.read_only {
    193            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readOnly", value)?;
    194        }
    195        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "secretRef", &self.secret_ref)?;
    196        if let Some(value) = &self.ssl_enabled {
    197            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "sslEnabled", value)?;
    198        }
    199        if let Some(value) = &self.storage_mode {
    200            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "storageMode", value)?;
    201        }
    202        if let Some(value) = &self.storage_pool {
    203            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "storagePool", value)?;
    204        }
    205        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "system", &self.system)?;
    206        if let Some(value) = &self.volume_name {
    207            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "volumeName", value)?;
    208        }
    209        crate::serde::ser::SerializeStruct::end(state)
    210    }
    211}
    212
    213#[cfg(feature = "schemars")]
    214impl crate::schemars::JsonSchema for ScaleIOVolumeSource {
    215    fn schema_name() -> std::borrow::Cow<'static, str> {
    216        "io.k8s.api.core.v1.ScaleIOVolumeSource".into()
    217    }
    218
    219    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    220        crate::schemars::json_schema!({
    221            "description": "ScaleIOVolumeSource represents a persistent ScaleIO volume",
    222            "type": "object",
    223            "properties": {
    224                "fsType": {
    225                    "description": "fsType is the filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Default is \"xfs\".",
    226                    "type": "string",
    227                },
    228                "gateway": {
    229                    "description": "gateway is the host address of the ScaleIO API Gateway.",
    230                    "type": "string",
    231                },
    232                "protectionDomain": {
    233                    "description": "protectionDomain is the name of the ScaleIO Protection Domain for the configured storage.",
    234                    "type": "string",
    235                },
    236                "readOnly": {
    237                    "description": "readOnly Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.",
    238                    "type": "boolean",
    239                },
    240                "secretRef": ({
    241                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::LocalObjectReference>();
    242                    schema_obj.ensure_object().insert("description".into(), "secretRef references to the secret for ScaleIO user and other sensitive information. If this is not provided, Login operation will fail.".into());
    243                    schema_obj
    244                }),
    245                "sslEnabled": {
    246                    "description": "sslEnabled Flag enable/disable SSL communication with Gateway, default false",
    247                    "type": "boolean",
    248                },
    249                "storageMode": {
    250                    "description": "storageMode indicates whether the storage for a volume should be ThickProvisioned or ThinProvisioned. Default is ThinProvisioned.",
    251                    "type": "string",
    252                },
    253                "storagePool": {
    254                    "description": "storagePool is the ScaleIO Storage Pool associated with the protection domain.",
    255                    "type": "string",
    256                },
    257                "system": {
    258                    "description": "system is the name of the storage system as configured in ScaleIO.",
    259                    "type": "string",
    260                },
    261                "volumeName": {
    262                    "description": "volumeName is the name of a volume already created in the ScaleIO system that is associated with this volume source.",
    263                    "type": "string",
    264                },
    265            },
    266            "required": [
    267                "gateway",
    268                "secretRef",
    269                "system",
    270            ],
    271        })
    272    }
    273}