/** * The dao module contains all the necessary object model definitions for Geoffrey to store data on * disk */ /** * The v1 module contains the initial version of data access objects/models */ pub mod v1 { use glob::glob; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Project { /// The specific type of SCM for the project scm: ScmType, /// The name of the project name: String, /// The URL slug for the project slug: String, /// A user-friendly plaintext or markdown description of the project description: Option, /// The trigger for executing the project trigger: TriggerType, } impl Project { pub fn load_all() -> Vec { use std::fs::File; let mut projects = vec![]; for entry in glob("projects.d/**/*.yml").expect("Failed to read projects glob") { match entry { Ok(path) => { projects.push( serde_yaml::from_reader(File::open(path).expect("Failed to open path")) .expect("Failed to load") ); }, Err(e) => println!("{:?}", e), } } projects } } #[derive(Clone, Debug, Deserialize, Serialize)] pub enum ScmType { Git { url: String, }, } #[derive(Clone, Debug, Deserialize, Serialize)] pub enum TriggerType { Manual, Cron { schedule: String, }, } #[cfg(test)] mod tests { use super::*; } }