k8s_openapi_ext/ext/
node.rs1use super::*;
2
3pub trait NodeExt: ResourceBuilder {
7 fn new(name: impl ToString) -> Self;
10
11 fn taints(self, taints: impl IntoIterator<Item = corev1::Taint>) -> Self;
14
15 fn unschedulable(self) -> Self;
18}
19
20impl NodeExt for corev1::Node {
21 fn new(name: impl ToString) -> Self {
22 let metadata = metadata(name);
23 Self {
24 metadata,
25 ..default()
28 }
29 }
30
31 fn taints(mut self, taints: impl IntoIterator<Item = corev1::Taint>) -> Self {
32 let taints = taints.into_iter().collect();
33 self.spec_mut().taints = Some(taints);
34 self
35 }
36
37 fn unschedulable(mut self) -> Self {
38 self.spec_mut().unschedulable = Some(true);
39 self
40 }
41}
42
43impl HasSpec for corev1::Node {
44 type Spec = corev1::NodeSpec;
45
46 fn spec_mut(&mut self) -> &mut Self::Spec {
47 self.spec.get_or_insert_with(default)
48 }
49}