diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2021-10-30 00:29:20 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2021-11-01 23:17:47 +0100 |
commit | 54578efb4fe92e26a25bc9329c07ac0a8dc33deb (patch) | |
tree | 0f8d56256010eec337f21d4c514fc7123c362674 /crates/driver/src/pin.rs | |
parent | fddeb158b550a938358ee8251741514b362c68b6 (diff) | |
download | rebel-54578efb4fe92e26a25bc9329c07ac0a8dc33deb.tar rebel-54578efb4fe92e26a25bc9329c07ac0a8dc33deb.zip |
driver: read pins from YAML file
Diffstat (limited to 'crates/driver/src/pin.rs')
-rw-r--r-- | crates/driver/src/pin.rs | 39 |
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) +} |