summaryrefslogtreecommitdiffstats
path: root/src/runner/runc/run.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/runner/runc/run.rs')
-rw-r--r--src/runner/runc/run.rs46
1 files changed, 6 insertions, 40 deletions
diff --git a/src/runner/runc/run.rs b/src/runner/runc/run.rs
index e7fb393..897fb47 100644
--- a/src/runner/runc/run.rs
+++ b/src/runner/runc/run.rs
@@ -4,14 +4,11 @@ use nix::{
mount::{self, MsFlags},
sched::{self, CloneFlags},
};
-use oci_spec::runtime;
use serde::{Deserialize, Serialize};
-use crate::{
- types::*,
- unshare,
- util::{Checkable, ToIOResult},
-};
+use crate::{types::*, util::ToIOResult};
+
+use super::spec;
#[derive(Debug, Deserialize, Serialize)]
pub enum Error {
@@ -52,43 +49,12 @@ fn init_task() -> Result<(), Error> {
Ok(())
}
-fn configure_spec(path: &str, run: &str) {
- let mut spec = runtime::Spec::load(path).unwrap();
-
- let process = spec.process.as_mut().unwrap();
- process.terminal = Some(false);
- process.user = runtime::User {
- uid: unshare::BUILD_UID,
- gid: unshare::BUILD_GID,
- additional_gids: None,
- username: None,
- };
- process.args = Some(
- vec!["sh", "-c", run]
- .into_iter()
- .map(str::to_string)
- .collect(),
- );
- process.cwd = "/rebel".to_string();
-
- let root = spec.root.as_mut().unwrap();
- root.path = "../rootfs".to_string();
-
- spec.hostname = Some("rebel-builder".to_string());
-
- spec.save(path).unwrap();
-}
-
pub fn handle_task(task: TaskRef, task_def: Task) -> Result<(), Error> {
init_task()?;
- process::Command::new("runc")
- .arg("spec")
- .current_dir("build/tmp/runc")
- .status()?
- .check()?;
-
- configure_spec("build/tmp/runc/config.json", task_def.run.as_str());
+ spec::generate_spec(task_def.run.as_str())
+ .save("build/tmp/runc/config.json")
+ .expect("Saving runtime spec failed");
let output = process::Command::new("runc")
.arg("--root")