use std::path::PathBuf;
use super::guest_volume::GuestVolumeManager;
#[derive(Debug, Clone)]
pub struct ContainerMount {
pub volume_name: String,
pub destination: String,
pub read_only: bool,
pub owner_uid: u32,
pub owner_gid: u32,
}
pub struct ContainerVolumeManager<'a> {
guest: &'a mut GuestVolumeManager,
container_mounts: Vec<ContainerMount>,
}
impl<'a> ContainerVolumeManager<'a> {
pub fn new(guest: &'a mut GuestVolumeManager) -> Self {
Self {
guest,
container_mounts: Vec::new(),
}
}
#[allow(clippy::too_many_arguments)]
pub fn add_volume(
&mut self,
container_id: &str,
volume_name: &str,
tag: &str,
host_path: PathBuf,
container_path: &str,
read_only: bool,
owner_uid: u32,
owner_gid: u32,
) {
self.guest.add_fs_share(
tag,
host_path,
None,
read_only,
Some(container_id.to_string()),
);
self.container_mounts.push(ContainerMount {
volume_name: volume_name.to_string(),
destination: container_path.to_string(),
read_only,
owner_uid,
owner_gid,
});
}
#[allow(dead_code)]
pub fn add_bind(&mut self, volume_name: &str, container_path: &str, read_only: bool) {
self.container_mounts.push(ContainerMount {
volume_name: volume_name.to_string(),
destination: container_path.to_string(),
read_only,
owner_uid: 0,
owner_gid: 0,
});
}
pub fn build_container_mounts(&self) -> Vec<ContainerMount> {
self.container_mounts.clone()
}
}