#
k8s_openapi/v1_35/apimachinery/pkg/version/
info.rs

    1// Generated from definition io.k8s.apimachinery.pkg.version.Info
    2
    3/// Info contains versioning information. how we'll want to distribute that information.
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct Info {
    6    pub build_date: std::string::String,
    7
    8    pub compiler: std::string::String,
    9
    10    /// EmulationMajor is the major version of the emulation version
    11    pub emulation_major: Option<std::string::String>,
    12
    13    /// EmulationMinor is the minor version of the emulation version
    14    pub emulation_minor: Option<std::string::String>,
    15
    16    pub git_commit: std::string::String,
    17
    18    pub git_tree_state: std::string::String,
    19
    20    pub git_version: std::string::String,
    21
    22    pub go_version: std::string::String,
    23
    24    /// Major is the major version of the binary version
    25    pub major: std::string::String,
    26
    27    /// MinCompatibilityMajor is the major version of the minimum compatibility version
    28    pub min_compatibility_major: Option<std::string::String>,
    29
    30    /// MinCompatibilityMinor is the minor version of the minimum compatibility version
    31    pub min_compatibility_minor: Option<std::string::String>,
    32
    33    /// Minor is the minor version of the binary version
    34    pub minor: std::string::String,
    35
    36    pub platform: std::string::String,
    37}
    38
    39impl crate::DeepMerge for Info {
    40    fn merge_from(&mut self, other: Self) {
    41        crate::DeepMerge::merge_from(&mut self.build_date, other.build_date);
    42        crate::DeepMerge::merge_from(&mut self.compiler, other.compiler);
    43        crate::DeepMerge::merge_from(&mut self.emulation_major, other.emulation_major);
    44        crate::DeepMerge::merge_from(&mut self.emulation_minor, other.emulation_minor);
    45        crate::DeepMerge::merge_from(&mut self.git_commit, other.git_commit);
    46        crate::DeepMerge::merge_from(&mut self.git_tree_state, other.git_tree_state);
    47        crate::DeepMerge::merge_from(&mut self.git_version, other.git_version);
    48        crate::DeepMerge::merge_from(&mut self.go_version, other.go_version);
    49        crate::DeepMerge::merge_from(&mut self.major, other.major);
    50        crate::DeepMerge::merge_from(&mut self.min_compatibility_major, other.min_compatibility_major);
    51        crate::DeepMerge::merge_from(&mut self.min_compatibility_minor, other.min_compatibility_minor);
    52        crate::DeepMerge::merge_from(&mut self.minor, other.minor);
    53        crate::DeepMerge::merge_from(&mut self.platform, other.platform);
    54    }
    55}
    56
    57impl<'de> crate::serde::Deserialize<'de> for Info {
    58    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    59        #[allow(non_camel_case_types)]
    60        enum Field {
    61            Key_build_date,
    62            Key_compiler,
    63            Key_emulation_major,
    64            Key_emulation_minor,
    65            Key_git_commit,
    66            Key_git_tree_state,
    67            Key_git_version,
    68            Key_go_version,
    69            Key_major,
    70            Key_min_compatibility_major,
    71            Key_min_compatibility_minor,
    72            Key_minor,
    73            Key_platform,
    74            Other,
    75        }
    76
    77        impl<'de> crate::serde::Deserialize<'de> for Field {
    78            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    79                struct Visitor;
    80
    81                impl crate::serde::de::Visitor<'_> for Visitor {
    82                    type Value = Field;
    83
    84                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    85                        f.write_str("field identifier")
    86                    }
    87
    88                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
    89                        Ok(match v {
    90                            "buildDate" => Field::Key_build_date,
    91                            "compiler" => Field::Key_compiler,
    92                            "emulationMajor" => Field::Key_emulation_major,
    93                            "emulationMinor" => Field::Key_emulation_minor,
    94                            "gitCommit" => Field::Key_git_commit,
    95                            "gitTreeState" => Field::Key_git_tree_state,
    96                            "gitVersion" => Field::Key_git_version,
    97                            "goVersion" => Field::Key_go_version,
    98                            "major" => Field::Key_major,
    99                            "minCompatibilityMajor" => Field::Key_min_compatibility_major,
    100                            "minCompatibilityMinor" => Field::Key_min_compatibility_minor,
    101                            "minor" => Field::Key_minor,
    102                            "platform" => Field::Key_platform,
    103                            _ => Field::Other,
    104                        })
    105                    }
    106                }
    107
    108                deserializer.deserialize_identifier(Visitor)
    109            }
    110        }
    111
    112        struct Visitor;
    113
    114        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
    115            type Value = Info;
    116
    117            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    118                f.write_str("Info")
    119            }
    120
    121            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
    122                let mut value_build_date: Option<std::string::String> = None;
    123                let mut value_compiler: Option<std::string::String> = None;
    124                let mut value_emulation_major: Option<std::string::String> = None;
    125                let mut value_emulation_minor: Option<std::string::String> = None;
    126                let mut value_git_commit: Option<std::string::String> = None;
    127                let mut value_git_tree_state: Option<std::string::String> = None;
    128                let mut value_git_version: Option<std::string::String> = None;
    129                let mut value_go_version: Option<std::string::String> = None;
    130                let mut value_major: Option<std::string::String> = None;
    131                let mut value_min_compatibility_major: Option<std::string::String> = None;
    132                let mut value_min_compatibility_minor: Option<std::string::String> = None;
    133                let mut value_minor: Option<std::string::String> = None;
    134                let mut value_platform: Option<std::string::String> = None;
    135
    136                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
    137                    match key {
    138                        Field::Key_build_date => value_build_date = crate::serde::de::MapAccess::next_value(&mut map)?,
    139                        Field::Key_compiler => value_compiler = crate::serde::de::MapAccess::next_value(&mut map)?,
    140                        Field::Key_emulation_major => value_emulation_major = crate::serde::de::MapAccess::next_value(&mut map)?,
    141                        Field::Key_emulation_minor => value_emulation_minor = crate::serde::de::MapAccess::next_value(&mut map)?,
    142                        Field::Key_git_commit => value_git_commit = crate::serde::de::MapAccess::next_value(&mut map)?,
    143                        Field::Key_git_tree_state => value_git_tree_state = crate::serde::de::MapAccess::next_value(&mut map)?,
    144                        Field::Key_git_version => value_git_version = crate::serde::de::MapAccess::next_value(&mut map)?,
    145                        Field::Key_go_version => value_go_version = crate::serde::de::MapAccess::next_value(&mut map)?,
    146                        Field::Key_major => value_major = crate::serde::de::MapAccess::next_value(&mut map)?,
    147                        Field::Key_min_compatibility_major => value_min_compatibility_major = crate::serde::de::MapAccess::next_value(&mut map)?,
    148                        Field::Key_min_compatibility_minor => value_min_compatibility_minor = crate::serde::de::MapAccess::next_value(&mut map)?,
    149                        Field::Key_minor => value_minor = crate::serde::de::MapAccess::next_value(&mut map)?,
    150                        Field::Key_platform => value_platform = crate::serde::de::MapAccess::next_value(&mut map)?,
    151                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
    152                    }
    153                }
    154
    155                Ok(Info {
    156                    build_date: value_build_date.unwrap_or_default(),
    157                    compiler: value_compiler.unwrap_or_default(),
    158                    emulation_major: value_emulation_major,
    159                    emulation_minor: value_emulation_minor,
    160                    git_commit: value_git_commit.unwrap_or_default(),
    161                    git_tree_state: value_git_tree_state.unwrap_or_default(),
    162                    git_version: value_git_version.unwrap_or_default(),
    163                    go_version: value_go_version.unwrap_or_default(),
    164                    major: value_major.unwrap_or_default(),
    165                    min_compatibility_major: value_min_compatibility_major,
    166                    min_compatibility_minor: value_min_compatibility_minor,
    167                    minor: value_minor.unwrap_or_default(),
    168                    platform: value_platform.unwrap_or_default(),
    169                })
    170            }
    171        }
    172
    173        deserializer.deserialize_struct(
    174            "Info",
    175            &[
    176                "buildDate",
    177                "compiler",
    178                "emulationMajor",
    179                "emulationMinor",
    180                "gitCommit",
    181                "gitTreeState",
    182                "gitVersion",
    183                "goVersion",
    184                "major",
    185                "minCompatibilityMajor",
    186                "minCompatibilityMinor",
    187                "minor",
    188                "platform",
    189            ],
    190            Visitor,
    191        )
    192    }
    193}
    194
    195impl crate::serde::Serialize for Info {
    196    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
    197        let mut state = serializer.serialize_struct(
    198            "Info",
    199            9 +
    200            self.emulation_major.as_ref().map_or(0, |_| 1) +
    201            self.emulation_minor.as_ref().map_or(0, |_| 1) +
    202            self.min_compatibility_major.as_ref().map_or(0, |_| 1) +
    203            self.min_compatibility_minor.as_ref().map_or(0, |_| 1),
    204        )?;
    205        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "buildDate", &self.build_date)?;
    206        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "compiler", &self.compiler)?;
    207        if let Some(value) = &self.emulation_major {
    208            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "emulationMajor", value)?;
    209        }
    210        if let Some(value) = &self.emulation_minor {
    211            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "emulationMinor", value)?;
    212        }
    213        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "gitCommit", &self.git_commit)?;
    214        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "gitTreeState", &self.git_tree_state)?;
    215        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "gitVersion", &self.git_version)?;
    216        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "goVersion", &self.go_version)?;
    217        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "major", &self.major)?;
    218        if let Some(value) = &self.min_compatibility_major {
    219            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "minCompatibilityMajor", value)?;
    220        }
    221        if let Some(value) = &self.min_compatibility_minor {
    222            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "minCompatibilityMinor", value)?;
    223        }
    224        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "minor", &self.minor)?;
    225        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "platform", &self.platform)?;
    226        crate::serde::ser::SerializeStruct::end(state)
    227    }
    228}
    229
    230#[cfg(feature = "schemars")]
    231impl crate::schemars::JsonSchema for Info {
    232    fn schema_name() -> std::borrow::Cow<'static, str> {
    233        "io.k8s.apimachinery.pkg.version.Info".into()
    234    }
    235
    236    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    237        crate::schemars::json_schema!({
    238            "description": "Info contains versioning information. how we'll want to distribute that information.",
    239            "type": "object",
    240            "properties": {
    241                "buildDate": {
    242                    "type": "string",
    243                },
    244                "compiler": {
    245                    "type": "string",
    246                },
    247                "emulationMajor": {
    248                    "description": "EmulationMajor is the major version of the emulation version",
    249                    "type": "string",
    250                },
    251                "emulationMinor": {
    252                    "description": "EmulationMinor is the minor version of the emulation version",
    253                    "type": "string",
    254                },
    255                "gitCommit": {
    256                    "type": "string",
    257                },
    258                "gitTreeState": {
    259                    "type": "string",
    260                },
    261                "gitVersion": {
    262                    "type": "string",
    263                },
    264                "goVersion": {
    265                    "type": "string",
    266                },
    267                "major": {
    268                    "description": "Major is the major version of the binary version",
    269                    "type": "string",
    270                },
    271                "minCompatibilityMajor": {
    272                    "description": "MinCompatibilityMajor is the major version of the minimum compatibility version",
    273                    "type": "string",
    274                },
    275                "minCompatibilityMinor": {
    276                    "description": "MinCompatibilityMinor is the minor version of the minimum compatibility version",
    277                    "type": "string",
    278                },
    279                "minor": {
    280                    "description": "Minor is the minor version of the binary version",
    281                    "type": "string",
    282                },
    283                "platform": {
    284                    "type": "string",
    285                },
    286            },
    287            "required": [
    288                "buildDate",
    289                "compiler",
    290                "gitCommit",
    291                "gitTreeState",
    292                "gitVersion",
    293                "goVersion",
    294                "major",
    295                "minor",
    296                "platform",
    297            ],
    298        })
    299    }
    300}