MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / docker_mount_from_config

Function docker_mount_from_config

crates/openshell-driver-docker/src/lib.rs:1840–1891  ·  view source on GitHub ↗
(config: &DockerDriverMountConfig)

Source from the content-addressed store, hash-verified

1838}
1839
1840fn docker_mount_from_config(config: &DockerDriverMountConfig) -> Result<Option<Mount>, Status> {
1841 match config {
1842 DockerDriverMountConfig::Bind { .. } => {
1843 // Bind mounts are handled via docker_driver_bind_strings.
1844 Ok(None)
1845 }
1846 DockerDriverMountConfig::Volume {
1847 source,
1848 target,
1849 read_only,
1850 subpath,
1851 } => Ok(Some(Mount {
1852 typ: Some(MountTypeEnum::VOLUME),
1853 source: Some(source.clone()),
1854 target: Some(target.clone()),
1855 read_only: Some(*read_only),
1856 volume_options: subpath.as_ref().map(|subpath| MountVolumeOptions {
1857 subpath: Some(subpath.clone()),
1858 ..Default::default()
1859 }),
1860 ..Default::default()
1861 })),
1862 DockerDriverMountConfig::Tmpfs {
1863 target,
1864 options,
1865 size_bytes,
1866 mode,
1867 } => Ok(Some(Mount {
1868 typ: Some(MountTypeEnum::TMPFS),
1869 target: Some(target.clone()),
1870 tmpfs_options: Some(MountTmpfsOptions {
1871 size_bytes: validate_optional_positive_integral_i64(
1872 *size_bytes,
1873 "tmpfs size_bytes",
1874 )?,
1875 mode: validate_optional_nonnegative_integral_i64(*mode, "tmpfs mode")?,
1876 options: (!options.is_empty())
1877 .then(|| {
1878 options
1879 .iter()
1880 .map(|option| docker_tmpfs_option(option))
1881 .collect::<Result<Vec<_>, _>>()
1882 })
1883 .transpose()?,
1884 }),
1885 ..Default::default()
1886 })),
1887 DockerDriverMountConfig::Image { .. } => Err(Status::failed_precondition(
1888 "invalid docker driver_config: docker image mounts are not supported",
1889 )),
1890 }
1891}
1892
1893fn validate_docker_driver_mounts(
1894 mounts: &[DockerDriverMountConfig],

Callers 1

docker_driver_mountsFunction · 0.85

Tested by

no test coverage detected