diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-12-03 09:36:48 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-12-03 09:36:50 +0100 |
commit | c09c16aa3d1aa7e84b11ff9e8f18c2ce71550dc4 (patch) | |
tree | 3251305d58b6978fb2267eeb8b0284d985c172ce /src/config | |
parent | 28725470845a23e89fbbd84714da29cae85123e9 (diff) |
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 <mail@beyermatthias.de>
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/configuration.rs | 21 | ||||
-rw-r--r-- | src/config/not_validated.rs | 22 |
2 files changed, 9 insertions, 34 deletions
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<String, String>) -> Result<PathBuf> { - 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<String, String>) -> Result<PathBuf> { - 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<String>, #[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<PhaseName>, } -impl<'reg> NotValidatedConfiguration { - pub fn validate(self) -> Result<Configuration<'reg>> { +impl NotValidatedConfiguration { + pub fn validate(self) -> Result<Configuration> { // 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 }) } } |