diff options
author | Matthias Beyer <matthias.beyer@atos.net> | 2021-06-25 19:09:52 +0200 |
---|---|---|
committer | Matthias Beyer <matthias.beyer@atos.net> | 2021-09-16 12:32:18 +0200 |
commit | 3cc328a5f5857b95299d0ef998be5dcc3ddde6a7 (patch) | |
tree | af2945fe2dfdf111b766221f914538f32fbf20e9 /src/commands | |
parent | 7902138f93e397c8a41f0699e970924916d613b0 (diff) |
Add passing of data for condition-check
This patch extends the interface for building the package DAG with a parameter
for the data that is required to check conditions for conditional dependencies.
A "DTO" type is added for this data.
The actual condition-checking is not implemented in this patch.
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/build.rs | 8 | ||||
-rw-r--r-- | src/commands/tree_of.rs | 11 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/commands/build.rs b/src/commands/build.rs index d0e473b..8148a33 100644 --- a/src/commands/build.rs +++ b/src/commands/build.rs @@ -43,6 +43,7 @@ use crate::package::Dag; use crate::package::PackageName; use crate::package::PackageVersion; use crate::package::Shebang; +use crate::package::condition::ConditionData; use crate::repository::Repository; use crate::schema; use crate::source::SourceCache; @@ -226,7 +227,12 @@ pub async fn build( let dag = { let bar_tree_building = progressbars.bar(); - let dag = Dag::for_root_package(package.clone(), &repo, Some(&bar_tree_building))?; + let condition_data = ConditionData { + image_name: Some(&image_name), + env: &additional_env, + }; + + let dag = Dag::for_root_package(package.clone(), &repo, Some(&bar_tree_building), &condition_data)?; bar_tree_building.finish_with_message("Finished loading Dag"); dag }; diff --git a/src/commands/tree_of.rs b/src/commands/tree_of.rs index 6b297e3..f5ce223 100644 --- a/src/commands/tree_of.rs +++ b/src/commands/tree_of.rs @@ -20,7 +20,11 @@ use resiter::AndThen; use crate::package::Dag; use crate::package::PackageName; use crate::package::PackageVersionConstraint; +use crate::package::condition::ConditionData; use crate::repository::Repository; +use crate::util::EnvironmentVariableName; +use crate::util::docker::ImageName; +use crate::util::progress::ProgressBars; /// Implementation of the "tree_of" subcommand pub async fn tree_of( @@ -36,6 +40,11 @@ pub async fn tree_of( .map(PackageVersionConstraint::try_from) .transpose()?; + let condition_data = ConditionData { + image_name: None + env: &[], + }; + repo.packages() .filter(|p| pname.as_ref().map(|n| p.name() == n).unwrap_or(true)) .filter(|p| { @@ -44,7 +53,7 @@ pub async fn tree_of( .map(|v| v.matches(p.version())) .unwrap_or(true) }) - .map(|package| Dag::for_root_package(package.clone(), &repo, None)) + .map(|package| Dag::for_root_package(package.clone(), &repo, None, &condition_data)) .and_then_ok(|tree| { let stdout = std::io::stdout(); let mut outlock = stdout.lock(); |