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

    1// Generated from definition io.k8s.api.core.v1.FlexVolumeSource
    2
    3/// FlexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin.
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct FlexVolumeSource {
    6    /// driver is the name of the driver to use for this volume.
    7    pub driver: std::string::String,
    8
    9    /// fsType is the filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". The default filesystem depends on FlexVolume script.
    10    pub fs_type: Option<std::string::String>,
    11
    12    /// options is Optional: this field holds extra command options if any.
    13    pub options: Option<std::collections::BTreeMap<std::string::String, std::string::String>>,
    14
    15    /// readOnly is Optional: defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.
    16    pub read_only: Option<bool>,
    17
    18    /// secretRef is Optional: secretRef is reference to the secret object containing sensitive information to pass to the plugin scripts. This may be empty if no secret object is specified. If the secret object contains more than one secret, all secrets are passed to the plugin scripts.
    19    pub secret_ref: Option<crate::api::core::v1::LocalObjectReference>,
    20}
    21
    22impl crate::DeepMerge for FlexVolumeSource {
    23    fn merge_from(&mut self, other: Self) {
    24        crate::DeepMerge::merge_from(&mut self.driver, other.driver);
    25        crate::DeepMerge::merge_from(&mut self.fs_type, other.fs_type);
    26        crate::merge_strategies::map::granular(&mut self.options, other.options, |current_item, other_item| {
    27            crate::DeepMerge::merge_from(current_item, other_item);
    28        });
    29        crate::DeepMerge::merge_from(&mut self.read_only, other.read_only);
    30        crate::DeepMerge::merge_from(&mut self.secret_ref, other.secret_ref);
    31    }
    32}
    33
    34impl<'de> crate::serde::Deserialize<'de> for FlexVolumeSource {
    35    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    36        #[allow(non_camel_case_types)]
    37        enum Field {
    38            Key_driver,
    39            Key_fs_type,
    40            Key_options,
    41            Key_read_only,
    42            Key_secret_ref,
    43            Other,
    44        }
    45
    46        impl<'de> crate::serde::Deserialize<'de> for Field {
    47            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    48                struct Visitor;
    49
    50                impl crate::serde::de::Visitor<'_> for Visitor {
    51                    type Value = Field;
    52
    53                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    54                        f.write_str("field identifier")
    55                    }
    56
    57                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
    58                        Ok(match v {
    59                            "driver" => Field::Key_driver,
    60                            "fsType" => Field::Key_fs_type,
    61                            "options" => Field::Key_options,
    62                            "readOnly" => Field::Key_read_only,
    63                            "secretRef" => Field::Key_secret_ref,
    64                            _ => Field::Other,
    65                        })
    66                    }
    67                }
    68
    69                deserializer.deserialize_identifier(Visitor)
    70            }
    71        }
    72
    73        struct Visitor;
    74
    75        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
    76            type Value = FlexVolumeSource;
    77
    78            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    79                f.write_str("FlexVolumeSource")
    80            }
    81
    82            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
    83                let mut value_driver: Option<std::string::String> = None;
    84                let mut value_fs_type: Option<std::string::String> = None;
    85                let mut value_options: Option<std::collections::BTreeMap<std::string::String, std::string::String>> = None;
    86                let mut value_read_only: Option<bool> = None;
    87                let mut value_secret_ref: Option<crate::api::core::v1::LocalObjectReference> = None;
    88
    89                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
    90                    match key {
    91                        Field::Key_driver => value_driver = crate::serde::de::MapAccess::next_value(&mut map)?,
    92                        Field::Key_fs_type => value_fs_type = crate::serde::de::MapAccess::next_value(&mut map)?,
    93                        Field::Key_options => value_options = crate::serde::de::MapAccess::next_value(&mut map)?,
    94                        Field::Key_read_only => value_read_only = crate::serde::de::MapAccess::next_value(&mut map)?,
    95                        Field::Key_secret_ref => value_secret_ref = crate::serde::de::MapAccess::next_value(&mut map)?,
    96                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
    97                    }
    98                }
    99
    100                Ok(FlexVolumeSource {
    101                    driver: value_driver.unwrap_or_default(),
    102                    fs_type: value_fs_type,
    103                    options: value_options,
    104                    read_only: value_read_only,
    105                    secret_ref: value_secret_ref,
    106                })
    107            }
    108        }
    109
    110        deserializer.deserialize_struct(
    111            "FlexVolumeSource",
    112            &[
    113                "driver",
    114                "fsType",
    115                "options",
    116                "readOnly",
    117                "secretRef",
    118            ],
    119            Visitor,
    120        )
    121    }
    122}
    123
    124impl crate::serde::Serialize for FlexVolumeSource {
    125    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
    126        let mut state = serializer.serialize_struct(
    127            "FlexVolumeSource",
    128            1 +
    129            self.fs_type.as_ref().map_or(0, |_| 1) +
    130            self.options.as_ref().map_or(0, |_| 1) +
    131            self.read_only.as_ref().map_or(0, |_| 1) +
    132            self.secret_ref.as_ref().map_or(0, |_| 1),
    133        )?;
    134        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "driver", &self.driver)?;
    135        if let Some(value) = &self.fs_type {
    136            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "fsType", value)?;
    137        }
    138        if let Some(value) = &self.options {
    139            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "options", value)?;
    140        }
    141        if let Some(value) = &self.read_only {
    142            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readOnly", value)?;
    143        }
    144        if let Some(value) = &self.secret_ref {
    145            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "secretRef", value)?;
    146        }
    147        crate::serde::ser::SerializeStruct::end(state)
    148    }
    149}
    150
    151#[cfg(feature = "schemars")]
    152impl crate::schemars::JsonSchema for FlexVolumeSource {
    153    fn schema_name() -> std::borrow::Cow<'static, str> {
    154        "io.k8s.api.core.v1.FlexVolumeSource".into()
    155    }
    156
    157    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    158        crate::schemars::json_schema!({
    159            "description": "FlexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin.",
    160            "type": "object",
    161            "properties": {
    162                "driver": {
    163                    "description": "driver is the name of the driver to use for this volume.",
    164                    "type": "string",
    165                },
    166                "fsType": {
    167                    "description": "fsType is the filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". The default filesystem depends on FlexVolume script.",
    168                    "type": "string",
    169                },
    170                "options": {
    171                    "description": "options is Optional: this field holds extra command options if any.",
    172                    "type": "object",
    173                    "additionalProperties": {
    174                        "type": "string",
    175                    },
    176                },
    177                "readOnly": {
    178                    "description": "readOnly is Optional: defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.",
    179                    "type": "boolean",
    180                },
    181                "secretRef": ({
    182                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::LocalObjectReference>();
    183                    schema_obj.ensure_object().insert("description".into(), "secretRef is Optional: secretRef is reference to the secret object containing sensitive information to pass to the plugin scripts. This may be empty if no secret object is specified. If the secret object contains more than one secret, all secrets are passed to the plugin scripts.".into());
    184                    schema_obj
    185                }),
    186            },
    187            "required": [
    188                "driver",
    189            ],
    190        })
    191    }
    192}