k8s_openapi/v1_36/api/resource/v1beta1/
device_taint.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct DeviceTaint {
6 pub effect: std::string::String,
10
11 pub key: std::string::String,
13
14 pub time_added: Option<crate::apimachinery::pkg::apis::meta::v1::Time>,
18
19 pub value: Option<std::string::String>,
21}
22
23impl crate::DeepMerge for DeviceTaint {
24 fn merge_from(&mut self, other: Self) {
25 crate::DeepMerge::merge_from(&mut self.effect, other.effect);
26 crate::DeepMerge::merge_from(&mut self.key, other.key);
27 crate::DeepMerge::merge_from(&mut self.time_added, other.time_added);
28 crate::DeepMerge::merge_from(&mut self.value, other.value);
29 }
30}
31
32impl<'de> crate::serde::Deserialize<'de> for DeviceTaint {
33 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
34 #[allow(non_camel_case_types)]
35 enum Field {
36 Key_effect,
37 Key_key,
38 Key_time_added,
39 Key_value,
40 Other,
41 }
42
43 impl<'de> crate::serde::Deserialize<'de> for Field {
44 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
45 struct Visitor;
46
47 impl crate::serde::de::Visitor<'_> for Visitor {
48 type Value = Field;
49
50 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
51 f.write_str("field identifier")
52 }
53
54 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
55 Ok(match v {
56 "effect" => Field::Key_effect,
57 "key" => Field::Key_key,
58 "timeAdded" => Field::Key_time_added,
59 "value" => Field::Key_value,
60 _ => Field::Other,
61 })
62 }
63 }
64
65 deserializer.deserialize_identifier(Visitor)
66 }
67 }
68
69 struct Visitor;
70
71 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
72 type Value = DeviceTaint;
73
74 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
75 f.write_str("DeviceTaint")
76 }
77
78 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
79 let mut value_effect: Option<std::string::String> = None;
80 let mut value_key: Option<std::string::String> = None;
81 let mut value_time_added: Option<crate::apimachinery::pkg::apis::meta::v1::Time> = None;
82 let mut value_value: Option<std::string::String> = None;
83
84 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
85 match key {
86 Field::Key_effect => value_effect = crate::serde::de::MapAccess::next_value(&mut map)?,
87 Field::Key_key => value_key = crate::serde::de::MapAccess::next_value(&mut map)?,
88 Field::Key_time_added => value_time_added = crate::serde::de::MapAccess::next_value(&mut map)?,
89 Field::Key_value => value_value = crate::serde::de::MapAccess::next_value(&mut map)?,
90 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
91 }
92 }
93
94 Ok(DeviceTaint {
95 effect: value_effect.unwrap_or_default(),
96 key: value_key.unwrap_or_default(),
97 time_added: value_time_added,
98 value: value_value,
99 })
100 }
101 }
102
103 deserializer.deserialize_struct(
104 "DeviceTaint",
105 &[
106 "effect",
107 "key",
108 "timeAdded",
109 "value",
110 ],
111 Visitor,
112 )
113 }
114}
115
116impl crate::serde::Serialize for DeviceTaint {
117 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
118 let mut state = serializer.serialize_struct(
119 "DeviceTaint",
120 2 +
121 self.time_added.as_ref().map_or(0, |_| 1) +
122 self.value.as_ref().map_or(0, |_| 1),
123 )?;
124 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "effect", &self.effect)?;
125 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "key", &self.key)?;
126 if let Some(value) = &self.time_added {
127 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "timeAdded", value)?;
128 }
129 if let Some(value) = &self.value {
130 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "value", value)?;
131 }
132 crate::serde::ser::SerializeStruct::end(state)
133 }
134}
135
136#[cfg(feature = "schemars")]
137impl crate::schemars::JsonSchema for DeviceTaint {
138 fn schema_name() -> std::borrow::Cow<'static, str> {
139 "io.k8s.api.resource.v1beta1.DeviceTaint".into()
140 }
141
142 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
143 crate::schemars::json_schema!({
144 "description": "The device this taint is attached to has the \"effect\" on any claim which does not tolerate the taint and, through the claim, to pods using the claim.",
145 "type": "object",
146 "properties": {
147 "effect": {
148 "description": "The effect of the taint on claims that do not tolerate the taint and through such claims on the pods using them.\n\nValid effects are None, NoSchedule and NoExecute. PreferNoSchedule as used for nodes is not valid here. More effects may get added in the future. Consumers must treat unknown effects like None.",
149 "type": "string",
150 },
151 "key": {
152 "description": "The taint key to be applied to a device. Must be a label name.",
153 "type": "string",
154 },
155 "timeAdded": ({
156 let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>();
157 schema_obj.ensure_object().insert("description".into(), "TimeAdded represents the time at which the taint was added or (only in a DeviceTaintRule) the effect was modified. Added automatically during create or update if not set.\n\nIn addition, in a DeviceTaintRule a value provided during an update gets replaced with the current time if the provided value is the same as the old one and the new effect is different. Changing the key and/or value while keeping the effect unchanged is possible and does not update the time stamp because the eviction which uses it is either already started (NoExecute) or not started yet (NoEffect, NoSchedule).".into());
158 schema_obj
159 }),
160 "value": {
161 "description": "The taint value corresponding to the taint key. Must be a label value.",
162 "type": "string",
163 },
164 },
165 "required": [
166 "effect",
167 "key",
168 ],
169 })
170 }
171}
172
173#[cfg(feature = "schemars08")]
174impl crate::schemars08::JsonSchema for DeviceTaint {
175 fn schema_name() -> std::string::String {
176 "io.k8s.api.resource.v1beta1.DeviceTaint".into()
177 }
178
179 fn json_schema(__gen: &mut crate::schemars08::gen::SchemaGenerator) -> crate::schemars08::schema::Schema {
180 crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
181 metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
182 description: Some("The device this taint is attached to has the \"effect\" on any claim which does not tolerate the taint and, through the claim, to pods using the claim.".into()),
183 ..Default::default()
184 })),
185 instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::Object))),
186 object: Some(std::boxed::Box::new(crate::schemars08::schema::ObjectValidation {
187 properties: [
188 (
189 "effect".into(),
190 crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
191 metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
192 description: Some("The effect of the taint on claims that do not tolerate the taint and through such claims on the pods using them.\n\nValid effects are None, NoSchedule and NoExecute. PreferNoSchedule as used for nodes is not valid here. More effects may get added in the future. Consumers must treat unknown effects like None.".into()),
193 ..Default::default()
194 })),
195 instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
196 ..Default::default()
197 }),
198 ),
199 (
200 "key".into(),
201 crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
202 metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
203 description: Some("The taint key to be applied to a device. Must be a label name.".into()),
204 ..Default::default()
205 })),
206 instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
207 ..Default::default()
208 }),
209 ),
210 (
211 "timeAdded".into(),
212 {
213 let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>().into_object();
214 schema_obj.metadata = Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
215 description: Some("TimeAdded represents the time at which the taint was added or (only in a DeviceTaintRule) the effect was modified. Added automatically during create or update if not set.\n\nIn addition, in a DeviceTaintRule a value provided during an update gets replaced with the current time if the provided value is the same as the old one and the new effect is different. Changing the key and/or value while keeping the effect unchanged is possible and does not update the time stamp because the eviction which uses it is either already started (NoExecute) or not started yet (NoEffect, NoSchedule).".into()),
216 ..Default::default()
217 }));
218 crate::schemars08::schema::Schema::Object(schema_obj)
219 },
220 ),
221 (
222 "value".into(),
223 crate::schemars08::schema::Schema::Object(crate::schemars08::schema::SchemaObject {
224 metadata: Some(std::boxed::Box::new(crate::schemars08::schema::Metadata {
225 description: Some("The taint value corresponding to the taint key. Must be a label value.".into()),
226 ..Default::default()
227 })),
228 instance_type: Some(crate::schemars08::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars08::schema::InstanceType::String))),
229 ..Default::default()
230 }),
231 ),
232 ].into(),
233 required: [
234 "effect".into(),
235 "key".into(),
236 ].into(),
237 ..Default::default()
238 })),
239 ..Default::default()
240 })
241 }
242}