summaryrefslogtreecommitdiffstats
path: root/src/config
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-12-07 13:26:09 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-12-07 13:26:09 +0100
commit5ff10cdad822300a04ffe3cb2482e20c37d7c2bd (patch)
tree6ffcc770c6bd2e69666fc3721b5143a76941b28a /src/config
parent36cb25353426ac2791dfb0ea335f1dd311aa66f3 (diff)
parente44ca9d61d420d9d0b9a7e6ca4f39068a1790067 (diff)
Merge branch 'cleanup' into master
Diffstat (limited to 'src/config')
-rw-r--r--src/config/configuration.rs6
-rw-r--r--src/config/not_validated.rs20
2 files changed, 17 insertions, 9 deletions
diff --git a/src/config/configuration.rs b/src/config/configuration.rs
index 162115b..10ee21a 100644
--- a/src/config/configuration.rs
+++ b/src/config/configuration.rs
@@ -1,10 +1,4 @@
-use std::collections::BTreeMap;
use std::ops::Deref;
-use std::path::PathBuf;
-
-use anyhow::Context;
-use anyhow::Result;
-use handlebars::Handlebars;
use crate::config::NotValidatedConfiguration;
diff --git a/src/config/not_validated.rs b/src/config/not_validated.rs
index c8fbb3f..b827be6 100644
--- a/src/config/not_validated.rs
+++ b/src/config/not_validated.rs
@@ -2,7 +2,6 @@ use std::path::PathBuf;
use anyhow::anyhow;
use anyhow::Result;
use getset::Getters;
-use handlebars::Handlebars;
use serde::Deserialize;
use crate::config::Configuration;
@@ -41,7 +40,7 @@ pub struct NotValidatedConfiguration {
#[serde(rename = "source_cache")]
#[getset(get = "pub")]
- source_cache_root: String,
+ source_cache_root: PathBuf,
#[getset(get = "pub")]
#[serde(rename = "database_host")]
@@ -75,7 +74,22 @@ pub struct NotValidatedConfiguration {
impl NotValidatedConfiguration {
pub fn validate(self) -> Result<Configuration> {
- // TODO: Implement proper validation
+ if !self.staging_directory.is_dir() {
+ return Err(anyhow!("Not a directory: staging = {}", self.staging_directory.display()))
+ }
+
+ if !self.releases_directory.is_dir() {
+ return Err(anyhow!("Not a directory: releases = {}", self.releases_directory.display()))
+ }
+
+ if !self.source_cache_root.is_dir() {
+ return Err(anyhow!("Not a directory: releases = {}", self.source_cache_root.display()))
+ }
+
+ if self.available_phases.is_empty() {
+ return Err(anyhow!("No phases configured"))
+ }
+
if let Some(configured_theme) = self.script_highlight_theme.as_ref() {
let allowed_theme_present = [
"base16-ocean.dark",