1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct PodSpec {
6 pub active_deadline_seconds: Option<i64>,
8
9 pub affinity: Option<crate::api::core::v1::Affinity>,
11
12 pub automount_service_account_token: Option<bool>,
14
15 pub containers: std::vec::Vec<crate::api::core::v1::Container>,
17
18 pub dns_config: Option<crate::api::core::v1::PodDNSConfig>,
20
21 pub dns_policy: Option<std::string::String>,
23
24 pub enable_service_links: Option<bool>,
26
27 pub ephemeral_containers: Option<std::vec::Vec<crate::api::core::v1::EphemeralContainer>>,
29
30 pub host_aliases: Option<std::vec::Vec<crate::api::core::v1::HostAlias>>,
32
33 pub host_ipc: Option<bool>,
35
36 pub host_network: Option<bool>,
38
39 pub host_pid: Option<bool>,
41
42 pub host_users: Option<bool>,
44
45 pub hostname: Option<std::string::String>,
47
48 pub image_pull_secrets: Option<std::vec::Vec<crate::api::core::v1::LocalObjectReference>>,
50
51 pub init_containers: Option<std::vec::Vec<crate::api::core::v1::Container>>,
53
54 pub node_name: Option<std::string::String>,
56
57 pub node_selector: Option<std::collections::BTreeMap<std::string::String, std::string::String>>,
59
60 pub os: Option<crate::api::core::v1::PodOS>,
66
67 pub overhead: Option<std::collections::BTreeMap<std::string::String, crate::apimachinery::pkg::api::resource::Quantity>>,
69
70 pub preemption_policy: Option<std::string::String>,
72
73 pub priority: Option<i32>,
75
76 pub priority_class_name: Option<std::string::String>,
78
79 pub readiness_gates: Option<std::vec::Vec<crate::api::core::v1::PodReadinessGate>>,
81
82 pub resource_claims: Option<std::vec::Vec<crate::api::core::v1::PodResourceClaim>>,
88
89 pub restart_policy: Option<std::string::String>,
91
92 pub runtime_class_name: Option<std::string::String>,
94
95 pub scheduler_name: Option<std::string::String>,
97
98 pub scheduling_gates: Option<std::vec::Vec<crate::api::core::v1::PodSchedulingGate>>,
102
103 pub security_context: Option<crate::api::core::v1::PodSecurityContext>,
105
106 pub service_account: Option<std::string::String>,
108
109 pub service_account_name: Option<std::string::String>,
111
112 pub set_hostname_as_fqdn: Option<bool>,
114
115 pub share_process_namespace: Option<bool>,
117
118 pub subdomain: Option<std::string::String>,
120
121 pub termination_grace_period_seconds: Option<i64>,
123
124 pub tolerations: Option<std::vec::Vec<crate::api::core::v1::Toleration>>,
126
127 pub topology_spread_constraints: Option<std::vec::Vec<crate::api::core::v1::TopologySpreadConstraint>>,
129
130 pub volumes: Option<std::vec::Vec<crate::api::core::v1::Volume>>,
132}
133
134impl crate::DeepMerge for PodSpec {
135 fn merge_from(&mut self, other: Self) {
136 crate::DeepMerge::merge_from(&mut self.active_deadline_seconds, other.active_deadline_seconds);
137 crate::DeepMerge::merge_from(&mut self.affinity, other.affinity);
138 crate::DeepMerge::merge_from(&mut self.automount_service_account_token, other.automount_service_account_token);
139 crate::merge_strategies::list::map(
140 &mut self.containers,
141 other.containers,
142 &[|lhs, rhs| lhs.name == rhs.name],
143 |current_item, other_item| {
144 crate::DeepMerge::merge_from(current_item, other_item);
145 },
146 );
147 crate::DeepMerge::merge_from(&mut self.dns_config, other.dns_config);
148 crate::DeepMerge::merge_from(&mut self.dns_policy, other.dns_policy);
149 crate::DeepMerge::merge_from(&mut self.enable_service_links, other.enable_service_links);
150 crate::merge_strategies::list::map(
151 &mut self.ephemeral_containers,
152 other.ephemeral_containers,
153 &[|lhs, rhs| lhs.name == rhs.name],
154 |current_item, other_item| {
155 crate::DeepMerge::merge_from(current_item, other_item);
156 },
157 );
158 crate::merge_strategies::list::map(
159 &mut self.host_aliases,
160 other.host_aliases,
161 &[|lhs, rhs| lhs.ip == rhs.ip],
162 |current_item, other_item| {
163 crate::DeepMerge::merge_from(current_item, other_item);
164 },
165 );
166 crate::DeepMerge::merge_from(&mut self.host_ipc, other.host_ipc);
167 crate::DeepMerge::merge_from(&mut self.host_network, other.host_network);
168 crate::DeepMerge::merge_from(&mut self.host_pid, other.host_pid);
169 crate::DeepMerge::merge_from(&mut self.host_users, other.host_users);
170 crate::DeepMerge::merge_from(&mut self.hostname, other.hostname);
171 crate::merge_strategies::list::map(
172 &mut self.image_pull_secrets,
173 other.image_pull_secrets,
174 &[|lhs, rhs| lhs.name == rhs.name],
175 |current_item, other_item| {
176 crate::DeepMerge::merge_from(current_item, other_item);
177 },
178 );
179 crate::merge_strategies::list::map(
180 &mut self.init_containers,
181 other.init_containers,
182 &[|lhs, rhs| lhs.name == rhs.name],
183 |current_item, other_item| {
184 crate::DeepMerge::merge_from(current_item, other_item);
185 },
186 );
187 crate::DeepMerge::merge_from(&mut self.node_name, other.node_name);
188 crate::merge_strategies::map::atomic(&mut self.node_selector, other.node_selector);
189 crate::DeepMerge::merge_from(&mut self.os, other.os);
190 crate::merge_strategies::map::granular(&mut self.overhead, other.overhead, |current_item, other_item| {
191 crate::DeepMerge::merge_from(current_item, other_item);
192 });
193 crate::DeepMerge::merge_from(&mut self.preemption_policy, other.preemption_policy);
194 crate::DeepMerge::merge_from(&mut self.priority, other.priority);
195 crate::DeepMerge::merge_from(&mut self.priority_class_name, other.priority_class_name);
196 crate::merge_strategies::list::atomic(&mut self.readiness_gates, other.readiness_gates);
197 crate::merge_strategies::list::map(
198 &mut self.resource_claims,
199 other.resource_claims,
200 &[|lhs, rhs| lhs.name == rhs.name],
201 |current_item, other_item| {
202 crate::DeepMerge::merge_from(current_item, other_item);
203 },
204 );
205 crate::DeepMerge::merge_from(&mut self.restart_policy, other.restart_policy);
206 crate::DeepMerge::merge_from(&mut self.runtime_class_name, other.runtime_class_name);
207 crate::DeepMerge::merge_from(&mut self.scheduler_name, other.scheduler_name);
208 crate::merge_strategies::list::map(
209 &mut self.scheduling_gates,
210 other.scheduling_gates,
211 &[|lhs, rhs| lhs.name == rhs.name],
212 |current_item, other_item| {
213 crate::DeepMerge::merge_from(current_item, other_item);
214 },
215 );
216 crate::DeepMerge::merge_from(&mut self.security_context, other.security_context);
217 crate::DeepMerge::merge_from(&mut self.service_account, other.service_account);
218 crate::DeepMerge::merge_from(&mut self.service_account_name, other.service_account_name);
219 crate::DeepMerge::merge_from(&mut self.set_hostname_as_fqdn, other.set_hostname_as_fqdn);
220 crate::DeepMerge::merge_from(&mut self.share_process_namespace, other.share_process_namespace);
221 crate::DeepMerge::merge_from(&mut self.subdomain, other.subdomain);
222 crate::DeepMerge::merge_from(&mut self.termination_grace_period_seconds, other.termination_grace_period_seconds);
223 crate::merge_strategies::list::atomic(&mut self.tolerations, other.tolerations);
224 crate::merge_strategies::list::map(
225 &mut self.topology_spread_constraints,
226 other.topology_spread_constraints,
227 &[|lhs, rhs| lhs.topology_key == rhs.topology_key],
228 |current_item, other_item| {
229 crate::DeepMerge::merge_from(current_item, other_item);
230 },
231 );
232 crate::merge_strategies::list::map(
233 &mut self.volumes,
234 other.volumes,
235 &[|lhs, rhs| lhs.name == rhs.name],
236 |current_item, other_item| {
237 crate::DeepMerge::merge_from(current_item, other_item);
238 },
239 );
240 }
241}
242
243impl<'de> crate::serde::Deserialize<'de> for PodSpec {
244 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
245 #[allow(non_camel_case_types)]
246 enum Field {
247 Key_active_deadline_seconds,
248 Key_affinity,
249 Key_automount_service_account_token,
250 Key_containers,
251 Key_dns_config,
252 Key_dns_policy,
253 Key_enable_service_links,
254 Key_ephemeral_containers,
255 Key_host_aliases,
256 Key_host_ipc,
257 Key_host_network,
258 Key_host_pid,
259 Key_host_users,
260 Key_hostname,
261 Key_image_pull_secrets,
262 Key_init_containers,
263 Key_node_name,
264 Key_node_selector,
265 Key_os,
266 Key_overhead,
267 Key_preemption_policy,
268 Key_priority,
269 Key_priority_class_name,
270 Key_readiness_gates,
271 Key_resource_claims,
272 Key_restart_policy,
273 Key_runtime_class_name,
274 Key_scheduler_name,
275 Key_scheduling_gates,
276 Key_security_context,
277 Key_service_account,
278 Key_service_account_name,
279 Key_set_hostname_as_fqdn,
280 Key_share_process_namespace,
281 Key_subdomain,
282 Key_termination_grace_period_seconds,
283 Key_tolerations,
284 Key_topology_spread_constraints,
285 Key_volumes,
286 Other,
287 }
288
289 impl<'de> crate::serde::Deserialize<'de> for Field {
290 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
291 struct Visitor;
292
293 impl crate::serde::de::Visitor<'_> for Visitor {
294 type Value = Field;
295
296 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
297 f.write_str("field identifier")
298 }
299
300 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
301 Ok(match v {
302 "activeDeadlineSeconds" => Field::Key_active_deadline_seconds,
303 "affinity" => Field::Key_affinity,
304 "automountServiceAccountToken" => Field::Key_automount_service_account_token,
305 "containers" => Field::Key_containers,
306 "dnsConfig" => Field::Key_dns_config,
307 "dnsPolicy" => Field::Key_dns_policy,
308 "enableServiceLinks" => Field::Key_enable_service_links,
309 "ephemeralContainers" => Field::Key_ephemeral_containers,
310 "hostAliases" => Field::Key_host_aliases,
311 "hostIPC" => Field::Key_host_ipc,
312 "hostNetwork" => Field::Key_host_network,
313 "hostPID" => Field::Key_host_pid,
314 "hostUsers" => Field::Key_host_users,
315 "hostname" => Field::Key_hostname,
316 "imagePullSecrets" => Field::Key_image_pull_secrets,
317 "initContainers" => Field::Key_init_containers,
318 "nodeName" => Field::Key_node_name,
319 "nodeSelector" => Field::Key_node_selector,
320 "os" => Field::Key_os,
321 "overhead" => Field::Key_overhead,
322 "preemptionPolicy" => Field::Key_preemption_policy,
323 "priority" => Field::Key_priority,
324 "priorityClassName" => Field::Key_priority_class_name,
325 "readinessGates" => Field::Key_readiness_gates,
326 "resourceClaims" => Field::Key_resource_claims,
327 "restartPolicy" => Field::Key_restart_policy,
328 "runtimeClassName" => Field::Key_runtime_class_name,
329 "schedulerName" => Field::Key_scheduler_name,
330 "schedulingGates" => Field::Key_scheduling_gates,
331 "securityContext" => Field::Key_security_context,
332 "serviceAccount" => Field::Key_service_account,
333 "serviceAccountName" => Field::Key_service_account_name,
334 "setHostnameAsFQDN" => Field::Key_set_hostname_as_fqdn,
335 "shareProcessNamespace" => Field::Key_share_process_namespace,
336 "subdomain" => Field::Key_subdomain,
337 "terminationGracePeriodSeconds" => Field::Key_termination_grace_period_seconds,
338 "tolerations" => Field::Key_tolerations,
339 "topologySpreadConstraints" => Field::Key_topology_spread_constraints,
340 "volumes" => Field::Key_volumes,
341 _ => Field::Other,
342 })
343 }
344 }
345
346 deserializer.deserialize_identifier(Visitor)
347 }
348 }
349
350 struct Visitor;
351
352 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
353 type Value = PodSpec;
354
355 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
356 f.write_str("PodSpec")
357 }
358
359 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
360 let mut value_active_deadline_seconds: Option<i64> = None;
361 let mut value_affinity: Option<crate::api::core::v1::Affinity> = None;
362 let mut value_automount_service_account_token: Option<bool> = None;
363 let mut value_containers: Option<std::vec::Vec<crate::api::core::v1::Container>> = None;
364 let mut value_dns_config: Option<crate::api::core::v1::PodDNSConfig> = None;
365 let mut value_dns_policy: Option<std::string::String> = None;
366 let mut value_enable_service_links: Option<bool> = None;
367 let mut value_ephemeral_containers: Option<std::vec::Vec<crate::api::core::v1::EphemeralContainer>> = None;
368 let mut value_host_aliases: Option<std::vec::Vec<crate::api::core::v1::HostAlias>> = None;
369 let mut value_host_ipc: Option<bool> = None;
370 let mut value_host_network: Option<bool> = None;
371 let mut value_host_pid: Option<bool> = None;
372 let mut value_host_users: Option<bool> = None;
373 let mut value_hostname: Option<std::string::String> = None;
374 let mut value_image_pull_secrets: Option<std::vec::Vec<crate::api::core::v1::LocalObjectReference>> = None;
375 let mut value_init_containers: Option<std::vec::Vec<crate::api::core::v1::Container>> = None;
376 let mut value_node_name: Option<std::string::String> = None;
377 let mut value_node_selector: Option<std::collections::BTreeMap<std::string::String, std::string::String>> = None;
378 let mut value_os: Option<crate::api::core::v1::PodOS> = None;
379 let mut value_overhead: Option<std::collections::BTreeMap<std::string::String, crate::apimachinery::pkg::api::resource::Quantity>> = None;
380 let mut value_preemption_policy: Option<std::string::String> = None;
381 let mut value_priority: Option<i32> = None;
382 let mut value_priority_class_name: Option<std::string::String> = None;
383 let mut value_readiness_gates: Option<std::vec::Vec<crate::api::core::v1::PodReadinessGate>> = None;
384 let mut value_resource_claims: Option<std::vec::Vec<crate::api::core::v1::PodResourceClaim>> = None;
385 let mut value_restart_policy: Option<std::string::String> = None;
386 let mut value_runtime_class_name: Option<std::string::String> = None;
387 let mut value_scheduler_name: Option<std::string::String> = None;
388 let mut value_scheduling_gates: Option<std::vec::Vec<crate::api::core::v1::PodSchedulingGate>> = None;
389 let mut value_security_context: Option<crate::api::core::v1::PodSecurityContext> = None;
390 let mut value_service_account: Option<std::string::String> = None;
391 let mut value_service_account_name: Option<std::string::String> = None;
392 let mut value_set_hostname_as_fqdn: Option<bool> = None;
393 let mut value_share_process_namespace: Option<bool> = None;
394 let mut value_subdomain: Option<std::string::String> = None;
395 let mut value_termination_grace_period_seconds: Option<i64> = None;
396 let mut value_tolerations: Option<std::vec::Vec<crate::api::core::v1::Toleration>> = None;
397 let mut value_topology_spread_constraints: Option<std::vec::Vec<crate::api::core::v1::TopologySpreadConstraint>> = None;
398 let mut value_volumes: Option<std::vec::Vec<crate::api::core::v1::Volume>> = None;
399
400 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
401 match key {
402 Field::Key_active_deadline_seconds => value_active_deadline_seconds = crate::serde::de::MapAccess::next_value(&mut map)?,
403 Field::Key_affinity => value_affinity = crate::serde::de::MapAccess::next_value(&mut map)?,
404 Field::Key_automount_service_account_token => value_automount_service_account_token = crate::serde::de::MapAccess::next_value(&mut map)?,
405 Field::Key_containers => value_containers = crate::serde::de::MapAccess::next_value(&mut map)?,
406 Field::Key_dns_config => value_dns_config = crate::serde::de::MapAccess::next_value(&mut map)?,
407 Field::Key_dns_policy => value_dns_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
408 Field::Key_enable_service_links => value_enable_service_links = crate::serde::de::MapAccess::next_value(&mut map)?,
409 Field::Key_ephemeral_containers => value_ephemeral_containers = crate::serde::de::MapAccess::next_value(&mut map)?,
410 Field::Key_host_aliases => value_host_aliases = crate::serde::de::MapAccess::next_value(&mut map)?,
411 Field::Key_host_ipc => value_host_ipc = crate::serde::de::MapAccess::next_value(&mut map)?,
412 Field::Key_host_network => value_host_network = crate::serde::de::MapAccess::next_value(&mut map)?,
413 Field::Key_host_pid => value_host_pid = crate::serde::de::MapAccess::next_value(&mut map)?,
414 Field::Key_host_users => value_host_users = crate::serde::de::MapAccess::next_value(&mut map)?,
415 Field::Key_hostname => value_hostname = crate::serde::de::MapAccess::next_value(&mut map)?,
416 Field::Key_image_pull_secrets => value_image_pull_secrets = crate::serde::de::MapAccess::next_value(&mut map)?,
417 Field::Key_init_containers => value_init_containers = crate::serde::de::MapAccess::next_value(&mut map)?,
418 Field::Key_node_name => value_node_name = crate::serde::de::MapAccess::next_value(&mut map)?,
419 Field::Key_node_selector => value_node_selector = crate::serde::de::MapAccess::next_value(&mut map)?,
420 Field::Key_os => value_os = crate::serde::de::MapAccess::next_value(&mut map)?,
421 Field::Key_overhead => value_overhead = crate::serde::de::MapAccess::next_value(&mut map)?,
422 Field::Key_preemption_policy => value_preemption_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
423 Field::Key_priority => value_priority = crate::serde::de::MapAccess::next_value(&mut map)?,
424 Field::Key_priority_class_name => value_priority_class_name = crate::serde::de::MapAccess::next_value(&mut map)?,
425 Field::Key_readiness_gates => value_readiness_gates = crate::serde::de::MapAccess::next_value(&mut map)?,
426 Field::Key_resource_claims => value_resource_claims = crate::serde::de::MapAccess::next_value(&mut map)?,
427 Field::Key_restart_policy => value_restart_policy = crate::serde::de::MapAccess::next_value(&mut map)?,
428 Field::Key_runtime_class_name => value_runtime_class_name = crate::serde::de::MapAccess::next_value(&mut map)?,
429 Field::Key_scheduler_name => value_scheduler_name = crate::serde::de::MapAccess::next_value(&mut map)?,
430 Field::Key_scheduling_gates => value_scheduling_gates = crate::serde::de::MapAccess::next_value(&mut map)?,
431 Field::Key_security_context => value_security_context = crate::serde::de::MapAccess::next_value(&mut map)?,
432 Field::Key_service_account => value_service_account = crate::serde::de::MapAccess::next_value(&mut map)?,
433 Field::Key_service_account_name => value_service_account_name = crate::serde::de::MapAccess::next_value(&mut map)?,
434 Field::Key_set_hostname_as_fqdn => value_set_hostname_as_fqdn = crate::serde::de::MapAccess::next_value(&mut map)?,
435 Field::Key_share_process_namespace => value_share_process_namespace = crate::serde::de::MapAccess::next_value(&mut map)?,
436 Field::Key_subdomain => value_subdomain = crate::serde::de::MapAccess::next_value(&mut map)?,
437 Field::Key_termination_grace_period_seconds => value_termination_grace_period_seconds = crate::serde::de::MapAccess::next_value(&mut map)?,
438 Field::Key_tolerations => value_tolerations = crate::serde::de::MapAccess::next_value(&mut map)?,
439 Field::Key_topology_spread_constraints => value_topology_spread_constraints = crate::serde::de::MapAccess::next_value(&mut map)?,
440 Field::Key_volumes => value_volumes = crate::serde::de::MapAccess::next_value(&mut map)?,
441 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
442 }
443 }
444
445 Ok(PodSpec {
446 active_deadline_seconds: value_active_deadline_seconds,
447 affinity: value_affinity,
448 automount_service_account_token: value_automount_service_account_token,
449 containers: value_containers.unwrap_or_default(),
450 dns_config: value_dns_config,
451 dns_policy: value_dns_policy,
452 enable_service_links: value_enable_service_links,
453 ephemeral_containers: value_ephemeral_containers,
454 host_aliases: value_host_aliases,
455 host_ipc: value_host_ipc,
456 host_network: value_host_network,
457 host_pid: value_host_pid,
458 host_users: value_host_users,
459 hostname: value_hostname,
460 image_pull_secrets: value_image_pull_secrets,
461 init_containers: value_init_containers,
462 node_name: value_node_name,
463 node_selector: value_node_selector,
464 os: value_os,
465 overhead: value_overhead,
466 preemption_policy: value_preemption_policy,
467 priority: value_priority,
468 priority_class_name: value_priority_class_name,
469 readiness_gates: value_readiness_gates,
470 resource_claims: value_resource_claims,
471 restart_policy: value_restart_policy,
472 runtime_class_name: value_runtime_class_name,
473 scheduler_name: value_scheduler_name,
474 scheduling_gates: value_scheduling_gates,
475 security_context: value_security_context,
476 service_account: value_service_account,
477 service_account_name: value_service_account_name,
478 set_hostname_as_fqdn: value_set_hostname_as_fqdn,
479 share_process_namespace: value_share_process_namespace,
480 subdomain: value_subdomain,
481 termination_grace_period_seconds: value_termination_grace_period_seconds,
482 tolerations: value_tolerations,
483 topology_spread_constraints: value_topology_spread_constraints,
484 volumes: value_volumes,
485 })
486 }
487 }
488
489 deserializer.deserialize_struct(
490 "PodSpec",
491 &[
492 "activeDeadlineSeconds",
493 "affinity",
494 "automountServiceAccountToken",
495 "containers",
496 "dnsConfig",
497 "dnsPolicy",
498 "enableServiceLinks",
499 "ephemeralContainers",
500 "hostAliases",
501 "hostIPC",
502 "hostNetwork",
503 "hostPID",
504 "hostUsers",
505 "hostname",
506 "imagePullSecrets",
507 "initContainers",
508 "nodeName",
509 "nodeSelector",
510 "os",
511 "overhead",
512 "preemptionPolicy",
513 "priority",
514 "priorityClassName",
515 "readinessGates",
516 "resourceClaims",
517 "restartPolicy",
518 "runtimeClassName",
519 "schedulerName",
520 "schedulingGates",
521 "securityContext",
522 "serviceAccount",
523 "serviceAccountName",
524 "setHostnameAsFQDN",
525 "shareProcessNamespace",
526 "subdomain",
527 "terminationGracePeriodSeconds",
528 "tolerations",
529 "topologySpreadConstraints",
530 "volumes",
531 ],
532 Visitor,
533 )
534 }
535}
536
537impl crate::serde::Serialize for PodSpec {
538 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
539 let mut state = serializer.serialize_struct(
540 "PodSpec",
541 1 +
542 self.active_deadline_seconds.as_ref().map_or(0, |_| 1) +
543 self.affinity.as_ref().map_or(0, |_| 1) +
544 self.automount_service_account_token.as_ref().map_or(0, |_| 1) +
545 self.dns_config.as_ref().map_or(0, |_| 1) +
546 self.dns_policy.as_ref().map_or(0, |_| 1) +
547 self.enable_service_links.as_ref().map_or(0, |_| 1) +
548 self.ephemeral_containers.as_ref().map_or(0, |_| 1) +
549 self.host_aliases.as_ref().map_or(0, |_| 1) +
550 self.host_ipc.as_ref().map_or(0, |_| 1) +
551 self.host_network.as_ref().map_or(0, |_| 1) +
552 self.host_pid.as_ref().map_or(0, |_| 1) +
553 self.host_users.as_ref().map_or(0, |_| 1) +
554 self.hostname.as_ref().map_or(0, |_| 1) +
555 self.image_pull_secrets.as_ref().map_or(0, |_| 1) +
556 self.init_containers.as_ref().map_or(0, |_| 1) +
557 self.node_name.as_ref().map_or(0, |_| 1) +
558 self.node_selector.as_ref().map_or(0, |_| 1) +
559 self.os.as_ref().map_or(0, |_| 1) +
560 self.overhead.as_ref().map_or(0, |_| 1) +
561 self.preemption_policy.as_ref().map_or(0, |_| 1) +
562 self.priority.as_ref().map_or(0, |_| 1) +
563 self.priority_class_name.as_ref().map_or(0, |_| 1) +
564 self.readiness_gates.as_ref().map_or(0, |_| 1) +
565 self.resource_claims.as_ref().map_or(0, |_| 1) +
566 self.restart_policy.as_ref().map_or(0, |_| 1) +
567 self.runtime_class_name.as_ref().map_or(0, |_| 1) +
568 self.scheduler_name.as_ref().map_or(0, |_| 1) +
569 self.scheduling_gates.as_ref().map_or(0, |_| 1) +
570 self.security_context.as_ref().map_or(0, |_| 1) +
571 self.service_account.as_ref().map_or(0, |_| 1) +
572 self.service_account_name.as_ref().map_or(0, |_| 1) +
573 self.set_hostname_as_fqdn.as_ref().map_or(0, |_| 1) +
574 self.share_process_namespace.as_ref().map_or(0, |_| 1) +
575 self.subdomain.as_ref().map_or(0, |_| 1) +
576 self.termination_grace_period_seconds.as_ref().map_or(0, |_| 1) +
577 self.tolerations.as_ref().map_or(0, |_| 1) +
578 self.topology_spread_constraints.as_ref().map_or(0, |_| 1) +
579 self.volumes.as_ref().map_or(0, |_| 1),
580 )?;
581 if let Some(value) = &self.active_deadline_seconds {
582 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "activeDeadlineSeconds", value)?;
583 }
584 if let Some(value) = &self.affinity {
585 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "affinity", value)?;
586 }
587 if let Some(value) = &self.automount_service_account_token {
588 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "automountServiceAccountToken", value)?;
589 }
590 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "containers", &self.containers)?;
591 if let Some(value) = &self.dns_config {
592 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "dnsConfig", value)?;
593 }
594 if let Some(value) = &self.dns_policy {
595 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "dnsPolicy", value)?;
596 }
597 if let Some(value) = &self.enable_service_links {
598 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "enableServiceLinks", value)?;
599 }
600 if let Some(value) = &self.ephemeral_containers {
601 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "ephemeralContainers", value)?;
602 }
603 if let Some(value) = &self.host_aliases {
604 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "hostAliases", value)?;
605 }
606 if let Some(value) = &self.host_ipc {
607 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "hostIPC", value)?;
608 }
609 if let Some(value) = &self.host_network {
610 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "hostNetwork", value)?;
611 }
612 if let Some(value) = &self.host_pid {
613 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "hostPID", value)?;
614 }
615 if let Some(value) = &self.host_users {
616 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "hostUsers", value)?;
617 }
618 if let Some(value) = &self.hostname {
619 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "hostname", value)?;
620 }
621 if let Some(value) = &self.image_pull_secrets {
622 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "imagePullSecrets", value)?;
623 }
624 if let Some(value) = &self.init_containers {
625 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "initContainers", value)?;
626 }
627 if let Some(value) = &self.node_name {
628 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "nodeName", value)?;
629 }
630 if let Some(value) = &self.node_selector {
631 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "nodeSelector", value)?;
632 }
633 if let Some(value) = &self.os {
634 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "os", value)?;
635 }
636 if let Some(value) = &self.overhead {
637 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "overhead", value)?;
638 }
639 if let Some(value) = &self.preemption_policy {
640 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "preemptionPolicy", value)?;
641 }
642 if let Some(value) = &self.priority {
643 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "priority", value)?;
644 }
645 if let Some(value) = &self.priority_class_name {
646 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "priorityClassName", value)?;
647 }
648 if let Some(value) = &self.readiness_gates {
649 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readinessGates", value)?;
650 }
651 if let Some(value) = &self.resource_claims {
652 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resourceClaims", value)?;
653 }
654 if let Some(value) = &self.restart_policy {
655 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "restartPolicy", value)?;
656 }
657 if let Some(value) = &self.runtime_class_name {
658 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "runtimeClassName", value)?;
659 }
660 if let Some(value) = &self.scheduler_name {
661 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "schedulerName", value)?;
662 }
663 if let Some(value) = &self.scheduling_gates {
664 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "schedulingGates", value)?;
665 }
666 if let Some(value) = &self.security_context {
667 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "securityContext", value)?;
668 }
669 if let Some(value) = &self.service_account {
670 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "serviceAccount", value)?;
671 }
672 if let Some(value) = &self.service_account_name {
673 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "serviceAccountName", value)?;
674 }
675 if let Some(value) = &self.set_hostname_as_fqdn {
676 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "setHostnameAsFQDN", value)?;
677 }
678 if let Some(value) = &self.share_process_namespace {
679 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "shareProcessNamespace", value)?;
680 }
681 if let Some(value) = &self.subdomain {
682 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "subdomain", value)?;
683 }
684 if let Some(value) = &self.termination_grace_period_seconds {
685 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "terminationGracePeriodSeconds", value)?;
686 }
687 if let Some(value) = &self.tolerations {
688 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "tolerations", value)?;
689 }
690 if let Some(value) = &self.topology_spread_constraints {
691 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "topologySpreadConstraints", value)?;
692 }
693 if let Some(value) = &self.volumes {
694 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "volumes", value)?;
695 }
696 crate::serde::ser::SerializeStruct::end(state)
697 }
698}
699
700#[cfg(feature = "schemars")]
701impl crate::schemars::JsonSchema for PodSpec {
702 fn schema_name() -> std::borrow::Cow<'static, str> {
703 "io.k8s.api.core.v1.PodSpec".into()
704 }
705
706 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
707 crate::schemars::json_schema!({
708 "description": "PodSpec is a description of a pod.",
709 "type": "object",
710 "properties": {
711 "activeDeadlineSeconds": {
712 "description": "Optional duration in seconds the pod may be active on the node relative to StartTime before the system will actively try to mark it failed and kill associated containers. Value must be a positive integer.",
713 "type": "integer",
714 "format": "int64",
715 },
716 "affinity": ({
717 let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::Affinity>();
718 schema_obj.ensure_object().insert("description".into(), "If specified, the pod's scheduling constraints".into());
719 schema_obj
720 }),
721 "automountServiceAccountToken": {
722 "description": "AutomountServiceAccountToken indicates whether a service account token should be automatically mounted.",
723 "type": "boolean",
724 },
725 "containers": {
726 "description": "List of containers belonging to the pod. Containers cannot currently be added or removed. There must be at least one container in a Pod. Cannot be updated.",
727 "type": "array",
728 "items": (__gen.subschema_for::<crate::api::core::v1::Container>()),
729 },
730 "dnsConfig": ({
731 let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::PodDNSConfig>();
732 schema_obj.ensure_object().insert("description".into(), "Specifies the DNS parameters of a pod. Parameters specified here will be merged to the generated DNS configuration based on DNSPolicy.".into());
733 schema_obj
734 }),
735 "dnsPolicy": {
736 "description": "Set DNS policy for the pod. Defaults to \"ClusterFirst\". Valid values are 'ClusterFirstWithHostNet', 'ClusterFirst', 'Default' or 'None'. DNS parameters given in DNSConfig will be merged with the policy selected with DNSPolicy. To have DNS options set along with hostNetwork, you have to specify DNS policy explicitly to 'ClusterFirstWithHostNet'.",
737 "type": "string",
738 },
739 "enableServiceLinks": {
740 "description": "EnableServiceLinks indicates whether information about services should be injected into pod's environment variables, matching the syntax of Docker links. Optional: Defaults to true.",
741 "type": "boolean",
742 },
743 "ephemeralContainers": {
744 "description": "List of ephemeral containers run in this pod. Ephemeral containers may be run in an existing pod to perform user-initiated actions such as debugging. This list cannot be specified when creating a pod, and it cannot be modified by updating the pod spec. In order to add an ephemeral container to an existing pod, use the pod's ephemeralcontainers subresource.",
745 "type": "array",
746 "items": (__gen.subschema_for::<crate::api::core::v1::EphemeralContainer>()),
747 },
748 "hostAliases": {
749 "description": "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified.",
750 "type": "array",
751 "items": (__gen.subschema_for::<crate::api::core::v1::HostAlias>()),
752 },
753 "hostIPC": {
754 "description": "Use the host's ipc namespace. Optional: Default to false.",
755 "type": "boolean",
756 },
757 "hostNetwork": {
758 "description": "Host networking requested for this pod. Use the host's network namespace. If this option is set, the ports that will be used must be specified. Default to false.",
759 "type": "boolean",
760 },
761 "hostPID": {
762 "description": "Use the host's pid namespace. Optional: Default to false.",
763 "type": "boolean",
764 },
765 "hostUsers": {
766 "description": "Use the host's user namespace. Optional: Default to true. If set to true or not present, the pod will be run in the host user namespace, useful for when the pod needs a feature only available to the host user namespace, such as loading a kernel module with CAP_SYS_MODULE. When set to false, a new userns is created for the pod. Setting false is useful for mitigating container breakout vulnerabilities even allowing users to run their containers as root without actually having root privileges on the host. This field is alpha-level and is only honored by servers that enable the UserNamespacesSupport feature.",
767 "type": "boolean",
768 },
769 "hostname": {
770 "description": "Specifies the hostname of the Pod If not specified, the pod's hostname will be set to a system-defined value.",
771 "type": "string",
772 },
773 "imagePullSecrets": {
774 "description": "ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. If specified, these secrets will be passed to individual puller implementations for them to use. More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod",
775 "type": "array",
776 "items": (__gen.subschema_for::<crate::api::core::v1::LocalObjectReference>()),
777 },
778 "initContainers": {
779 "description": "List of initialization containers belonging to the pod. Init containers are executed in order prior to containers being started. If any init container fails, the pod is considered to have failed and is handled according to its restartPolicy. The name for an init container or normal container must be unique among all containers. Init containers may not have Lifecycle actions, Readiness probes, Liveness probes, or Startup probes. The resourceRequirements of an init container are taken into account during scheduling by finding the highest request/limit for each resource type, and then using the max of of that value or the sum of the normal containers. Limits are applied to init containers in a similar fashion. Init containers cannot currently be added or removed. Cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/",
780 "type": "array",
781 "items": (__gen.subschema_for::<crate::api::core::v1::Container>()),
782 },
783 "nodeName": {
784 "description": "NodeName is a request to schedule this pod onto a specific node. If it is non-empty, the scheduler simply schedules this pod onto that node, assuming that it fits resource requirements.",
785 "type": "string",
786 },
787 "nodeSelector": {
788 "description": "NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node's labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/",
789 "type": "object",
790 "additionalProperties": {
791 "type": "string",
792 },
793 },
794 "os": ({
795 let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::PodOS>();
796 schema_obj.ensure_object().insert("description".into(), "Specifies the OS of the containers in the pod. Some pod and container fields are restricted if this is set.\n\nIf the OS field is set to linux, the following fields must be unset: -securityContext.windowsOptions\n\nIf the OS field is set to windows, following fields must be unset: - spec.hostPID - spec.hostIPC - spec.hostUsers - spec.securityContext.appArmorProfile - spec.securityContext.seLinuxOptions - spec.securityContext.seccompProfile - spec.securityContext.fsGroup - spec.securityContext.fsGroupChangePolicy - spec.securityContext.sysctls - spec.shareProcessNamespace - spec.securityContext.runAsUser - spec.securityContext.runAsGroup - spec.securityContext.supplementalGroups - spec.containers[*].securityContext.appArmorProfile - spec.containers[*].securityContext.seLinuxOptions - spec.containers[*].securityContext.seccompProfile - spec.containers[*].securityContext.capabilities - spec.containers[*].securityContext.readOnlyRootFilesystem - spec.containers[*].securityContext.privileged - spec.containers[*].securityContext.allowPrivilegeEscalation - spec.containers[*].securityContext.procMount - spec.containers[*].securityContext.runAsUser - spec.containers[*].securityContext.runAsGroup".into());
797 schema_obj
798 }),
799 "overhead": {
800 "description": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. This field will be autopopulated at admission time by the RuntimeClass admission controller. If the RuntimeClass admission controller is enabled, overhead must not be set in Pod create requests. The RuntimeClass admission controller will reject Pod create requests which have the overhead already set. If RuntimeClass is configured and selected in the PodSpec, Overhead will be set to the value defined in the corresponding RuntimeClass, otherwise it will remain unset and treated as zero. More info: https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md",
801 "type": "object",
802 "additionalProperties": (__gen.subschema_for::<crate::apimachinery::pkg::api::resource::Quantity>()),
803 },
804 "preemptionPolicy": {
805 "description": "PreemptionPolicy is the Policy for preempting pods with lower priority. One of Never, PreemptLowerPriority. Defaults to PreemptLowerPriority if unset.",
806 "type": "string",
807 },
808 "priority": {
809 "description": "The priority value. Various system components use this field to find the priority of the pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority.",
810 "type": "integer",
811 "format": "int32",
812 },
813 "priorityClassName": {
814 "description": "If specified, indicates the pod's priority. \"system-node-critical\" and \"system-cluster-critical\" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default.",
815 "type": "string",
816 },
817 "readinessGates": {
818 "description": "If specified, all readiness gates will be evaluated for pod readiness. A pod is ready when all its containers are ready AND all conditions specified in the readiness gates have status equal to \"True\" More info: https://git.k8s.io/enhancements/keps/sig-network/580-pod-readiness-gates",
819 "type": "array",
820 "items": (__gen.subschema_for::<crate::api::core::v1::PodReadinessGate>()),
821 },
822 "resourceClaims": {
823 "description": "ResourceClaims defines which ResourceClaims must be allocated and reserved before the Pod is allowed to start. The resources will be made available to those containers which consume them by name.\n\nThis is an alpha field and requires enabling the DynamicResourceAllocation feature gate.\n\nThis field is immutable.",
824 "type": "array",
825 "items": (__gen.subschema_for::<crate::api::core::v1::PodResourceClaim>()),
826 },
827 "restartPolicy": {
828 "description": "Restart policy for all containers within the pod. One of Always, OnFailure, Never. In some contexts, only a subset of those values may be permitted. Default to Always. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy",
829 "type": "string",
830 },
831 "runtimeClassName": {
832 "description": "RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the \"legacy\" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: https://git.k8s.io/enhancements/keps/sig-node/585-runtime-class",
833 "type": "string",
834 },
835 "schedulerName": {
836 "description": "If specified, the pod will be dispatched by specified scheduler. If not specified, the pod will be dispatched by default scheduler.",
837 "type": "string",
838 },
839 "schedulingGates": {
840 "description": "SchedulingGates is an opaque list of values that if specified will block scheduling the pod. If schedulingGates is not empty, the pod will stay in the SchedulingGated state and the scheduler will not attempt to schedule the pod.\n\nSchedulingGates can only be set at pod creation time, and be removed only afterwards.",
841 "type": "array",
842 "items": (__gen.subschema_for::<crate::api::core::v1::PodSchedulingGate>()),
843 },
844 "securityContext": ({
845 let mut schema_obj = __gen.subschema_for::<crate::api::core::v1::PodSecurityContext>();
846 schema_obj.ensure_object().insert("description".into(), "SecurityContext holds pod-level security attributes and common container settings. Optional: Defaults to empty. See type description for default values of each field.".into());
847 schema_obj
848 }),
849 "serviceAccount": {
850 "description": "DeprecatedServiceAccount is a deprecated alias for ServiceAccountName. Deprecated: Use serviceAccountName instead.",
851 "type": "string",
852 },
853 "serviceAccountName": {
854 "description": "ServiceAccountName is the name of the ServiceAccount to use to run this pod. More info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/",
855 "type": "string",
856 },
857 "setHostnameAsFQDN": {
858 "description": "If true the pod's hostname will be configured as the pod's FQDN, rather than the leaf name (the default). In Linux containers, this means setting the FQDN in the hostname field of the kernel (the nodename field of struct utsname). In Windows containers, this means setting the registry value of hostname for the registry key HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters to FQDN. If a pod does not have FQDN, this has no effect. Default to false.",
859 "type": "boolean",
860 },
861 "shareProcessNamespace": {
862 "description": "Share a single process namespace between all of the containers in a pod. When this is set containers will be able to view and signal processes from other containers in the same pod, and the first process in each container will not be assigned PID 1. HostPID and ShareProcessNamespace cannot both be set. Optional: Default to false.",
863 "type": "boolean",
864 },
865 "subdomain": {
866 "description": "If specified, the fully qualified Pod hostname will be \"<hostname>.<subdomain>.<pod namespace>.svc.<cluster domain>\". If not specified, the pod will not have a domainname at all.",
867 "type": "string",
868 },
869 "terminationGracePeriodSeconds": {
870 "description": "Optional duration in seconds the pod needs to terminate gracefully. May be decreased in delete request. Value must be non-negative integer. The value zero indicates stop immediately via the kill signal (no opportunity to shut down). If this value is nil, the default grace period will be used instead. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process. Defaults to 30 seconds.",
871 "type": "integer",
872 "format": "int64",
873 },
874 "tolerations": {
875 "description": "If specified, the pod's tolerations.",
876 "type": "array",
877 "items": (__gen.subschema_for::<crate::api::core::v1::Toleration>()),
878 },
879 "topologySpreadConstraints": {
880 "description": "TopologySpreadConstraints describes how a group of pods ought to spread across topology domains. Scheduler will schedule pods in a way which abides by the constraints. All topologySpreadConstraints are ANDed.",
881 "type": "array",
882 "items": (__gen.subschema_for::<crate::api::core::v1::TopologySpreadConstraint>()),
883 },
884 "volumes": {
885 "description": "List of volumes that can be mounted by containers belonging to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes",
886 "type": "array",
887 "items": (__gen.subschema_for::<crate::api::core::v1::Volume>()),
888 },
889 },
890 "required": [
891 "containers",
892 ],
893 })
894 }
895}