blob: 294c5cbbcc564b3a272b02d99ab8d2c418367e81 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
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;
#[derive(Debug)]
pub struct Configuration<'reg> {
pub (in crate::config) inner: NotValidatedConfiguration,
pub (in crate::config) hb: Handlebars<'reg>,
}
impl<'reg> Deref for Configuration<'reg> {
type Target = NotValidatedConfiguration;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
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")
}
}
|