diff options
author | Lars Wirzenius <liw@liw.fi> | 2020-12-13 12:47:48 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2020-12-13 13:08:20 +0200 |
commit | f039d822db63d46c772c85f44db36909656ebf05 (patch) | |
tree | 7528f8409f02747e61f56f4b9bc6fa202eb11bad /src/config.rs | |
parent | 17d9868e93f429db6807266cbaaaa19d3212821a (diff) | |
download | contractor2-f039d822db63d46c772c85f44db36909656ebf05.tar.gz |
feat: add "dump" subcommand
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..0c9c35c --- /dev/null +++ b/src/config.rs @@ -0,0 +1,23 @@ +use log::trace; +use serde::{Deserialize, Serialize}; +use std::fs::File; +use std::path::{Path, PathBuf}; + +#[derive(Debug, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] +pub struct Config { + pub worker_image: PathBuf, + pub source: PathBuf, + pub workspace: Option<PathBuf>, + pub ansible: serde_yaml::Value, + pub build: String, +} + +impl Config { + pub fn read(filename: &Path) -> anyhow::Result<Self> { + trace!("filename={:?}", filename); + let file = File::open(filename)?; + let config: Config = serde_yaml::from_reader(file)?; + Ok(config) + } +} |