Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ use std::time::Duration;
#[derive(Debug, Clone)]
pub struct Ex(String);

#[derive(Debug, Clone)]
pub struct DockerEnv(#[allow(unused)] String);
impl FromStr for Ex {
type Err = Error;

Expand All @@ -43,6 +41,9 @@ impl FromStr for Ex {
}
}

#[derive(Debug, Clone)]
pub struct DockerEnv(String);

impl FromStr for DockerEnv {
type Err = Error;

Expand Down Expand Up @@ -205,7 +206,7 @@ pub enum Crater {
#[clap(name = "threads", short = 't', long = "threads", default_value = "1")]
threads: usize,
#[clap(name = "docker-env", long = "docker-env")]
docker_env: Option<String>,
docker_env: Option<DockerEnv>,
#[clap(name = "fast-workspace-init", long = "fast-workspace-init")]
fast_workspace_init: bool,
},
Expand Down Expand Up @@ -242,7 +243,7 @@ pub enum Crater {
#[clap(name = "threads", short = 't', long = "threads", default_value = "1")]
threads: usize,
#[clap(name = "docker-env", long = "docker-env")]
docker_env: Option<String>,
docker_env: Option<DockerEnv>,
#[clap(name = "fast-workspace-init", long = "fast-workspace-init")]
fast_workspace_init: bool,
#[clap(
Expand Down Expand Up @@ -438,8 +439,7 @@ impl Crater {

let result_db = DatabaseDB::new(&db);

let workspace = self
.workspace(docker_env.as_ref().map(|s| s.as_str()), fast_workspace_init)?;
let workspace = self.workspace(docker_env.as_ref(), fast_workspace_init)?;
workspace.purge_all_build_dirs()?;

let crates =
Expand Down Expand Up @@ -528,8 +528,7 @@ impl Crater {
token,
threads,
&caps,
&self
.workspace(docker_env.as_ref().map(|s| s.as_str()), fast_workspace_init)?,
&self.workspace(docker_env.as_ref(), fast_workspace_init)?,
)?;
}
Crater::CheckConfig { ref filename } => {
Expand All @@ -542,14 +541,18 @@ impl Crater {
Ok(())
}

fn workspace(&self, docker_env: Option<&str>, fast_init: bool) -> Result<Workspace, Error> {
fn workspace(
&self,
docker_env: Option<&DockerEnv>,
fast_init: bool,
) -> Result<Workspace, Error> {
let mut builder = WorkspaceBuilder::new(&crater::dirs::WORK_DIR, &crater::USER_AGENT)
.fast_init(fast_init)
.fetch_registry_index_during_builds(true)
.command_timeout(Some(Duration::from_secs(15 * 60)))
.command_no_output_timeout(Some(Duration::from_secs(5 * 60)))
.running_inside_docker(std::env::var("CRATER_INSIDE_DOCKER").is_ok());
if let Some(env) = docker_env {
if let Some(DockerEnv(env)) = docker_env {
builder = builder.sandbox_image(if env.contains('/') {
SandboxImage::remote(env)?
} else {
Expand Down