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
use super::*;
pub trait ConfigMapExt: ResourceBuilder {
fn new(name: impl ToString) -> Self;
fn immutable(self, yes: bool) -> Self;
fn binary_data(self, data: impl IntoIterator<Item = (impl ToString, ByteString)>) -> Self;
fn data(self, data: impl IntoIterator<Item = (impl ToString, impl ToString)>) -> Self;
fn data_mut(&mut self) -> &mut BTreeMap<String, String>;
fn binary_data_mut(&mut self) -> &mut BTreeMap<String, ByteString>;
}
impl ConfigMapExt for corev1::ConfigMap {
fn new(name: impl ToString) -> Self {
let metadata = metadata(name);
Self {
metadata,
..default()
}
}
fn immutable(self, yes: bool) -> Self {
let immutable = Some(yes);
Self { immutable, ..self }
}
fn binary_data(self, data: impl IntoIterator<Item = (impl ToString, ByteString)>) -> Self {
let data = data
.into_iter()
.map(|(key, value)| (key.to_string(), value))
.collect();
Self {
binary_data: Some(data),
..self
}
}
fn data(self, data: impl IntoIterator<Item = (impl ToString, impl ToString)>) -> Self {
let data = data
.into_iter()
.map(|(key, value)| (key.to_string(), value.to_string()))
.collect();
Self {
data: Some(data),
..self
}
}
fn data_mut(&mut self) -> &mut BTreeMap<String, String> {
self.data.get_or_insert_with(default)
}
fn binary_data_mut(&mut self) -> &mut BTreeMap<String, ByteString> {
self.binary_data.get_or_insert_with(default)
}
}