k8s_openapi_ext/ext/
configmap_volume_source.rs1use super::*;
2
3pub trait ConfigMapVolumeSourceExt: Sized {
5 fn new(name: impl ToString) -> Self;
6
7 fn optional(self, yes: bool) -> Self;
8
9 fn required(self) -> Self {
10 self.optional(false)
11 }
12
13 fn default_mode(self, mode: i32) -> Self;
14
15 fn items(self, items: impl IntoIterator<Item = (impl ToString, impl ToString)>) -> Self;
16}
17
18impl ConfigMapVolumeSourceExt for corev1::ConfigMapVolumeSource {
19 fn new(name: impl ToString) -> Self {
20 let name = name.to_string();
21 Self { name, ..default() }
22 }
23
24 fn optional(mut self, yes: bool) -> Self {
25 self.optional = Some(yes);
26 self
27 }
28
29 fn default_mode(mut self, mode: i32) -> Self {
30 self.default_mode = Some(mode);
31 self
32 }
33
34 fn items(self, items: impl IntoIterator<Item = (impl ToString, impl ToString)>) -> Self {
35 let items = Some(
36 items
37 .into_iter()
38 .map(|(key, path)| corev1::KeyToPath {
39 key: key.to_string(),
40 path: path.to_string(),
41 ..default()
42 })
43 .collect(),
44 );
45 Self { items, ..self }
46 }
47}