1// Generated from definition io.k8s.api.core.v1.Toleration
23/// The pod this Toleration is attached to tolerates any taint that matches the triple \<key,value,effect\> using the matching operator \<operator\>.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct Toleration {
6/// Effect indicates the taint effect to match. Empty means match all taint effects. When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute.
7pub effect: Option<std::string::String>,
89/// Key is the taint key that the toleration applies to. Empty means match all taint keys. If the key is empty, operator must be Exists; this combination means to match all values and all keys.
10pub key: Option<std::string::String>,
1112/// Operator represents a key's relationship to the value. Valid operators are Exists and Equal. Defaults to Equal. Exists is equivalent to wildcard for value, so that a pod can tolerate all taints of a particular category.
13pub operator: Option<std::string::String>,
1415/// TolerationSeconds represents the period of time the toleration (which must be of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default, it is not set, which means tolerate the taint forever (do not evict). Zero and negative values will be treated as 0 (evict immediately) by the system.
16pub toleration_seconds: Option<i64>,
1718/// Value is the taint value the toleration matches to. If the operator is Exists, the value should be empty, otherwise just a regular string.
19pub value: Option<std::string::String>,
20}
2122impl crate::DeepMerge for Toleration {
23fn merge_from(&mut self, other: Self) {
24crate::DeepMerge::merge_from(&mut self.effect, other.effect);
25crate::DeepMerge::merge_from(&mut self.key, other.key);
26crate::DeepMerge::merge_from(&mut self.operator, other.operator);
27crate::DeepMerge::merge_from(&mut self.toleration_seconds, other.toleration_seconds);
28crate::DeepMerge::merge_from(&mut self.value, other.value);
29 }
30}
3132impl<'de> crate::serde::Deserialize<'de> for Toleration {
33fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
34#[allow(non_camel_case_types)]
35enum Field {
36 Key_effect,
37 Key_key,
38 Key_operator,
39 Key_toleration_seconds,
40 Key_value,
41 Other,
42 }
4344impl<'de> crate::serde::Deserialize<'de> for Field {
45fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
46struct Visitor;
4748impl crate::serde::de::Visitor<'_> for Visitor {
49type Value = Field;
5051fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
52 f.write_str("field identifier")
53 }
5455fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
56Ok(match v {
57"effect" => Field::Key_effect,
58"key" => Field::Key_key,
59"operator" => Field::Key_operator,
60"tolerationSeconds" => Field::Key_toleration_seconds,
61"value" => Field::Key_value,
62_ => Field::Other,
63 })
64 }
65 }
6667 deserializer.deserialize_identifier(Visitor)
68 }
69 }
7071struct Visitor;
7273impl<'de> crate::serde::de::Visitor<'de> for Visitor {
74type Value = Toleration;
7576fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
77 f.write_str("Toleration")
78 }
7980fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
81let mut value_effect: Option<std::string::String> = None;
82let mut value_key: Option<std::string::String> = None;
83let mut value_operator: Option<std::string::String> = None;
84let mut value_toleration_seconds: Option<i64> = None;
85let mut value_value: Option<std::string::String> = None;
8687while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
88match key {
89 Field::Key_effect => value_effect = crate::serde::de::MapAccess::next_value(&mut map)?,
90 Field::Key_key => value_key = crate::serde::de::MapAccess::next_value(&mut map)?,
91 Field::Key_operator => value_operator = crate::serde::de::MapAccess::next_value(&mut map)?,
92 Field::Key_toleration_seconds => value_toleration_seconds = crate::serde::de::MapAccess::next_value(&mut map)?,
93 Field::Key_value => value_value = crate::serde::de::MapAccess::next_value(&mut map)?,
94 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
95 }
96 }
9798Ok(Toleration {
99 effect: value_effect,
100 key: value_key,
101 operator: value_operator,
102 toleration_seconds: value_toleration_seconds,
103 value: value_value,
104 })
105 }
106 }
107108 deserializer.deserialize_struct(
109"Toleration",
110&[
111"effect",
112"key",
113"operator",
114"tolerationSeconds",
115"value",
116 ],
117 Visitor,
118 )
119 }
120}
121122impl crate::serde::Serialize for Toleration {
123fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
124let mut state = serializer.serialize_struct(
125"Toleration",
126self.effect.as_ref().map_or(0, |_| 1) +
127self.key.as_ref().map_or(0, |_| 1) +
128self.operator.as_ref().map_or(0, |_| 1) +
129self.toleration_seconds.as_ref().map_or(0, |_| 1) +
130self.value.as_ref().map_or(0, |_| 1),
131 )?;
132if let Some(value) = &self.effect {
133crate::serde::ser::SerializeStruct::serialize_field(&mut state, "effect", value)?;
134 }
135if let Some(value) = &self.key {
136crate::serde::ser::SerializeStruct::serialize_field(&mut state, "key", value)?;
137 }
138if let Some(value) = &self.operator {
139crate::serde::ser::SerializeStruct::serialize_field(&mut state, "operator", value)?;
140 }
141if let Some(value) = &self.toleration_seconds {
142crate::serde::ser::SerializeStruct::serialize_field(&mut state, "tolerationSeconds", value)?;
143 }
144if let Some(value) = &self.value {
145crate::serde::ser::SerializeStruct::serialize_field(&mut state, "value", value)?;
146 }
147crate::serde::ser::SerializeStruct::end(state)
148 }
149}
150151#[cfg(feature = "schemars")]
152impl crate::schemars::JsonSchema for Toleration {
153fn schema_name() -> std::string::String {
154"io.k8s.api.core.v1.Toleration".into()
155 }
156157fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
158crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
159 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
160 description: Some("The pod this Toleration is attached to tolerates any taint that matches the triple <key,value,effect> using the matching operator <operator>.".into()),
161 ..Default::default()
162 })),
163 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
164 object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
165 properties: [
166 (
167"effect".into(),
168crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
169 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
170 description: Some("Effect indicates the taint effect to match. Empty means match all taint effects. When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute.".into()),
171 ..Default::default()
172 })),
173 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
174 ..Default::default()
175 }),
176 ),
177 (
178"key".into(),
179crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
180 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
181 description: Some("Key is the taint key that the toleration applies to. Empty means match all taint keys. If the key is empty, operator must be Exists; this combination means to match all values and all keys.".into()),
182 ..Default::default()
183 })),
184 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
185 ..Default::default()
186 }),
187 ),
188 (
189"operator".into(),
190crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
191 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
192 description: Some("Operator represents a key's relationship to the value. Valid operators are Exists and Equal. Defaults to Equal. Exists is equivalent to wildcard for value, so that a pod can tolerate all taints of a particular category.".into()),
193 ..Default::default()
194 })),
195 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
196 ..Default::default()
197 }),
198 ),
199 (
200"tolerationSeconds".into(),
201crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
202 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
203 description: Some("TolerationSeconds represents the period of time the toleration (which must be of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default, it is not set, which means tolerate the taint forever (do not evict). Zero and negative values will be treated as 0 (evict immediately) by the system.".into()),
204 ..Default::default()
205 })),
206 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
207 format: Some("int64".into()),
208 ..Default::default()
209 }),
210 ),
211 (
212"value".into(),
213crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
214 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
215 description: Some("Value is the taint value the toleration matches to. If the operator is Exists, the value should be empty, otherwise just a regular string.".into()),
216 ..Default::default()
217 })),
218 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::String))),
219 ..Default::default()
220 }),
221 ),
222 ].into(),
223 ..Default::default()
224 })),
225 ..Default::default()
226 })
227 }
228}