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
use super::*;
pub trait StorageClassExt: super::ResourceBuilder {
fn with_provisioner(name: impl ToString, provisioner: impl ToString) -> Self;
fn allow_volume_expansion(self, yes: bool) -> Self;
fn mount_options(self, options: impl IntoIterator<Item = impl ToString>) -> Self;
fn parameters(
self,
parameters: impl IntoIterator<Item = (impl ToString, impl ToString)>,
) -> Self;
fn retain(self) -> Self;
fn delete(self) -> Self;
fn immediate(self) -> Self;
fn wait_for_first_consumer(self) -> Self;
}
impl StorageClassExt for storagev1::StorageClass {
fn with_provisioner(name: impl ToString, provisioner: impl ToString) -> Self {
let metadata = metadata(name);
let provisioner = provisioner.to_string();
Self {
metadata,
provisioner,
..default()
}
}
fn allow_volume_expansion(self, yes: bool) -> Self {
Self {
allow_volume_expansion: Some(yes),
..self
}
}
fn mount_options(self, options: impl IntoIterator<Item = impl ToString>) -> Self {
let mount_options = options
.into_iter()
.map(|option| option.to_string())
.collect();
Self {
mount_options: Some(mount_options),
..self
}
}
fn parameters(
self,
parameters: impl IntoIterator<Item = (impl ToString, impl ToString)>,
) -> Self {
let parameters = parameters
.into_iter()
.map(|(key, value)| (key.to_string(), value.to_string()))
.collect();
Self {
parameters: Some(parameters),
..self
}
}
fn retain(self) -> Self {
Self {
reclaim_policy: Some(String::from("Retain")),
..self
}
}
fn delete(self) -> Self {
Self {
reclaim_policy: Some(String::from("Delete")),
..self
}
}
fn immediate(self) -> Self {
Self {
volume_binding_mode: Some(String::from("Immediate")),
..self
}
}
fn wait_for_first_consumer(self) -> Self {
Self {
volume_binding_mode: Some(String::from("WaitForFirstConsumer")),
..self
}
}
}