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

    1// Generated from definition io.k8s.api.core.v1.ClusterTrustBundleProjection
    2
    3/// ClusterTrustBundleProjection describes how to select a set of ClusterTrustBundle objects and project their contents into the pod filesystem.
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct ClusterTrustBundleProjection {
    6    /// Select all ClusterTrustBundles that match this label selector.  Only has effect if signerName is set.  Mutually-exclusive with name.  If unset, interpreted as "match nothing".  If set but empty, interpreted as "match everything".
    7    pub label_selector: Option<crate::apimachinery::pkg::apis::meta::v1::LabelSelector>,
    8
    9    /// Select a single ClusterTrustBundle by object name.  Mutually-exclusive with signerName and labelSelector.
    10    pub name: Option<std::string::String>,
    11
    12    /// If true, don't block pod startup if the referenced ClusterTrustBundle(s) aren't available.  If using name, then the named ClusterTrustBundle is allowed not to exist.  If using signerName, then the combination of signerName and labelSelector is allowed to match zero ClusterTrustBundles.
    13    pub optional: Option<bool>,
    14
    15    /// Relative path from the volume root to write the bundle.
    16    pub path: std::string::String,
    17
    18    /// Select all ClusterTrustBundles that match this signer name. Mutually-exclusive with name.  The contents of all selected ClusterTrustBundles will be unified and deduplicated.
    19    pub signer_name: Option<std::string::String>,
    20}
    21
    22impl crate::DeepMerge for ClusterTrustBundleProjection {
    23    fn merge_from(&mut self, other: Self) {
    24        crate::DeepMerge::merge_from(&mut self.label_selector, other.label_selector);
    25        crate::DeepMerge::merge_from(&mut self.name, other.name);
    26        crate::DeepMerge::merge_from(&mut self.optional, other.optional);
    27        crate::DeepMerge::merge_from(&mut self.path, other.path);
    28        crate::DeepMerge::merge_from(&mut self.signer_name, other.signer_name);
    29    }
    30}
    31
    32impl<'de> crate::serde::Deserialize<'de> for ClusterTrustBundleProjection {
    33    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    34        #[allow(non_camel_case_types)]
    35        enum Field {
    36            Key_label_selector,
    37            Key_name,
    38            Key_optional,
    39            Key_path,
    40            Key_signer_name,
    41            Other,
    42        }
    43
    44        impl<'de> crate::serde::Deserialize<'de> for Field {
    45            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    46                struct Visitor;
    47
    48                impl crate::serde::de::Visitor<'_> for Visitor {
    49                    type Value = Field;
    50
    51                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    52                        f.write_str("field identifier")
    53                    }
    54
    55                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
    56                        Ok(match v {
    57                            "labelSelector" => Field::Key_label_selector,
    58                            "name" => Field::Key_name,
    59                            "optional" => Field::Key_optional,
    60                            "path" => Field::Key_path,
    61                            "signerName" => Field::Key_signer_name,
    62                            _ => Field::Other,
    63                        })
    64                    }
    65                }
    66
    67                deserializer.deserialize_identifier(Visitor)
    68            }
    69        }
    70
    71        struct Visitor;
    72
    73        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
    74            type Value = ClusterTrustBundleProjection;
    75
    76            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    77                f.write_str("ClusterTrustBundleProjection")
    78            }
    79
    80            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
    81                let mut value_label_selector: Option<crate::apimachinery::pkg::apis::meta::v1::LabelSelector> = None;
    82                let mut value_name: Option<std::string::String> = None;
    83                let mut value_optional: Option<bool> = None;
    84                let mut value_path: Option<std::string::String> = None;
    85                let mut value_signer_name: Option<std::string::String> = None;
    86
    87                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
    88                    match key {
    89                        Field::Key_label_selector => value_label_selector = crate::serde::de::MapAccess::next_value(&mut map)?,
    90                        Field::Key_name => value_name = crate::serde::de::MapAccess::next_value(&mut map)?,
    91                        Field::Key_optional => value_optional = crate::serde::de::MapAccess::next_value(&mut map)?,
    92                        Field::Key_path => value_path = crate::serde::de::MapAccess::next_value(&mut map)?,
    93                        Field::Key_signer_name => value_signer_name = crate::serde::de::MapAccess::next_value(&mut map)?,
    94                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
    95                    }
    96                }
    97
    98                Ok(ClusterTrustBundleProjection {
    99                    label_selector: value_label_selector,
    100                    name: value_name,
    101                    optional: value_optional,
    102                    path: value_path.unwrap_or_default(),
    103                    signer_name: value_signer_name,
    104                })
    105            }
    106        }
    107
    108        deserializer.deserialize_struct(
    109            "ClusterTrustBundleProjection",
    110            &[
    111                "labelSelector",
    112                "name",
    113                "optional",
    114                "path",
    115                "signerName",
    116            ],
    117            Visitor,
    118        )
    119    }
    120}
    121
    122impl crate::serde::Serialize for ClusterTrustBundleProjection {
    123    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
    124        let mut state = serializer.serialize_struct(
    125            "ClusterTrustBundleProjection",
    126            1 +
    127            self.label_selector.as_ref().map_or(0, |_| 1) +
    128            self.name.as_ref().map_or(0, |_| 1) +
    129            self.optional.as_ref().map_or(0, |_| 1) +
    130            self.signer_name.as_ref().map_or(0, |_| 1),
    131        )?;
    132        if let Some(value) = &self.label_selector {
    133            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "labelSelector", value)?;
    134        }
    135        if let Some(value) = &self.name {
    136            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "name", value)?;
    137        }
    138        if let Some(value) = &self.optional {
    139            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "optional", value)?;
    140        }
    141        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "path", &self.path)?;
    142        if let Some(value) = &self.signer_name {
    143            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "signerName", value)?;
    144        }
    145        crate::serde::ser::SerializeStruct::end(state)
    146    }
    147}
    148
    149#[cfg(feature = "schemars")]
    150impl crate::schemars::JsonSchema for ClusterTrustBundleProjection {
    151    fn schema_name() -> std::borrow::Cow<'static, str> {
    152        "io.k8s.api.core.v1.ClusterTrustBundleProjection".into()
    153    }
    154
    155    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    156        crate::schemars::json_schema!({
    157            "description": "ClusterTrustBundleProjection describes how to select a set of ClusterTrustBundle objects and project their contents into the pod filesystem.",
    158            "type": "object",
    159            "properties": {
    160                "labelSelector": ({
    161                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::LabelSelector>();
    162                    schema_obj.ensure_object().insert("description".into(), "Select all ClusterTrustBundles that match this label selector.  Only has effect if signerName is set.  Mutually-exclusive with name.  If unset, interpreted as \"match nothing\".  If set but empty, interpreted as \"match everything\".".into());
    163                    schema_obj
    164                }),
    165                "name": {
    166                    "description": "Select a single ClusterTrustBundle by object name.  Mutually-exclusive with signerName and labelSelector.",
    167                    "type": "string",
    168                },
    169                "optional": {
    170                    "description": "If true, don't block pod startup if the referenced ClusterTrustBundle(s) aren't available.  If using name, then the named ClusterTrustBundle is allowed not to exist.  If using signerName, then the combination of signerName and labelSelector is allowed to match zero ClusterTrustBundles.",
    171                    "type": "boolean",
    172                },
    173                "path": {
    174                    "description": "Relative path from the volume root to write the bundle.",
    175                    "type": "string",
    176                },
    177                "signerName": {
    178                    "description": "Select all ClusterTrustBundles that match this signer name. Mutually-exclusive with name.  The contents of all selected ClusterTrustBundles will be unified and deduplicated.",
    179                    "type": "string",
    180                },
    181            },
    182            "required": [
    183                "path",
    184            ],
    185        })
    186    }
    187}