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

    1// Generated from definition io.k8s.api.core.v1.NodeSystemInfo
    2
    3/// NodeSystemInfo is a set of ids/uuids to uniquely identify the node.
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct NodeSystemInfo {
    6    /// The Architecture reported by the node
    7    pub architecture: std::string::String,
    8
    9    /// Boot ID reported by the node.
    10    pub boot_id: std::string::String,
    11
    12    /// ContainerRuntime Version reported by the node through runtime remote API (e.g. containerd://1.4.2).
    13    pub container_runtime_version: std::string::String,
    14
    15    /// Kernel Version reported by the node from 'uname -r' (e.g. 3.16.0-0.bpo.4-amd64).
    16    pub kernel_version: std::string::String,
    17
    18    /// Deprecated: KubeProxy Version reported by the node.
    19    pub kube_proxy_version: std::string::String,
    20
    21    /// Kubelet Version reported by the node.
    22    pub kubelet_version: std::string::String,
    23
    24    /// MachineID reported by the node. For unique machine identification in the cluster this field is preferred. Learn more from man(5) machine-id: http://man7.org/linux/man-pages/man5/machine-id.5.html
    25    pub machine_id: std::string::String,
    26
    27    /// The Operating System reported by the node
    28    pub operating_system: std::string::String,
    29
    30    /// OS Image reported by the node from /etc/os-release (e.g. Debian GNU/Linux 7 (wheezy)).
    31    pub os_image: std::string::String,
    32
    33    /// Swap Info reported by the node.
    34    pub swap: Option<crate::api::core::v1::NodeSwapStatus>,
    35
    36    /// SystemUUID reported by the node. For unique machine identification MachineID is preferred. This field is specific to Red Hat hosts https://access.redhat.com/documentation/en-us/red_hat_subscription_management/1/html/rhsm/uuid
    37    pub system_uuid: std::string::String,
    38}
    39
    40impl crate::DeepMerge for NodeSystemInfo {
    41    fn merge_from(&mut self, other: Self) {
    42        crate::DeepMerge::merge_from(&mut self.architecture, other.architecture);
    43        crate::DeepMerge::merge_from(&mut self.boot_id, other.boot_id);
    44        crate::DeepMerge::merge_from(&mut self.container_runtime_version, other.container_runtime_version);
    45        crate::DeepMerge::merge_from(&mut self.kernel_version, other.kernel_version);
    46        crate::DeepMerge::merge_from(&mut self.kube_proxy_version, other.kube_proxy_version);
    47        crate::DeepMerge::merge_from(&mut self.kubelet_version, other.kubelet_version);
    48        crate::DeepMerge::merge_from(&mut self.machine_id, other.machine_id);
    49        crate::DeepMerge::merge_from(&mut self.operating_system, other.operating_system);
    50        crate::DeepMerge::merge_from(&mut self.os_image, other.os_image);
    51        crate::DeepMerge::merge_from(&mut self.swap, other.swap);
    52        crate::DeepMerge::merge_from(&mut self.system_uuid, other.system_uuid);
    53    }
    54}
    55
    56impl<'de> crate::serde::Deserialize<'de> for NodeSystemInfo {
    57    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    58        #[allow(non_camel_case_types)]
    59        enum Field {
    60            Key_architecture,
    61            Key_boot_id,
    62            Key_container_runtime_version,
    63            Key_kernel_version,
    64            Key_kube_proxy_version,
    65            Key_kubelet_version,
    66            Key_machine_id,
    67            Key_operating_system,
    68            Key_os_image,
    69            Key_swap,
    70            Key_system_uuid,
    71            Other,
    72        }
    73
    74        impl<'de> crate::serde::Deserialize<'de> for Field {
    75            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    76                struct Visitor;
    77
    78                impl crate::serde::de::Visitor<'_> for Visitor {
    79                    type Value = Field;
    80
    81                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    82                        f.write_str("field identifier")
    83                    }
    84
    85                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
    86                        Ok(match v {
    87                            "architecture" => Field::Key_architecture,
    88                            "bootID" => Field::Key_boot_id,
    89                            "containerRuntimeVersion" => Field::Key_container_runtime_version,
    90                            "kernelVersion" => Field::Key_kernel_version,
    91                            "kubeProxyVersion" => Field::Key_kube_proxy_version,
    92                            "kubeletVersion" => Field::Key_kubelet_version,
    93                            "machineID" => Field::Key_machine_id,
    94                            "operatingSystem" => Field::Key_operating_system,
    95                            "osImage" => Field::Key_os_image,
    96                            "swap" => Field::Key_swap,
    97                            "systemUUID" => Field::Key_system_uuid,
    98                            _ => Field::Other,
    99                        })
    100                    }
    101                }
    102
    103                deserializer.deserialize_identifier(Visitor)
    104            }
    105        }
    106
    107        struct Visitor;
    108
    109        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
    110            type Value = NodeSystemInfo;
    111
    112            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    113                f.write_str("NodeSystemInfo")
    114            }
    115
    116            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
    117                let mut value_architecture: Option<std::string::String> = None;
    118                let mut value_boot_id: Option<std::string::String> = None;
    119                let mut value_container_runtime_version: Option<std::string::String> = None;
    120                let mut value_kernel_version: Option<std::string::String> = None;
    121                let mut value_kube_proxy_version: Option<std::string::String> = None;
    122                let mut value_kubelet_version: Option<std::string::String> = None;
    123                let mut value_machine_id: Option<std::string::String> = None;
    124                let mut value_operating_system: Option<std::string::String> = None;
    125                let mut value_os_image: Option<std::string::String> = None;
    126                let mut value_swap: Option<crate::api::core::v1::NodeSwapStatus> = None;
    127                let mut value_system_uuid: Option<std::string::String> = None;
    128
    129                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
    130                    match key {
    131                        Field::Key_architecture => value_architecture = crate::serde::de::MapAccess::next_value(&mut map)?,
    132                        Field::Key_boot_id => value_boot_id = crate::serde::de::MapAccess::next_value(&mut map)?,
    133                        Field::Key_container_runtime_version => value_container_runtime_version = crate::serde::de::MapAccess::next_value(&mut map)?,
    134                        Field::Key_kernel_version => value_kernel_version = crate::serde::de::MapAccess::next_value(&mut map)?,
    135                        Field::Key_kube_proxy_version => value_kube_proxy_version = crate::serde::de::MapAccess::next_value(&mut map)?,
    136                        Field::Key_kubelet_version => value_kubelet_version = crate::serde::de::MapAccess::next_value(&mut map)?,
    137                        Field::Key_machine_id => value_machine_id = crate::serde::de::MapAccess::next_value(&mut map)?,
    138                        Field::Key_operating_system => value_operating_system = crate::serde::de::MapAccess::next_value(&mut map)?,
    139                        Field::Key_os_image => value_os_image = crate::serde::de::MapAccess::next_value(&mut map)?,
    140                        Field::Key_swap => value_swap = crate::serde::de::MapAccess::next_value(&mut map)?,
    141                        Field::Key_system_uuid => value_system_uuid = crate::serde::de::MapAccess::next_value(&mut map)?,
    142                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
    143                    }
    144                }
    145
    146                Ok(NodeSystemInfo {
    147                    architecture: value_architecture.unwrap_or_default(),
    148                    boot_id: value_boot_id.unwrap_or_default(),
    149                    container_runtime_version: value_container_runtime_version.unwrap_or_default(),
    150                    kernel_version: value_kernel_version.unwrap_or_default(),
    151                    kube_proxy_version: value_kube_proxy_version.unwrap_or_default(),
    152                    kubelet_version: value_kubelet_version.unwrap_or_default(),
    153                    machine_id: value_machine_id.unwrap_or_default(),
    154                    operating_system: value_operating_system.unwrap_or_default(),
    155                    os_image: value_os_image.unwrap_or_default(),
    156                    swap: value_swap,
    157                    system_uuid: value_system_uuid.unwrap_or_default(),
    158                })
    159            }
    160        }
    161
    162        deserializer.deserialize_struct(
    163            "NodeSystemInfo",
    164            &[
    165                "architecture",
    166                "bootID",
    167                "containerRuntimeVersion",
    168                "kernelVersion",
    169                "kubeProxyVersion",
    170                "kubeletVersion",
    171                "machineID",
    172                "operatingSystem",
    173                "osImage",
    174                "swap",
    175                "systemUUID",
    176            ],
    177            Visitor,
    178        )
    179    }
    180}
    181
    182impl crate::serde::Serialize for NodeSystemInfo {
    183    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
    184        let mut state = serializer.serialize_struct(
    185            "NodeSystemInfo",
    186            10 +
    187            self.swap.as_ref().map_or(0, |_| 1),
    188        )?;
    189        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "architecture", &self.architecture)?;
    190        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "bootID", &self.boot_id)?;
    191        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "containerRuntimeVersion", &self.container_runtime_version)?;
    192        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "kernelVersion", &self.kernel_version)?;
    193        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "kubeProxyVersion", &self.kube_proxy_version)?;
    194        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "kubeletVersion", &self.kubelet_version)?;
    195        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "machineID", &self.machine_id)?;
    196        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "operatingSystem", &self.operating_system)?;
    197        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "osImage", &self.os_image)?;
    198        if let Some(value) = &self.swap {
    199            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "swap", value)?;
    200        }
    201        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "systemUUID", &self.system_uuid)?;
    202        crate::serde::ser::SerializeStruct::end(state)
    203    }
    204}
    205
    206#[cfg(feature = "schemars")]
    207impl crate::schemars::JsonSchema for NodeSystemInfo {
    208    fn schema_name() -> std::borrow::Cow<'static, str> {
    209        "io.k8s.api.core.v1.NodeSystemInfo".into()
    210    }
    211
    212    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    213        crate::schemars::json_schema!({
    214            "description": "NodeSystemInfo is a set of ids/uuids to uniquely identify the node.",
    215            "type": "object",
    216            "properties": {
    217                "architecture": {
    218                    "description": "The Architecture reported by the node",
    219                    "type": "string",
    220                },
    221                "bootID": {
    222                    "description": "Boot ID reported by the node.",
    223                    "type": "string",
    224                },
    225                "containerRuntimeVersion": {
    226                    "description": "ContainerRuntime Version reported by the node through runtime remote API (e.g. containerd://1.4.2).",
    227                    "type": "string",
    228                },
    229                "kernelVersion": {
    230                    "description": "Kernel Version reported by the node from 'uname -r' (e.g. 3.16.0-0.bpo.4-amd64).",
    231                    "type": "string",
    232                },
    233                "kubeProxyVersion": {
    234                    "description": "Deprecated: KubeProxy Version reported by the node.",
    235                    "type": "string",
    236                },
    237                "kubeletVersion": {
    238                    "description": "Kubelet Version reported by the node.",
    239                    "type": "string",
    240                },
    241                "machineID": {
    242                    "description": "MachineID reported by the node. For unique machine identification in the cluster this field is preferred. Learn more from man(5) machine-id: http://man7.org/linux/man-pages/man5/machine-id.5.html",
    243                    "type": "string",
    244                },
    245                "operatingSystem": {
    246                    "description": "The Operating System reported by the node",
    247                    "type": "string",
    248                },
    249                "osImage": {
    250                    "description": "OS Image reported by the node from /etc/os-release (e.g. Debian GNU/Linux 7 (wheezy)).",
    251                    "type": "string",
    252                },
    253                "swap": ({
    254                    let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::NodeSwapStatus>();
    255                    schema_obj.ensure_object().insert("description".into(), "Swap Info reported by the node.".into());
    256                    schema_obj
    257                }),
    258                "systemUUID": {
    259                    "description": "SystemUUID reported by the node. For unique machine identification MachineID is preferred. This field is specific to Red Hat hosts https://access.redhat.com/documentation/en-us/red_hat_subscription_management/1/html/rhsm/uuid",
    260                    "type": "string",
    261                },
    262            },
    263            "required": [
    264                "architecture",
    265                "bootID",
    266                "containerRuntimeVersion",
    267                "kernelVersion",
    268                "kubeProxyVersion",
    269                "kubeletVersion",
    270                "machineID",
    271                "operatingSystem",
    272                "osImage",
    273                "systemUUID",
    274            ],
    275        })
    276    }
    277}