diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2021-10-28 23:21:20 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2021-10-28 23:28:04 +0200 |
commit | 8b71986fe1d7a6a889cbb437294b76b22a1e7377 (patch) | |
tree | b09e7687ff33adc98548aa254dc2e689c82e992d | |
parent | fc117b0900cfcba6f5f87882e15c7d263171f6c3 (diff) | |
download | rebel-8b71986fe1d7a6a889cbb437294b76b22a1e7377.tar rebel-8b71986fe1d7a6a889cbb437294b76b22a1e7377.zip |
Pass workdir from driver to runner
The paths modules of driver and runner do not contain any duplicates
anymore. One remaining path that still appears in more places than it
should is /build.
-rw-r--r-- | crates/common/src/types.rs | 1 | ||||
-rw-r--r-- | crates/driver/src/driver.rs | 1 | ||||
-rw-r--r-- | crates/runner/src/paths.rs | 1 | ||||
-rw-r--r-- | crates/runner/src/task.rs | 4 |
4 files changed, 5 insertions, 2 deletions
diff --git a/crates/common/src/types.rs b/crates/common/src/types.rs index f45d1dd..0dad60c 100644 --- a/crates/common/src/types.rs +++ b/crates/common/src/types.rs @@ -37,6 +37,7 @@ pub enum Dependency { pub struct Task { pub label: String, pub command: String, + pub workdir: String, pub inherit: Vec<LayerHash>, pub depends: HashSet<Dependency>, pub outputs: HashMap<String, String>, diff --git a/crates/driver/src/driver.rs b/crates/driver/src/driver.rs index 3927291..d7106c3 100644 --- a/crates/driver/src/driver.rs +++ b/crates/driver/src/driver.rs @@ -294,6 +294,7 @@ impl<'ctx> Driver<'ctx> { let task = Task { label: format!("{:#}", task_ref), command, + workdir: paths::TASK_WORKDIR.to_string(), inherit: inherit_chain, depends: task_deps, outputs: task_output, diff --git a/crates/runner/src/paths.rs b/crates/runner/src/paths.rs index 660021c..738cb54 100644 --- a/crates/runner/src/paths.rs +++ b/crates/runner/src/paths.rs @@ -60,7 +60,6 @@ pub const TASK_STATE_WORK_SUBDIR: &str = "work"; pub const TASK_BUILDDIR: &str = "build"; pub const TASK_TASKDIR: &str = "build/task"; -pub const TASK_WORKDIR: &str = "build/work"; pub const TASK_RUN: &str = "run"; diff --git a/crates/runner/src/task.rs b/crates/runner/src/task.rs index a909d22..47fa9e4 100644 --- a/crates/runner/src/task.rs +++ b/crates/runner/src/task.rs @@ -44,12 +44,14 @@ fn input_hash(task: &Task) -> InputHash { #[derive(Debug, Serialize)] struct HashInput<'a> { pub command: &'a str, + pub workdir: &'a str, pub inherit: &'a [LayerHash], pub depends: HashMap<DependencyHash, &'a Dependency>, pub outputs: &'a HashMap<String, String>, } let input = HashInput { command: &task.command, + workdir: &task.workdir, inherit: &task.inherit, depends: task .depends @@ -83,7 +85,7 @@ fn init_task(input_hash: &InputHash, task: &Task) -> Result<fs::Mount> { std::fs::write(&runfile, &task.command) .with_context(|| format!("Failed to write {}", runfile))?; - let mount_target = paths::join(&[&task_tmp_dir, paths::TASK_WORKDIR]); + let mount_target = paths::join(&[&task_tmp_dir, &task.workdir]); let mount = if task.inherit.is_empty() { fs::mount(task_layer_dir, &mount_target, None, MsFlags::MS_BIND, None) .with_context(|| format!("Failed to bind mount to {:?}", mount_target))? |