summaryrefslogtreecommitdiffstats
path: root/src/config
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-01-13 16:18:24 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-01-15 23:16:04 +0100
commit5223f12462f67bb052a515ba8d9422e04288c03a (patch)
tree313e6384d1c89ddd454c1140ba3423d451d152d7 /src/config
parent952fa0bee9f57e8650cafd94ff7da0cd2cbd6cb1 (diff)
Add compatiblity setting in configuration file
This patch adds a compatibility setting in the configuration file, so that butido does not fail late when parsing configuration parameters or package definition files, but early, when the configured compatilibty does not match the version of butido itself. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src/config')
-rw-r--r--src/config/not_validated.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/config/not_validated.rs b/src/config/not_validated.rs
index 87dbc78..eab7cbc 100644
--- a/src/config/not_validated.rs
+++ b/src/config/not_validated.rs
@@ -10,6 +10,7 @@
use std::path::PathBuf;
use anyhow::anyhow;
+use anyhow::Context;
use anyhow::Result;
use getset::Getters;
use serde::Deserialize;
@@ -23,6 +24,9 @@ use crate::package::PhaseName;
#[derive(Debug, Getters, Deserialize)]
pub struct NotValidatedConfiguration {
#[getset(get = "pub")]
+ compatibility: semver::VersionReq,
+
+ #[getset(get = "pub")]
log_dir: PathBuf,
#[serde(default = "default_strict_script_interpolation")]
@@ -99,6 +103,13 @@ pub struct NotValidatedConfiguration {
impl NotValidatedConfiguration {
pub fn validate(self) -> Result<Configuration> {
+ let crate_version = semver::Version::parse(env!("CARGO_PKG_VERSION"))
+ .context("Parsing version of crate (CARGO_PKG_VERSION) into semver::Version object")?;
+
+ if !self.compatibility.matches(&crate_version) {
+ return Err(anyhow!("Configuration is not compatible to butido {}", crate_version))
+ }
+
if let Some(linter) = self.script_linter.as_ref() {
if !linter.is_file() {
return Err(anyhow!("Lint script is not a file: {}", linter.display()))