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