summaryrefslogtreecommitdiff
path: root/src/config.rs
blob: 0c9c35c51d52220cd0b9837fbe81611ec444af2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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)
    }
}