File tree 1 file changed +16
-1
lines changed
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};
8
8
use std:: time:: Duration ;
9
9
10
10
/// The Docker image used for sandboxing.
11
+ #[ derive( Clone ) ]
11
12
pub struct SandboxImage {
12
13
name : String ,
13
14
}
@@ -146,6 +147,7 @@ pub struct SandboxBuilder {
146
147
user : Option < String > ,
147
148
cmd : Vec < String > ,
148
149
enable_networking : bool ,
150
+ image : Option < SandboxImage > ,
149
151
}
150
152
151
153
impl SandboxBuilder {
@@ -160,6 +162,7 @@ impl SandboxBuilder {
160
162
user : None ,
161
163
cmd : Vec :: new ( ) ,
162
164
enable_networking : true ,
165
+ image : None ,
163
166
}
164
167
}
165
168
@@ -203,6 +206,14 @@ impl SandboxBuilder {
203
206
self
204
207
}
205
208
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
+
206
217
pub ( super ) fn env < S1 : Into < String > , S2 : Into < String > > ( mut self , key : S1 , value : S2 ) -> Self {
207
218
self . env . push ( ( key. into ( ) , value. into ( ) ) ) ;
208
219
self
@@ -274,7 +285,11 @@ impl SandboxBuilder {
274
285
args. push ( "--isolation=process" . into ( ) ) ;
275
286
}
276
287
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
+ }
278
293
279
294
for arg in self . cmd {
280
295
args. push ( arg) ;
You can’t perform that action at this time.
0 commit comments