diff --git a/src/cmd/sandbox.rs b/src/cmd/sandbox.rs index 1f5fd33..8e7fdee 100644 --- a/src/cmd/sandbox.rs +++ b/src/cmd/sandbox.rs @@ -146,6 +146,7 @@ pub struct SandboxBuilder { user: Option, cmd: Vec, enable_networking: bool, + image: Option, } impl SandboxBuilder { @@ -160,6 +161,7 @@ impl SandboxBuilder { user: None, cmd: Vec::new(), enable_networking: true, + image: None, } } @@ -203,6 +205,14 @@ impl SandboxBuilder { self } + /// Override the image used for this sandbox. + /// + /// By default rustwide will use the image configured with [`WorkspaceBuilder::sandbox_image`]. + pub fn image(mut self, image: SandboxImage) -> Self { + self.image = Some(image.name); + self + } + pub(super) fn env, S2: Into>(mut self, key: S1, value: S2) -> Self { self.env.push((key.into(), value.into())); self @@ -274,7 +284,11 @@ impl SandboxBuilder { args.push("--isolation=process".into()); } - args.push(workspace.sandbox_image().name.clone()); + if let Some(image) = self.image { + args.push(image); + } else { + args.push(workspace.sandbox_image().name.clone()); + } for arg in self.cmd { args.push(arg); diff --git a/src/crates/mod.rs b/src/crates/mod.rs index 6e330c5..d9ce4a5 100644 --- a/src/crates/mod.rs +++ b/src/crates/mod.rs @@ -73,7 +73,8 @@ impl Crate { } } - pub(crate) fn copy_source_to(&self, workspace: &Workspace, dest: &Path) -> Result<(), Error> { + /// Copy this crate's source to `dest`. If `dest` already exists, it will be replaced. + pub fn copy_source_to(&self, workspace: &Workspace, dest: &Path) -> Result<(), Error> { if dest.exists() { info!( "crate source directory {} already exists, cleaning it up",