k8s_openapi_ext/ext/
secret_volume_source.rs1use super::*;
2
3pub trait SecretVolumeSourceExt: Sized {
5 fn secret_name(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 SecretVolumeSourceExt for corev1::SecretVolumeSource {
19 fn secret_name(name: impl ToString) -> Self {
20 let secret_name = Some(name.to_string());
21 Self {
22 secret_name,
23 ..default()
24 }
25 }
26
27 fn optional(mut self, yes: bool) -> Self {
28 self.optional = Some(yes);
29 self
30 }
31
32 fn default_mode(mut self, mode: i32) -> Self {
33 self.default_mode = Some(mode);
34 self
35 }
36
37 fn items(self, items: impl IntoIterator<Item = (impl ToString, impl ToString)>) -> Self {
38 let items = Some(
39 items
40 .into_iter()
41 .map(|(key, path)| corev1::KeyToPath {
42 key: key.to_string(),
43 path: path.to_string(),
44 ..default()
45 })
46 .collect(),
47 );
48 Self { items, ..self }
49 }
50}