summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-12-03 09:36:48 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-12-03 09:36:50 +0100
commitc09c16aa3d1aa7e84b11ff9e8f18c2ce71550dc4 (patch)
tree3251305d58b6978fb2267eeb8b0284d985c172ce /src
parent28725470845a23e89fbbd84714da29cae85123e9 (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')
-rw-r--r--src/commands/build.rs11
-rw-r--r--src/commands/db.rs4
-rw-r--r--src/commands/dependencies_of.rs2
-rw-r--r--src/commands/find_pkg.rs2
-rw-r--r--src/commands/source.rs10
-rw-r--r--src/commands/what_depends.rs2
-rw-r--r--src/config/configuration.rs21
-rw-r--r--src/config/not_validated.rs22
8 files changed, 23 insertions, 51 deletions
diff --git a/src/commands/build.rs b/src/commands/build.rs
index 530fd3e..32f3a42 100644
--- a/src/commands/build.rs
+++ b/src/commands/build.rs
@@ -27,10 +27,10 @@ use crate::source::SourceCache;
use crate::util::docker::ImageName;
use crate::util::progress::ProgressBars;
-pub async fn build<'a>(matches: &ArgMatches,
+pub async fn build(matches: &ArgMatches,
progressbars: ProgressBars,
database_connection: PgConnection,
- config: &Configuration<'a>,
+ config: &Configuration,
repo: Repository,
repo_path: &Path,
max_packages: u64)
@@ -116,8 +116,7 @@ pub async fn build<'a>(matches: &ArgMatches,
let bar_release_loading = progressbars.release_loading();
bar_release_loading.set_length(max_packages);
- let variables = BTreeMap::new();
- let p = config.releases_directory(&variables)?;
+ let p = config.releases_directory();
debug!("Loading release directory: {}", p.display());
let r = ReleaseStore::load(&p, bar_release_loading.clone());
if r.is_ok() {
@@ -132,13 +131,11 @@ pub async fn build<'a>(matches: &ArgMatches,
let bar_staging_loading = progressbars.staging_loading();
bar_staging_loading.set_length(max_packages);
- let variables = BTreeMap::new();
let p = if let Some(staging_dir) = matches.value_of("staging_dir").map(PathBuf::from) {
info!("Setting staging dir to {} for this run", staging_dir.display());
staging_dir
} else {
- config.staging_directory(&variables)?
- .join(uuid::Uuid::new_v4().hyphenated().to_string())
+ config.staging_directory().join(uuid::Uuid::new_v4().hyphenated().to_string())
};
if !p.is_dir() {
diff --git a/src/commands/db.rs b/src/commands/db.rs
index 00530fd..30a4d42 100644
--- a/src/commands/db.rs
+++ b/src/commands/db.rs
@@ -25,7 +25,7 @@ use crate::db::models;
use crate::log::LogItem;
use crate::schema;
-pub fn db<'a>(db_connection_config: DbConnectionConfig, config: &Configuration<'a>, matches: &ArgMatches) -> Result<()> {
+pub fn db(db_connection_config: DbConnectionConfig, config: &Configuration, matches: &ArgMatches) -> Result<()> {
match matches.subcommand() {
Some(("cli", matches)) => cli(db_connection_config, matches),
Some(("artifacts", matches)) => artifacts(db_connection_config, matches),
@@ -271,7 +271,7 @@ fn jobs(conn_cfg: DbConnectionConfig, matches: &ArgMatches) -> Result<()> {
Ok(())
}
-fn job<'a>(conn_cfg: DbConnectionConfig, config: &Configuration<'a>, matches: &ArgMatches) -> Result<()> {
+fn job(conn_cfg: DbConnectionConfig, config: &Configuration, matches: &ArgMatches) -> Result<()> {
let highlighting_disabled = matches.is_present("script_disable_highlighting");
let configured_theme = config.script_highlight_theme();
diff --git a/src/commands/dependencies_of.rs b/src/commands/dependencies_of.rs
index 355b41f..db0e3f9 100644
--- a/src/commands/dependencies_of.rs
+++ b/src/commands/dependencies_of.rs
@@ -6,7 +6,7 @@ use crate::config::*;
use crate::package::PackageName;
use crate::repository::Repository;
-pub async fn dependencies_of<'a>(matches: &ArgMatches, config: &Configuration<'a>, repo: Repository) -> Result<()> {
+pub async fn dependencies_of(matches: &ArgMatches, config: &Configuration, repo: Repository) -> Result<()> {
use filters::filter::Filter;
let package_filter = {
diff --git a/src/commands/find_pkg.rs b/src/commands/find_pkg.rs
index be35d43..c1f4a91 100644
--- a/src/commands/find_pkg.rs
+++ b/src/commands/find_pkg.rs
@@ -6,7 +6,7 @@ use crate::config::Configuration;
use crate::package::Package;
use crate::repository::Repository;
-pub async fn find_pkg<'a>(matches: &ArgMatches, config: &Configuration<'a>, repo: Repository) -> Result<()> {
+pub async fn find_pkg(matches: &ArgMatches, config: &Configuration, repo: Repository) -> Result<()> {
use filters::filter::Filter;
use std::io::Write;
diff --git a/src/commands/source.rs b/src/commands/source.rs
index 235b709..ef5b5c8 100644
--- a/src/commands/source.rs
+++ b/src/commands/source.rs
@@ -16,7 +16,7 @@ use crate::repository::Repository;
use crate::source::*;
use crate::util::progress::ProgressBars;
-pub async fn source<'a>(matches: &ArgMatches, config: &Configuration<'a>, repo: Repository, progressbars: ProgressBars) -> Result<()> {
+pub async fn source(matches: &ArgMatches, config: &Configuration, repo: Repository, progressbars: ProgressBars) -> Result<()> {
match matches.subcommand() {
Some(("verify", matches)) => verify(matches, config, repo).await,
Some(("list-missing", matches)) => list_missing(matches, config, repo).await,
@@ -27,7 +27,7 @@ pub async fn source<'a>(matches: &ArgMatches, config: &Configuration<'a>, repo:
}
}
-pub async fn verify<'a>(matches: &ArgMatches, config: &Configuration<'a>, repo: Repository) -> Result<()> {
+pub async fn verify(matches: &ArgMatches, config: &Configuration, repo: Repository) -> Result<()> {
let source_cache_root = PathBuf::from(config.source_cache_root());
let sc = SourceCache::new(source_cache_root);
let pname = matches.value_of("package_name").map(String::from).map(PackageName::from);
@@ -72,7 +72,7 @@ pub (in crate::commands) async fn verify_impl<'a, I>(packages: I, sc: &SourceCac
}
}
-pub async fn list_missing<'a>(_: &ArgMatches, config: &Configuration<'a>, repo: Repository) -> Result<()> {
+pub async fn list_missing(_: &ArgMatches, config: &Configuration, repo: Repository) -> Result<()> {
let sc = SourceCache::new(PathBuf::from(config.source_cache_root()));
let out = std::io::stdout();
let mut outlock = out.lock();
@@ -90,7 +90,7 @@ pub async fn list_missing<'a>(_: &ArgMatches, config: &Configuration<'a>, repo:
.collect()
}
-pub async fn url<'a>(matches: &ArgMatches, config: &Configuration<'a>, repo: Repository) -> Result<()> {
+pub async fn url(matches: &ArgMatches, config: &Configuration, repo: Repository) -> Result<()> {
let out = std::io::stdout();
let mut outlock = out.lock();
@@ -109,7 +109,7 @@ pub async fn url<'a>(matches: &ArgMatches, config: &Configuration<'a>, repo: Rep
.collect()
}
-pub async fn download<'a>(matches: &ArgMatches, config: &Configuration<'a>, repo: Repository, progressbars: ProgressBars) -> Result<()> {
+pub async fn download(matches: &ArgMatches, config: &Configuration, repo: Repository, progressbars: ProgressBars) -> Result<()> {
let force = matches.is_present("force");
let cache = PathBuf::from(config.source_cache_root());
let sc = SourceCache::new(cache);
diff --git a/src/commands/what_depends.rs b/src/commands/what_depends.rs
index fc2c125..0204251 100644
--- a/src/commands/what_depends.rs
+++ b/src/commands/what_depends.rs
@@ -8,7 +8,7 @@ use crate::config::*;
use crate::package::PackageName;
use crate::repository::Repository;
-pub async fn what_depends<'a>(matches: &ArgMatches, config: &Configuration<'a>, repo: Repository) -> Result<()> {
+pub async fn what_depends(matches: &ArgMatches, config: &Configuration, repo: Repository) -> Result<()> {
use filters::failable::filter::FailableFilter;
let print_runtime_deps = getbool(matches, "dependency_type", crate::cli::IDENT_DEPENDENCY_TYPE_RUNTIME);
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 })
}
}