k8s_openapi/v1_35/api/core/v1/
container_restart_rule_on_exit_codes.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct ContainerRestartRuleOnExitCodes {
6 pub operator: std::string::String,
11
12 pub values: Option<std::vec::Vec<i32>>,
14}
15
16impl crate::DeepMerge for ContainerRestartRuleOnExitCodes {
17 fn merge_from(&mut self, other: Self) {
18 crate::DeepMerge::merge_from(&mut self.operator, other.operator);
19 crate::merge_strategies::list::set(&mut self.values, other.values);
20 }
21}
22
23impl<'de> crate::serde::Deserialize<'de> for ContainerRestartRuleOnExitCodes {
24 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
25 #[allow(non_camel_case_types)]
26 enum Field {
27 Key_operator,
28 Key_values,
29 Other,
30 }
31
32 impl<'de> crate::serde::Deserialize<'de> for Field {
33 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
34 struct Visitor;
35
36 impl crate::serde::de::Visitor<'_> for Visitor {
37 type Value = Field;
38
39 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
40 f.write_str("field identifier")
41 }
42
43 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
44 Ok(match v {
45 "operator" => Field::Key_operator,
46 "values" => Field::Key_values,
47 _ => Field::Other,
48 })
49 }
50 }
51
52 deserializer.deserialize_identifier(Visitor)
53 }
54 }
55
56 struct Visitor;
57
58 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
59 type Value = ContainerRestartRuleOnExitCodes;
60
61 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
62 f.write_str("ContainerRestartRuleOnExitCodes")
63 }
64
65 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
66 let mut value_operator: Option<std::string::String> = None;
67 let mut value_values: Option<std::vec::Vec<i32>> = None;
68
69 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
70 match key {
71 Field::Key_operator => value_operator = crate::serde::de::MapAccess::next_value(&mut map)?,
72 Field::Key_values => value_values = crate::serde::de::MapAccess::next_value(&mut map)?,
73 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
74 }
75 }
76
77 Ok(ContainerRestartRuleOnExitCodes {
78 operator: value_operator.unwrap_or_default(),
79 values: value_values,
80 })
81 }
82 }
83
84 deserializer.deserialize_struct(
85 "ContainerRestartRuleOnExitCodes",
86 &[
87 "operator",
88 "values",
89 ],
90 Visitor,
91 )
92 }
93}
94
95impl crate::serde::Serialize for ContainerRestartRuleOnExitCodes {
96 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
97 let mut state = serializer.serialize_struct(
98 "ContainerRestartRuleOnExitCodes",
99 1 +
100 self.values.as_ref().map_or(0, |_| 1),
101 )?;
102 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "operator", &self.operator)?;
103 if let Some(value) = &self.values {
104 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "values", value)?;
105 }
106 crate::serde::ser::SerializeStruct::end(state)
107 }
108}
109
110#[cfg(feature = "schemars")]
111impl crate::schemars::JsonSchema for ContainerRestartRuleOnExitCodes {
112 fn schema_name() -> std::borrow::Cow<'static, str> {
113 "io.k8s.api.core.v1.ContainerRestartRuleOnExitCodes".into()
114 }
115
116 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
117 crate::schemars::json_schema!({
118 "description": "ContainerRestartRuleOnExitCodes describes the condition for handling an exited container based on its exit codes.",
119 "type": "object",
120 "properties": {
121 "operator": {
122 "description": "Represents the relationship between the container exit code(s) and the specified values. Possible values are: - In: the requirement is satisfied if the container exit code is in the\n set of specified values.\n- NotIn: the requirement is satisfied if the container exit code is\n not in the set of specified values.",
123 "type": "string",
124 },
125 "values": {
126 "description": "Specifies the set of values to check for container exit codes. At most 255 elements are allowed.",
127 "type": "array",
128 "items": {
129 "type": "integer",
130 "format": "int32",
131 },
132 },
133 },
134 "required": [
135 "operator",
136 ],
137 })
138 }
139}