summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-06-25 19:11:30 +0200
committerMatthias Beyer <matthias.beyer@atos.net>2021-09-16 12:32:18 +0200
commit27f6085f0cc2f882656d40e2b4665e20a4a80959 (patch)
tree9dd7b122cc3a0960f47c276608f29f33a4ae2c04
parent3cc328a5f5857b95299d0ef998be5dcc3ddde6a7 (diff)
Add CLI parameters for tree-of subcommand to add condition-checking data
This patch adds parameters for the tree-of subcommand which can be used to change the package-DAG-building based on conditional requirements. If a package has a dependency-condition that only includes a dependency if there is a certain image used to build, the "image" parameter can be used to inspect the package tree (DAG) build with that image in mind. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
-rw-r--r--src/cli.rs29
-rw-r--r--src/commands/tree_of.rs15
2 files changed, 42 insertions, 2 deletions
diff --git a/src/cli.rs b/src/cli.rs
index dbafd91..bc14341 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -1061,6 +1061,35 @@ pub fn cli<'a>() -> App<'a> {
.value_name("VERSION_CONSTRAINT")
.about("A version constraint to search for (optional), E.G. '=1.0.0'")
)
+ .arg(Arg::new("image")
+ .required(false)
+ .multiple(false)
+ .takes_value(true)
+ .value_name("IMAGE NAME")
+ .short('I')
+ .long("image")
+ .about("Name of the docker image to use")
+ .long_about(indoc::indoc!(r#"
+ Name of the docker image to use.
+
+ Required because tree might look different on different images because of
+ conditions on dependencies.
+ "#))
+ )
+ .arg(Arg::new("env")
+ .required(false)
+ .multiple(true)
+ .short('E')
+ .long("env")
+ .validator(env_pass_validator)
+ .about("Additional env to be passed when building packages")
+ .long_about(indoc::indoc!(r#"
+ Additional env to be passed when building packages.
+
+ Required because tree might look different on different images because of
+ conditions on dependencies.
+ "#))
+ )
)
.subcommand(App::new("metrics")
diff --git a/src/commands/tree_of.rs b/src/commands/tree_of.rs
index f5ce223..09fcabf 100644
--- a/src/commands/tree_of.rs
+++ b/src/commands/tree_of.rs
@@ -40,9 +40,20 @@ pub async fn tree_of(
.map(PackageVersionConstraint::try_from)
.transpose()?;
+ let image_name = matches
+ .value_of("image")
+ .map(String::from)
+ .map(ImageName::from);
+
+ let additional_env = matches
+ .values_of("env")
+ .unwrap_or_default()
+ .map(crate::util::env::parse_to_env)
+ .collect::<Result<Vec<(EnvironmentVariableName, String)>>>()?;
+
let condition_data = ConditionData {
- image_name: None
- env: &[],
+ image_name: image_name.as_ref(),
+ env: &additional_env,
};
repo.packages()