summaryrefslogtreecommitdiffstats
path: root/crates/driver/src/pin.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/driver/src/pin.rs')
-rw-r--r--crates/driver/src/pin.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/crates/driver/src/pin.rs b/crates/driver/src/pin.rs
new file mode 100644
index 0000000..26e445c
--- /dev/null
+++ b/crates/driver/src/pin.rs
@@ -0,0 +1,39 @@
+use std::{collections::HashMap, fs::File, path::Path};
+
+use serde::{Deserialize, Serialize};
+
+use common::{error::*, string_hash::*};
+
+#[derive(Clone, Debug, Deserialize, Serialize)]
+pub struct Args {
+ pub host: Option<String>,
+ pub target: Option<String>,
+}
+
+#[derive(Clone, Debug, Deserialize, Serialize)]
+pub struct Provides {
+ pub recipe: String,
+ pub task: String,
+ pub output: Vec<String>,
+ pub args: Args,
+}
+
+#[derive(Clone, Debug, Deserialize, Serialize)]
+#[serde(rename_all = "kebab-case")]
+pub struct Pin {
+ pub hash: Option<ArchiveHash>,
+ #[serde(default)]
+ pub provides: Vec<Provides>,
+ #[serde(default)]
+ pub is_rootfs: bool,
+}
+
+pub type Pins = HashMap<String, Pin>;
+
+pub fn read_pins<P: AsRef<Path>>(path: P) -> Result<Pins> {
+ let f = File::open(path)?;
+ let pins: Pins = serde_yaml::from_reader(f)
+ .map_err(Error::new)
+ .context("YAML error")?;
+ Ok(pins)
+}