k8s_openapi_ext/ext/
storage_class.rs1use super::*;
2
3pub trait StorageClassExt: super::ResourceBuilder {
4 fn with_provisioner(name: impl ToString, provisioner: impl ToString) -> Self;
5
6 fn allow_volume_expansion(self, yes: bool) -> Self;
7 fn mount_options(self, options: impl IntoIterator<Item = impl ToString>) -> Self;
8 fn parameters(
9 self,
10 parameters: impl IntoIterator<Item = (impl ToString, impl ToString)>,
11 ) -> Self;
12 fn retain(self) -> Self;
13 fn delete(self) -> Self;
14 fn immediate(self) -> Self;
15 fn wait_for_first_consumer(self) -> Self;
16}
17
18impl StorageClassExt for storagev1::StorageClass {
19 fn with_provisioner(name: impl ToString, provisioner: impl ToString) -> Self {
20 let metadata = metadata(name);
21 let provisioner = provisioner.to_string();
22 Self {
23 metadata,
24 provisioner,
25 ..default()
32 }
33 }
34
35 fn allow_volume_expansion(self, yes: bool) -> Self {
36 Self {
37 allow_volume_expansion: Some(yes),
38 ..self
39 }
40 }
41
42 fn mount_options(self, options: impl IntoIterator<Item = impl ToString>) -> Self {
43 let mount_options = options
44 .into_iter()
45 .map(|option| option.to_string())
46 .collect();
47
48 Self {
49 mount_options: Some(mount_options),
50 ..self
51 }
52 }
53
54 fn parameters(
55 self,
56 parameters: impl IntoIterator<Item = (impl ToString, impl ToString)>,
57 ) -> Self {
58 let parameters = parameters
59 .into_iter()
60 .map(|(key, value)| (key.to_string(), value.to_string()))
61 .collect();
62
63 Self {
64 parameters: Some(parameters),
65 ..self
66 }
67 }
68
69 fn retain(self) -> Self {
70 Self {
71 reclaim_policy: Some(String::from("Retain")),
72 ..self
73 }
74 }
75
76 fn delete(self) -> Self {
77 Self {
78 reclaim_policy: Some(String::from("Delete")),
79 ..self
80 }
81 }
82
83 fn immediate(self) -> Self {
84 Self {
85 volume_binding_mode: Some(String::from("Immediate")),
86 ..self
87 }
88 }
89
90 fn wait_for_first_consumer(self) -> Self {
91 Self {
92 volume_binding_mode: Some(String::from("WaitForFirstConsumer")),
93 ..self
94 }
95 }
96}