File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ use std::path::{Path, PathBuf};
88use std:: time:: Duration ;
99
1010/// The Docker image used for sandboxing.
11+ #[ derive( Clone ) ]
1112pub struct SandboxImage {
1213 name : String ,
1314}
@@ -146,6 +147,7 @@ pub struct SandboxBuilder {
146147 user : Option < String > ,
147148 cmd : Vec < String > ,
148149 enable_networking : bool ,
150+ image : Option < SandboxImage > ,
149151}
150152
151153impl SandboxBuilder {
@@ -160,6 +162,7 @@ impl SandboxBuilder {
160162 user : None ,
161163 cmd : Vec :: new ( ) ,
162164 enable_networking : true ,
165+ image : None ,
163166 }
164167 }
165168
@@ -203,6 +206,14 @@ impl SandboxBuilder {
203206 self
204207 }
205208
209+ /// Override the image used for this sandbox.
210+ ///
211+ /// By default rustwide will use the image from the `Workspace`.
212+ pub fn image ( mut self , image : SandboxImage ) -> Self {
213+ self . image = Some ( image) ;
214+ self
215+ }
216+
206217 pub ( super ) fn env < S1 : Into < String > , S2 : Into < String > > ( mut self , key : S1 , value : S2 ) -> Self {
207218 self . env . push ( ( key. into ( ) , value. into ( ) ) ) ;
208219 self
@@ -274,7 +285,11 @@ impl SandboxBuilder {
274285 args. push ( "--isolation=process" . into ( ) ) ;
275286 }
276287
277- args. push ( workspace. sandbox_image ( ) . name . clone ( ) ) ;
288+ if let Some ( image) = self . image {
289+ args. push ( image. name ) ;
290+ } else {
291+ args. push ( workspace. sandbox_image ( ) . name . clone ( ) ) ;
292+ }
278293
279294 for arg in self . cmd {
280295 args. push ( arg) ;
You can’t perform that action at this time.
0 commit comments