Skip to content

Commit 87f3a0f

Browse files
committed
respect command configs in sanboxed env
1 parent 8bdfd2a commit 87f3a0f

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
### Changed
99

10+
- Subcommands executed in sandbox respect configs of parent command
1011
- Added logging of exact image hash used during build
1112

1213
## [0.7.1] - 2020-05-20

src/cmd/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,10 @@ impl<'w, 'pl> Command<'w, 'pl> {
364364
self.timeout,
365365
self.no_output_timeout,
366366
self.process_lines,
367-
)?;
368-
Ok(ProcessOutput {
369-
stdout: Vec::new(),
370-
stderr: Vec::new(),
371-
})
367+
self.log_output,
368+
self.log_command,
369+
capture,
370+
)
372371
} else {
373372
let (binary, managed_by_rustwide) = match self.binary {
374373
Binary::Global(path) => (path, false),

src/cmd/sandbox.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::cmd::{Command, CommandError, ProcessLinesActions};
1+
use crate::cmd::{Command, CommandError, ProcessLinesActions, ProcessOutput};
22
use crate::Workspace;
33
use failure::Error;
44
use log::{error, info};
@@ -277,13 +277,17 @@ impl SandboxBuilder {
277277
})
278278
}
279279

280+
#[allow(clippy::too_many_arguments)]
280281
pub(super) fn run(
281282
self,
282283
workspace: &Workspace,
283284
timeout: Option<Duration>,
284285
no_output_timeout: Option<Duration>,
285286
process_lines: Option<&mut dyn FnMut(&str, &mut ProcessLinesActions)>,
286-
) -> Result<(), Error> {
287+
log_output: bool,
288+
log_command: bool,
289+
capture: bool,
290+
) -> Result<ProcessOutput, Error> {
287291
let container = self.create(workspace)?;
288292

289293
// Ensure the container is properly deleted even if something panics
@@ -297,8 +301,14 @@ impl SandboxBuilder {
297301
}
298302
}}
299303

300-
container.run(timeout, no_output_timeout, process_lines)?;
301-
Ok(())
304+
container.run(
305+
timeout,
306+
no_output_timeout,
307+
process_lines,
308+
log_output,
309+
log_command,
310+
capture,
311+
)
302312
}
303313
}
304314

@@ -345,17 +355,22 @@ impl Container<'_> {
345355
timeout: Option<Duration>,
346356
no_output_timeout: Option<Duration>,
347357
process_lines: Option<&mut dyn FnMut(&str, &mut ProcessLinesActions)>,
348-
) -> Result<(), Error> {
358+
log_output: bool,
359+
log_command: bool,
360+
capture: bool,
361+
) -> Result<ProcessOutput, Error> {
349362
let mut cmd = Command::new(self.workspace, "docker")
350363
.args(&["start", "-a", &self.id])
351364
.timeout(timeout)
365+
.log_output(log_output)
366+
.log_command(log_command)
352367
.no_output_timeout(no_output_timeout);
353368

354369
if let Some(f) = process_lines {
355370
cmd = cmd.process_lines(f);
356371
}
357372

358-
let res = cmd.run();
373+
let res = cmd.run_inner(capture);
359374
let details = self.inspect()?;
360375

361376
// Return a different error if the container was killed due to an OOM

0 commit comments

Comments
 (0)