65 lines
1.8 KiB
Rust
65 lines
1.8 KiB
Rust
/**
|
|
* 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<String>,
|
|
/// The trigger for executing the project
|
|
trigger: TriggerType,
|
|
/// Optional inline script, otherwise Geoffrey will look for a file in the repo
|
|
script: Option<String>,
|
|
}
|
|
|
|
impl Project {
|
|
pub fn load_all() -> Vec<Project> {
|
|
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::*;
|
|
}
|
|
}
|