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

    1// Generated from definition io.k8s.api.core.v1.PodCondition
    2
    3/// PodCondition contains details for the current condition of this pod.
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct PodCondition {
    6    /// Last time we probed the condition.
    7    pub last_probe_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time>,
    8
    9    /// Last time the condition transitioned from one status to another.
    10    pub last_transition_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time>,
    11
    12    /// Human-readable message indicating details about last transition.
    13    pub message: Option<std::string::String>,
    14
    15    /// If set, this represents the .metadata.generation that the pod condition was set based upon. The PodObservedGenerationTracking feature gate must be enabled to use this field.
    16    pub observed_generation: Option<i64>,
    17
    18    /// Unique, one-word, CamelCase reason for the condition's last transition.
    19    pub reason: Option<std::string::String>,
    20
    21    /// Status is the status of the condition. Can be True, False, Unknown. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-conditions
    22    pub status: std::string::String,
    23
    24    /// Type is the type of the condition. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-conditions
    25    pub type_: std::string::String,
    26}
    27
    28impl crate::DeepMerge for PodCondition {
    29    fn merge_from(&mut self, other: Self) {
    30        crate::DeepMerge::merge_from(&mut self.last_probe_time, other.last_probe_time);
    31        crate::DeepMerge::merge_from(&mut self.last_transition_time, other.last_transition_time);
    32        crate::DeepMerge::merge_from(&mut self.message, other.message);
    33        crate::DeepMerge::merge_from(&mut self.observed_generation, other.observed_generation);
    34        crate::DeepMerge::merge_from(&mut self.reason, other.reason);
    35        crate::DeepMerge::merge_from(&mut self.status, other.status);
    36        crate::DeepMerge::merge_from(&mut self.type_, other.type_);
    37    }
    38}
    39
    40impl<'de> crate::serde::Deserialize<'de> for PodCondition {
    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_last_probe_time,
    45            Key_last_transition_time,
    46            Key_message,
    47            Key_observed_generation,
    48            Key_reason,
    49            Key_status,
    50            Key_type_,
    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                            "lastProbeTime" => Field::Key_last_probe_time,
    68                            "lastTransitionTime" => Field::Key_last_transition_time,
    69                            "message" => Field::Key_message,
    70                            "observedGeneration" => Field::Key_observed_generation,
    71                            "reason" => Field::Key_reason,
    72                            "status" => Field::Key_status,
    73                            "type" => Field::Key_type_,
    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 = PodCondition;
    87
    88            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    89                f.write_str("PodCondition")
    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_last_probe_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time> = None;
    94                let mut value_last_transition_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time> = None;
    95                let mut value_message: Option<std::string::String> = None;
    96                let mut value_observed_generation: Option<i64> = None;
    97                let mut value_reason: Option<std::string::String> = None;
    98                let mut value_status: Option<std::string::String> = None;
    99                let mut value_type_: Option<std::string::String> = None;
    100
    101                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
    102                    match key {
    103                        Field::Key_last_probe_time => value_last_probe_time = crate::serde::de::MapAccess::next_value(&mut map)?,
    104                        Field::Key_last_transition_time => value_last_transition_time = crate::serde::de::MapAccess::next_value(&mut map)?,
    105                        Field::Key_message => value_message = crate::serde::de::MapAccess::next_value(&mut map)?,
    106                        Field::Key_observed_generation => value_observed_generation = crate::serde::de::MapAccess::next_value(&mut map)?,
    107                        Field::Key_reason => value_reason = crate::serde::de::MapAccess::next_value(&mut map)?,
    108                        Field::Key_status => value_status = crate::serde::de::MapAccess::next_value(&mut map)?,
    109                        Field::Key_type_ => value_type_ = 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(PodCondition {
    115                    last_probe_time: value_last_probe_time,
    116                    last_transition_time: value_last_transition_time,
    117                    message: value_message,
    118                    observed_generation: value_observed_generation,
    119                    reason: value_reason,
    120                    status: value_status.unwrap_or_default(),
    121                    type_: value_type_.unwrap_or_default(),
    122                })
    123            }
    124        }
    125
    126        deserializer.deserialize_struct(
    127            "PodCondition",
    128            &[
    129                "lastProbeTime",
    130                "lastTransitionTime",
    131                "message",
    132                "observedGeneration",
    133                "reason",
    134                "status",
    135                "type",
    136            ],
    137            Visitor,
    138        )
    139    }
    140}
    141
    142impl crate::serde::Serialize for PodCondition {
    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            "PodCondition",
    146            2 +
    147            self.last_probe_time.as_ref().map_or(0, |_| 1) +
    148            self.last_transition_time.as_ref().map_or(0, |_| 1) +
    149            self.message.as_ref().map_or(0, |_| 1) +
    150            self.observed_generation.as_ref().map_or(0, |_| 1) +
    151            self.reason.as_ref().map_or(0, |_| 1),
    152        )?;
    153        if let Some(value) = &self.last_probe_time {
    154            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "lastProbeTime", value)?;
    155        }
    156        if let Some(value) = &self.last_transition_time {
    157            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "lastTransitionTime", value)?;
    158        }
    159        if let Some(value) = &self.message {
    160            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "message", value)?;
    161        }
    162        if let Some(value) = &self.observed_generation {
    163            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "observedGeneration", value)?;
    164        }
    165        if let Some(value) = &self.reason {
    166            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "reason", value)?;
    167        }
    168        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "status", &self.status)?;
    169        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "type", &self.type_)?;
    170        crate::serde::ser::SerializeStruct::end(state)
    171    }
    172}
    173
    174#[cfg(feature = "schemars")]
    175impl crate::schemars::JsonSchema for PodCondition {
    176    fn schema_name() -> std::borrow::Cow<'static, str> {
    177        "io.k8s.api.core.v1.PodCondition".into()
    178    }
    179
    180    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    181        crate::schemars::json_schema!({
    182            "description": "PodCondition contains details for the current condition of this pod.",
    183            "type": "object",
    184            "properties": {
    185                "lastProbeTime": ({
    186                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>();
    187                    schema_obj.ensure_object().insert("description".into(), "Last time we probed the condition.".into());
    188                    schema_obj
    189                }),
    190                "lastTransitionTime": ({
    191                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>();
    192                    schema_obj.ensure_object().insert("description".into(), "Last time the condition transitioned from one status to another.".into());
    193                    schema_obj
    194                }),
    195                "message": {
    196                    "description": "Human-readable message indicating details about last transition.",
    197                    "type": "string",
    198                },
    199                "observedGeneration": {
    200                    "description": "If set, this represents the .metadata.generation that the pod condition was set based upon. The PodObservedGenerationTracking feature gate must be enabled to use this field.",
    201                    "type": "integer",
    202                    "format": "int64",
    203                },
    204                "reason": {
    205                    "description": "Unique, one-word, CamelCase reason for the condition's last transition.",
    206                    "type": "string",
    207                },
    208                "status": {
    209                    "description": "Status is the status of the condition. Can be True, False, Unknown. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-conditions",
    210                    "type": "string",
    211                },
    212                "type": {
    213                    "description": "Type is the type of the condition. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-conditions",
    214                    "type": "string",
    215                },
    216            },
    217            "required": [
    218                "status",
    219                "type",
    220            ],
    221        })
    222    }
    223}