summaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-12-13 12:47:48 +0200
committerLars Wirzenius <liw@liw.fi>2020-12-13 13:08:20 +0200
commitf039d822db63d46c772c85f44db36909656ebf05 (patch)
tree7528f8409f02747e61f56f4b9bc6fa202eb11bad /src/config.rs
parent17d9868e93f429db6807266cbaaaa19d3212821a (diff)
downloadcontractor2-f039d822db63d46c772c85f44db36909656ebf05.tar.gz
feat: add "dump" subcommand
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs23
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)
+ }
+}