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