k8s_openapi_ext/ext/
daemon_set.rs1use super::*;
2
3pub trait DaemonSetExt: super::ResourceBuilder {
4 fn new(name: impl ToString) -> Self;
5 fn with_labels(
6 name: impl ToString,
7 labels: impl IntoIterator<Item = (impl ToString, impl ToString)>,
8 ) -> Self;
9
10 fn spec(self, spec: appsv1::DaemonSetSpec) -> Self;
11
12 fn min_ready_seconds(self, seconds: i32) -> Self;
13
14 fn revision_history_limit(self, limit: i32) -> Self;
15
16 fn selector(self, selector: metav1::LabelSelector) -> Self;
17
18 fn match_labels(
19 self,
20 match_labels: impl IntoIterator<Item = (impl ToString, impl ToString)>,
21 ) -> Self;
22
23 fn update_strategy(self, strategy: appsv1::DaemonSetUpdateStrategy) -> Self;
24
25 fn template(self, template: corev1::PodTemplateSpec) -> Self;
26
27 fn pod(self, pod: corev1::PodSpec) -> Self;
28}
29
30impl DaemonSetExt for appsv1::DaemonSet {
31 fn new(name: impl ToString) -> Self {
32 let metadata = metadata(name);
33 Self {
34 metadata,
35 ..default()
38 }
39 }
40
41 fn with_labels(
42 name: impl ToString,
43 labels: impl IntoIterator<Item = (impl ToString, impl ToString)>,
44 ) -> Self {
45 Self::new(name).labels(labels)
46 }
47
48 fn spec(self, spec: appsv1::DaemonSetSpec) -> Self {
49 Self {
50 spec: Some(spec),
51 ..self
52 }
53 }
54
55 fn min_ready_seconds(mut self, seconds: i32) -> Self {
56 self.spec_mut().min_ready_seconds.replace(seconds);
57 self
58 }
59
60 fn revision_history_limit(mut self, limit: i32) -> Self {
61 self.spec_mut().revision_history_limit.replace(limit);
62 self
63 }
64
65 fn selector(mut self, selector: metav1::LabelSelector) -> Self {
66 self.spec_mut().selector = selector;
67 self
68 }
69
70 fn match_labels(
71 mut self,
72 match_labels: impl IntoIterator<Item = (impl ToString, impl ToString)>,
73 ) -> Self {
74 self.spec_mut().selector = metav1::LabelSelector::match_labels(match_labels);
75 self
76 }
77
78 fn update_strategy(mut self, strategy: appsv1::DaemonSetUpdateStrategy) -> Self {
79 self.spec_mut().update_strategy.replace(strategy);
80 self
81 }
82
83 fn template(mut self, template: corev1::PodTemplateSpec) -> Self {
84 self.spec_mut().template = template;
85 self
86 }
87
88 fn pod(mut self, pod_spec: corev1::PodSpec) -> Self {
89 self.spec_mut().template.spec.replace(pod_spec);
90 self
91 }
92}
93
94impl HasSpec for appsv1::DaemonSet {
95 type Spec = appsv1::DaemonSetSpec;
96
97 fn spec_mut(&mut self) -> &mut Self::Spec {
98 self.spec.get_or_insert_default()
99 }
100}