From c09c16aa3d1aa7e84b11ff9e8f18c2ce71550dc4 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 3 Dec 2020 09:36:48 +0100 Subject: Remove variable interpolation in config file This was unused anyways, and I am not even sure what we implemented it for. Signed-off-by: Matthias Beyer --- src/config/configuration.rs | 21 ++------------------- src/config/not_validated.rs | 22 +++++++--------------- 2 files changed, 9 insertions(+), 34 deletions(-) (limited to 'src/config') diff --git a/src/config/configuration.rs b/src/config/configuration.rs index 294c5cb..162115b 100644 --- a/src/config/configuration.rs +++ b/src/config/configuration.rs @@ -9,12 +9,11 @@ use handlebars::Handlebars; use crate::config::NotValidatedConfiguration; #[derive(Debug)] -pub struct Configuration<'reg> { +pub struct Configuration { pub (in crate::config) inner: NotValidatedConfiguration, - pub (in crate::config) hb: Handlebars<'reg>, } -impl<'reg> Deref for Configuration<'reg> { +impl Deref for Configuration { type Target = NotValidatedConfiguration; fn deref(&self) -> &Self::Target { @@ -22,19 +21,3 @@ impl<'reg> Deref for Configuration<'reg> { } } -impl<'reg> Configuration<'reg> { - /// Get the path to the releases directory, interpolate every variable used in the config - pub fn releases_directory(&self, hm: &BTreeMap) -> Result { - self.hb.render("releases", hm) - .map(PathBuf::from) - .context("Interpolating variables into 'release' setting from configuration") - } - - /// Get the path to the staging directory, interpolate every variable used in the config - pub fn staging_directory(&self, hm: &BTreeMap) -> Result { - self.hb.render("staging", hm) - .map(PathBuf::from) - .context("Interpolating variables into 'staging' setting from configuration") - } -} - diff --git a/src/config/not_validated.rs b/src/config/not_validated.rs index c91a0cb..a18b19c 100644 --- a/src/config/not_validated.rs +++ b/src/config/not_validated.rs @@ -28,10 +28,12 @@ pub struct NotValidatedConfiguration { script_highlight_theme: Option, #[serde(rename = "releases")] - releases_directory: String, + #[getset(get = "pub")] + releases_directory: PathBuf, #[serde(rename = "staging")] - staging_directory: String, + #[getset(get = "pub")] + staging_directory: PathBuf, #[serde(rename = "source_cache")] #[getset(get = "pub")] @@ -67,8 +69,8 @@ pub struct NotValidatedConfiguration { available_phases: Vec, } -impl<'reg> NotValidatedConfiguration { - pub fn validate(self) -> Result> { +impl NotValidatedConfiguration { + pub fn validate(self) -> Result { // TODO: Implement proper validation if let Some(configured_theme) = self.script_highlight_theme.as_ref() { let allowed_theme_present = [ @@ -86,17 +88,7 @@ impl<'reg> NotValidatedConfiguration { } } - let hb = { - let mut hb = Handlebars::new(); - hb.register_template_string("releases", &self.releases_directory)?; - hb.register_template_string("staging", &self.staging_directory)?; - hb - }; - - Ok(Configuration { - inner: self, - hb, - }) + Ok(Configuration { inner: self }) } } -- cgit v1.2.3