diff --git a/src/config.rs b/src/config.rs index 621d3d7..cb18a54 100644 --- a/src/config.rs +++ b/src/config.rs @@ -4,13 +4,14 @@ */ use serde::de::{Deserialize, Deserializer}; use std::str::FromStr; +use std::collections::HashMap; #[derive(Debug, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Config { pub projects: Vec, pub agents: Vec, - pub handlers: Vec, + pub handlers: HashMap, } #[derive(Debug, Deserialize)] @@ -48,11 +49,26 @@ pub struct Scm { #[derive(Debug, Deserialize)] #[serde(rename_all = "camelCase")] -pub struct Agent {} +pub enum AgentType { + Local, + Ssh, +} #[derive(Debug, Deserialize)] #[serde(rename_all = "camelCase")] -pub struct Handler {} +pub struct Agent { + name: String, + description: String, + r#type: AgentType, + params: Option>, +} + +#[derive(Debug, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct Handler { + filename: String, + defaults: Option>, +} fn deserialize_cron_schedule<'de, D>(deserializer: D) -> Result, D::Error> where @@ -70,8 +86,19 @@ where #[cfg(test)] mod tests { + use std::fs::File; + use std::io::Read; + use super::*; + #[test] + fn test_deserialize_example_config() { + let mut f = File::open("urci.yml").unwrap(); + let mut yaml = String::new(); + f.read_to_string(&mut yaml).expect("Failed to read into string"); + let _config: Config = serde_yaml::from_str(&yaml).expect("Failed to parse the yaml"); + } + #[test] fn test_cron_deserialize() { let trigger_yaml = r#"--- diff --git a/urci.yml b/urci.yml index 4037b31..7b76d85 100644 --- a/urci.yml +++ b/urci.yml @@ -5,7 +5,7 @@ projects: - name: hotdog trigger: - cron: '*/10 * * * *' + cron: '10 * * * * *' # The different types of handlers should be documented elsewhere. In this # case, the project is expected to use a simple .travis-ci.yml handler: travis-ci