diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-12-03 09:16:30 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-12-04 08:45:22 +0100 |
commit | 0b67aeebc1c50f3a0ba61c6b1fcc0272071d87f8 (patch) | |
tree | d6bacb15cb3703054e58a0f29eaf547785b1cf23 /src/job | |
parent | 5b4617aec92fc0f7666162e3a2b8080f87f0258c (diff) |
Add strict script interpolation
This patch adds strict script interpolation, which means that the script
interpolation will result in an error if a variable is referenced that
does not exist.
Before this patch, referencing an absent variable did result in an empty
string, possibly resulting in an error at runtime.
This feature is on by default.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/job')
-rw-r--r-- | src/job/runnable.rs | 5 | ||||
-rw-r--r-- | src/job/set.rs | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/job/runnable.rs b/src/job/runnable.rs index ab2d6ca..5e6387a 100644 --- a/src/job/runnable.rs +++ b/src/job/runnable.rs @@ -6,6 +6,7 @@ use getset::Getters; use tokio::stream::StreamExt; use uuid::Uuid; +use crate::config::Configuration; use crate::filestore::MergedStores; use crate::job::Job; use crate::job::JobResource; @@ -40,9 +41,9 @@ pub struct RunnableJob { } impl RunnableJob { - pub async fn build_from_job(job: Job, merged_stores: &MergedStores, source_cache: &SourceCache) -> Result<Self> { + pub async fn build_from_job(job: Job, merged_stores: &MergedStores, source_cache: &SourceCache, config: &Configuration) -> Result<Self> { let script = ScriptBuilder::new(&job.script_shebang) - .build(&job.package, &job.script_phases)?; + .build(&job.package, &job.script_phases, *config.strict_script_interpolation())?; trace!("Preparing build dependencies"); let resources = { diff --git a/src/job/set.rs b/src/job/set.rs index 745b38d..a428cce 100644 --- a/src/job/set.rs +++ b/src/job/set.rs @@ -1,6 +1,7 @@ use anyhow::Result; use tokio::stream::StreamExt; +use crate::config::Configuration; use crate::filestore::MergedStores; use crate::job::Job; use crate::job::RunnableJob; @@ -24,10 +25,10 @@ impl JobSet { self.set.is_empty() } - pub async fn into_runables<'a>(self, merged_stores: &'a MergedStores, source_cache: &'a SourceCache) -> Result<Vec<RunnableJob>> { + pub async fn into_runables<'a>(self, merged_stores: &'a MergedStores, source_cache: &'a SourceCache, config: &Configuration) -> Result<Vec<RunnableJob>> { self.set .into_iter() - .map(move |j| RunnableJob::build_from_job(j, merged_stores, source_cache)) + .map(move |j| RunnableJob::build_from_job(j, merged_stores, source_cache, config)) .collect::<futures::stream::FuturesUnordered<_>>() .collect::<Result<Vec<RunnableJob>>>() .await |