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

    1// Generated from definition io.k8s.api.core.v1.NodeSpec
    2
    3/// NodeSpec describes the attributes that a node is created with.
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct NodeSpec {
    6    /// Deprecated: Previously used to specify the source of the node's configuration for the DynamicKubeletConfig feature. This feature is removed.
    7    pub config_source: Option<crate::api::core::v1::NodeConfigSource>,
    8
    9    /// Deprecated. Not all kubelets will set this field. Remove field after 1.13. see: https://issues.k8s.io/61966
    10    pub external_id: Option<std::string::String>,
    11
    12    /// PodCIDR represents the pod IP range assigned to the node.
    13    pub pod_cidr: Option<std::string::String>,
    14
    15    /// podCIDRs represents the IP ranges assigned to the node for usage by Pods on that node. If this field is specified, the 0th entry must match the podCIDR field. It may contain at most 1 value for each of IPv4 and IPv6.
    16    pub pod_cidrs: Option<std::vec::Vec<std::string::String>>,
    17
    18    /// ID of the node assigned by the cloud provider in the format: \<ProviderName\>://\<ProviderSpecificNodeID\>
    19    pub provider_id: Option<std::string::String>,
    20
    21    /// If specified, the node's taints.
    22    pub taints: Option<std::vec::Vec<crate::api::core::v1::Taint>>,
    23
    24    /// Unschedulable controls node schedulability of new pods. By default, node is schedulable. More info: https://kubernetes.io/docs/concepts/nodes/node/#manual-node-administration
    25    pub unschedulable: Option<bool>,
    26}
    27
    28impl crate::DeepMerge for NodeSpec {
    29    fn merge_from(&mut self, other: Self) {
    30        crate::DeepMerge::merge_from(&mut self.config_source, other.config_source);
    31        crate::DeepMerge::merge_from(&mut self.external_id, other.external_id);
    32        crate::DeepMerge::merge_from(&mut self.pod_cidr, other.pod_cidr);
    33        crate::merge_strategies::list::set(&mut self.pod_cidrs, other.pod_cidrs);
    34        crate::DeepMerge::merge_from(&mut self.provider_id, other.provider_id);
    35        crate::merge_strategies::list::atomic(&mut self.taints, other.taints);
    36        crate::DeepMerge::merge_from(&mut self.unschedulable, other.unschedulable);
    37    }
    38}
    39
    40impl<'de> crate::serde::Deserialize<'de> for NodeSpec {
    41    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    42        #[allow(non_camel_case_types)]
    43        enum Field {
    44            Key_config_source,
    45            Key_external_id,
    46            Key_pod_cidr,
    47            Key_pod_cidrs,
    48            Key_provider_id,
    49            Key_taints,
    50            Key_unschedulable,
    51            Other,
    52        }
    53
    54        impl<'de> crate::serde::Deserialize<'de> for Field {
    55            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    56                struct Visitor;
    57
    58                impl crate::serde::de::Visitor<'_> for Visitor {
    59                    type Value = Field;
    60
    61                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    62                        f.write_str("field identifier")
    63                    }
    64
    65                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
    66                        Ok(match v {
    67                            "configSource" => Field::Key_config_source,
    68                            "externalID" => Field::Key_external_id,
    69                            "podCIDR" => Field::Key_pod_cidr,
    70                            "podCIDRs" => Field::Key_pod_cidrs,
    71                            "providerID" => Field::Key_provider_id,
    72                            "taints" => Field::Key_taints,
    73                            "unschedulable" => Field::Key_unschedulable,
    74                            _ => Field::Other,
    75                        })
    76                    }
    77                }
    78
    79                deserializer.deserialize_identifier(Visitor)
    80            }
    81        }
    82
    83        struct Visitor;
    84
    85        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
    86            type Value = NodeSpec;
    87
    88            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    89                f.write_str("NodeSpec")
    90            }
    91
    92            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
    93                let mut value_config_source: Option<crate::api::core::v1::NodeConfigSource> = None;
    94                let mut value_external_id: Option<std::string::String> = None;
    95                let mut value_pod_cidr: Option<std::string::String> = None;
    96                let mut value_pod_cidrs: Option<std::vec::Vec<std::string::String>> = None;
    97                let mut value_provider_id: Option<std::string::String> = None;
    98                let mut value_taints: Option<std::vec::Vec<crate::api::core::v1::Taint>> = None;
    99                let mut value_unschedulable: Option<bool> = None;
    100
    101                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
    102                    match key {
    103                        Field::Key_config_source => value_config_source = crate::serde::de::MapAccess::next_value(&mut map)?,
    104                        Field::Key_external_id => value_external_id = crate::serde::de::MapAccess::next_value(&mut map)?,
    105                        Field::Key_pod_cidr => value_pod_cidr = crate::serde::de::MapAccess::next_value(&mut map)?,
    106                        Field::Key_pod_cidrs => value_pod_cidrs = crate::serde::de::MapAccess::next_value(&mut map)?,
    107                        Field::Key_provider_id => value_provider_id = crate::serde::de::MapAccess::next_value(&mut map)?,
    108                        Field::Key_taints => value_taints = crate::serde::de::MapAccess::next_value(&mut map)?,
    109                        Field::Key_unschedulable => value_unschedulable = crate::serde::de::MapAccess::next_value(&mut map)?,
    110                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
    111                    }
    112                }
    113
    114                Ok(NodeSpec {
    115                    config_source: value_config_source,
    116                    external_id: value_external_id,
    117                    pod_cidr: value_pod_cidr,
    118                    pod_cidrs: value_pod_cidrs,
    119                    provider_id: value_provider_id,
    120                    taints: value_taints,
    121                    unschedulable: value_unschedulable,
    122                })
    123            }
    124        }
    125
    126        deserializer.deserialize_struct(
    127            "NodeSpec",
    128            &[
    129                "configSource",
    130                "externalID",
    131                "podCIDR",
    132                "podCIDRs",
    133                "providerID",
    134                "taints",
    135                "unschedulable",
    136            ],
    137            Visitor,
    138        )
    139    }
    140}
    141
    142impl crate::serde::Serialize for NodeSpec {
    143    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
    144        let mut state = serializer.serialize_struct(
    145            "NodeSpec",
    146            self.config_source.as_ref().map_or(0, |_| 1) +
    147            self.external_id.as_ref().map_or(0, |_| 1) +
    148            self.pod_cidr.as_ref().map_or(0, |_| 1) +
    149            self.pod_cidrs.as_ref().map_or(0, |_| 1) +
    150            self.provider_id.as_ref().map_or(0, |_| 1) +
    151            self.taints.as_ref().map_or(0, |_| 1) +
    152            self.unschedulable.as_ref().map_or(0, |_| 1),
    153        )?;
    154        if let Some(value) = &self.config_source {
    155            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "configSource", value)?;
    156        }
    157        if let Some(value) = &self.external_id {
    158            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "externalID", value)?;
    159        }
    160        if let Some(value) = &self.pod_cidr {
    161            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "podCIDR", value)?;
    162        }
    163        if let Some(value) = &self.pod_cidrs {
    164            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "podCIDRs", value)?;
    165        }
    166        if let Some(value) = &self.provider_id {
    167            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "providerID", value)?;
    168        }
    169        if let Some(value) = &self.taints {
    170            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "taints", value)?;
    171        }
    172        if let Some(value) = &self.unschedulable {
    173            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "unschedulable", value)?;
    174        }
    175        crate::serde::ser::SerializeStruct::end(state)
    176    }
    177}
    178
    179#[cfg(feature = "schemars")]
    180impl crate::schemars::JsonSchema for NodeSpec {
    181    fn schema_name() -> std::borrow::Cow<'static, str> {
    182        "io.k8s.api.core.v1.NodeSpec".into()
    183    }
    184
    185    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    186        crate::schemars::json_schema!({
    187            "description": "NodeSpec describes the attributes that a node is created with.",
    188            "type": "object",
    189            "properties": {
    190                "configSource": ({
    191                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::NodeConfigSource>();
    192                    schema_obj.ensure_object().insert("description".into(), "Deprecated: Previously used to specify the source of the node's configuration for the DynamicKubeletConfig feature. This feature is removed.".into());
    193                    schema_obj
    194                }),
    195                "externalID": {
    196                    "description": "Deprecated. Not all kubelets will set this field. Remove field after 1.13. see: https://issues.k8s.io/61966",
    197                    "type": "string",
    198                },
    199                "podCIDR": {
    200                    "description": "PodCIDR represents the pod IP range assigned to the node.",
    201                    "type": "string",
    202                },
    203                "podCIDRs": {
    204                    "description": "podCIDRs represents the IP ranges assigned to the node for usage by Pods on that node. If this field is specified, the 0th entry must match the podCIDR field. It may contain at most 1 value for each of IPv4 and IPv6.",
    205                    "type": "array",
    206                    "items": {
    207                        "type": "string",
    208                    },
    209                },
    210                "providerID": {
    211                    "description": "ID of the node assigned by the cloud provider in the format: <ProviderName>://<ProviderSpecificNodeID>",
    212                    "type": "string",
    213                },
    214                "taints": {
    215                    "description": "If specified, the node's taints.",
    216                    "type": "array",
    217                    "items": (__gen.subschema_for::<crate::api::core::v1::Taint>()),
    218                },
    219                "unschedulable": {
    220                    "description": "Unschedulable controls node schedulability of new pods. By default, node is schedulable. More info: https://kubernetes.io/docs/concepts/nodes/node/#manual-node-administration",
    221                    "type": "boolean",
    222                },
    223            },
    224        })
    225    }
    226}