diff --git a/src/cmd/sandbox.rs b/src/cmd/sandbox.rs index 1f5fd33..c5b569b 100644 --- a/src/cmd/sandbox.rs +++ b/src/cmd/sandbox.rs @@ -8,6 +8,7 @@ use std::path::{Path, PathBuf}; use std::time::Duration; /// The Docker image used for sandboxing. +#[derive(Clone)] pub struct SandboxImage { name: String, } @@ -146,6 +147,7 @@ pub struct SandboxBuilder { user: Option, cmd: Vec, enable_networking: bool, + image: Option, } impl SandboxBuilder { @@ -160,6 +162,7 @@ impl SandboxBuilder { user: None, cmd: Vec::new(), enable_networking: true, + image: None, } } @@ -203,6 +206,14 @@ impl SandboxBuilder { self } + /// Override the image used for this sandbox. + /// + /// By default rustwide will use the image from the `Workspace`. + pub fn image(mut self, image: SandboxImage) -> Self { + self.image = Some(image); + self + } + pub(super) fn env, S2: Into>(mut self, key: S1, value: S2) -> Self { self.env.push((key.into(), value.into())); self @@ -274,7 +285,11 @@ impl SandboxBuilder { args.push("--isolation=process".into()); } - args.push(workspace.sandbox_image().name.clone()); + if let Some(image) = self.image { + args.push(image.name); + } else { + args.push(workspace.sandbox_image().name.clone()); + } for arg in self.cmd { args.push(arg);