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
use super::*;
pub trait PodTemplateSpecExt {
fn new(name: impl ToString) -> Self;
fn labels(self, labels: impl IntoIterator<Item = (impl ToString, impl ToString)>) -> Self;
fn pod_spec(self, spec: corev1::PodSpec) -> Self;
}
impl PodTemplateSpecExt for corev1::PodTemplateSpec {
fn new(name: impl ToString) -> Self {
Self {
metadata: Some(metadata(name)),
spec: None,
}
}
fn labels(self, labels: impl IntoIterator<Item = (impl ToString, impl ToString)>) -> Self {
let labels = labels
.into_iter()
.map(|(key, value)| (key.to_string(), value.to_string()))
.collect();
let mut metadata = self.metadata.unwrap_or_default();
metadata.labels = Some(labels);
Self {
metadata: Some(metadata),
..self
}
}
fn pod_spec(self, spec: corev1::PodSpec) -> Self {
Self {
spec: Some(spec),
..self
}
}
}