summaryrefslogtreecommitdiffstats
path: root/src/runner/runc/run.rs
blob: 9261b7de44874b481c92128da04438e0c7011053 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use std::{io, process};

use serde::{Deserialize, Serialize};

use crate::types::*;
#[derive(Debug, Deserialize, Serialize)]
pub struct Error;

impl From<Error> for io::Error {
	fn from(_: Error) -> Self {
		io::Error::new(io::ErrorKind::Other, "Failed to run task")
	}
}

pub fn handle_task(task: TaskRef, task_def: Task) -> Result<(), Error> {
	let result = process::Command::new("sh")
		.arg("-c")
		.arg(task_def.run)
		.current_dir("build/tmp/runc/rootfs")
		.output();
	if let Ok(output) = result {
		println!(
			"{}:\n{}",
			task,
			String::from_utf8_lossy(output.stdout.as_slice()),
		);
	} else {
		println!("{}:\n\t{:?}", task, result);
	}

	Ok(())
}