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

Function validate_docker_driver_mounts

crates/openshell-driver-docker/src/lib.rs:1893–1959  ·  view source on GitHub ↗
(
    mounts: &[DockerDriverMountConfig],
    enable_bind_mounts: bool,
)

Source from the content-addressed store, hash-verified

1891}
1892
1893fn validate_docker_driver_mounts(
1894 mounts: &[DockerDriverMountConfig],
1895 enable_bind_mounts: bool,
1896) -> Result<(), Status> {
1897 let mut targets = HashSet::new();
1898 for mount in mounts {
1899 let target = match mount {
1900 DockerDriverMountConfig::Bind { source, target, .. } => {
1901 if !enable_bind_mounts {
1902 return Err(Status::failed_precondition(
1903 "docker bind mounts require enable_bind_mounts = true in [openshell.drivers.docker]",
1904 ));
1905 }
1906 driver_mounts::validate_absolute_mount_source(source, "bind source")
1907 .map_err(Status::failed_precondition)?;
1908 target
1909 }
1910 DockerDriverMountConfig::Volume {
1911 source,
1912 target,
1913 subpath,
1914 ..
1915 } => {
1916 driver_mounts::validate_mount_source(source, "volume source")
1917 .map_err(Status::failed_precondition)?;
1918 if let Some(subpath) = subpath {
1919 driver_mounts::validate_mount_subpath(subpath)
1920 .map_err(Status::failed_precondition)?;
1921 }
1922 target
1923 }
1924 DockerDriverMountConfig::Tmpfs {
1925 target,
1926 options,
1927 size_bytes,
1928 mode,
1929 } => {
1930 validate_optional_positive_integral_i64(*size_bytes, "tmpfs size_bytes")?;
1931 validate_optional_nonnegative_integral_i64(*mode, "tmpfs mode")?;
1932 for option in options {
1933 docker_tmpfs_option(option)?;
1934 }
1935 target
1936 }
1937 DockerDriverMountConfig::Image {
1938 source,
1939 target,
1940 read_only,
1941 subpath,
1942 } => {
1943 let _ = (source, target, read_only, subpath);
1944 return Err(Status::failed_precondition(
1945 "invalid docker driver_config: docker image mounts are not supported",
1946 ));
1947 }
1948 };
1949 driver_mounts::validate_container_mount_target(target)
1950 .map_err(Status::failed_precondition)?;

Callers 2

validated_sandboxMethod · 0.85
docker_driver_configFunction · 0.85

Tested by

no test coverage detected