k8s_openapi_ext/ext/
volume_mount.rs

1use super::*;
2
3/// Builders for `corev1::VolumeMount` objects
4pub trait VolumeMountExt: Sized {
5    fn new(mount_path: impl ToString, volume: &corev1::Volume) -> Self;
6
7    fn read_only(self) -> Self;
8
9    fn sub_path(self, path: impl ToString) -> Self;
10}
11
12impl VolumeMountExt for corev1::VolumeMount {
13    fn new(mount_path: impl ToString, volume: &corev1::Volume) -> Self {
14        let mount_path = mount_path.to_string();
15        let name = volume.name.clone();
16        Self {
17            mount_path,
18            name,
19            // mount_propagation: todo!(),
20            // read_only: todo!(),
21            // sub_path: todo!(),
22            // sub_path_expr: todo!(),
23            ..default()
24        }
25    }
26
27    fn read_only(mut self) -> Self {
28        self.read_only = Some(true);
29        self
30    }
31
32    fn sub_path(mut self, path: impl ToString) -> Self {
33        self.sub_path = Some(path.to_string());
34        self
35    }
36}