Add a web extension and debian package compilation (#5)
All checks were successful
Check go code / build-and-release (push) Successful in 1m9s
All checks were successful
Check go code / build-and-release (push) Successful in 1m9s
Reviewed-on: #5 Co-authored-by: Julien Fastré <julien.fastre@champs-libres.coop> Co-committed-by: Julien Fastré <julien.fastre@champs-libres.coop>
This commit was merged in pull request #5.
This commit is contained in:
@@ -1,26 +1,59 @@
|
||||
use crate::error::GeneralError;
|
||||
use serde::Deserialize;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub(crate) struct Config {
|
||||
pub struct Config {
|
||||
pub gitlab: Vec<GitlabConfig>,
|
||||
pub gitea: Vec<GiteaConfig>,
|
||||
pub openproject: OpenProjectConfig,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub(crate) struct GitlabConfig {
|
||||
pub struct GitlabConfig {
|
||||
pub token: String,
|
||||
pub domain: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub(crate) struct GiteaConfig {
|
||||
pub struct GiteaConfig {
|
||||
pub token: String,
|
||||
pub domain: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub(crate) struct OpenProjectConfig {
|
||||
pub struct OpenProjectConfig {
|
||||
pub token: String,
|
||||
pub base_url: String,
|
||||
}
|
||||
|
||||
pub struct BuildConfigError {
|
||||
msg: String,
|
||||
}
|
||||
|
||||
impl Into<GeneralError> for BuildConfigError {
|
||||
fn into(self) -> GeneralError {
|
||||
GeneralError {
|
||||
description: format!("Could not build config: {}", self.msg),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build_config(config_path: &Path) -> Result<Config, BuildConfigError> {
|
||||
let config_path_content = match fs::read_to_string(config_path) {
|
||||
Ok(content) => content,
|
||||
Err(e) => {
|
||||
return Err(BuildConfigError {
|
||||
msg: format!(
|
||||
"Could not read a config file at {:?}, error: {}",
|
||||
config_path, e
|
||||
),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
let config: Config = toml::from_str(&*config_path_content).expect("Could not parse config");
|
||||
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user