summaryrefslogtreecommitdiffstats
path: root/crates/common/src/types.rs
blob: 32b918200fda17e61a3d7f414ef6ae340eb1be01 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use std::{
	collections::{HashMap, HashSet},
	fmt::Display,
};

use serde::{Deserialize, Serialize};

use crate::string_hash::*;

#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)]
pub struct TaskID {
	pub recipe: String,
	pub task: String,
}

impl Display for TaskID {
	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
		write!(f, "{}:{}", self.recipe, self.task)
	}
}

#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)]
#[serde(rename_all = "snake_case")]
pub enum Dependency {
	Fetch {
		name: String,
		target_dir: String,
		sha256: StringHash,
	},
	Task {
		output: ArchiveHash,
		path: String,
	},
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Task {
	pub label: String,
	pub command: String,
	pub workdir: String,
	pub rootfs: ArchiveHash,
	pub inherit: Vec<LayerHash>,
	pub depends: HashSet<Dependency>,
	pub outputs: HashMap<String, String>,
	pub pins: HashMap<ArchiveHash, String>,
	pub force_run: bool,
}

#[derive(Clone, Debug, Deserialize, Serialize, Default)]
pub struct TaskOutput {
	pub input_hash: Option<InputHash>,
	pub layer: Option<LayerHash>,
	pub outputs: HashMap<String, ArchiveHash>,
}