From ed9d61a07ac69b9bdaf649356622e2553d0ef72c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 30 Aug 2021 13:22:04 +0200 Subject: Add CLI option to call find-artifacts subcommand with filter for image Signed-off-by: Matthias Beyer --- src/cli.rs | 9 +++++++++ src/commands/find_artifact.rs | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/src/cli.rs b/src/cli.rs index 37df36c..1c6bcb9 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -654,6 +654,15 @@ pub fn cli<'a>() -> App<'a> { .validator(env_pass_validator) .about("Filter for this \"key=value\" environment variable") ) + .arg(Arg::new("image") + .required(false) + .multiple(false) + .long("image") + .short('I') + .takes_value(true) + .value_name("IMAGE") + .about("Only list artifacts that were built on IMAGE") + ) ) .subcommand(App::new("find-pkg") diff --git a/src/commands/find_artifact.rs b/src/commands/find_artifact.rs index fbd8e10..6904cf4 100644 --- a/src/commands/find_artifact.rs +++ b/src/commands/find_artifact.rs @@ -31,6 +31,7 @@ use crate::filestore::path::StoreRoot; use crate::package::PackageVersionConstraint; use crate::repository::Repository; use crate::util::progress::ProgressBars; +use crate::util::docker::ImageName; /// Implementation of the "find_artifact" subcommand pub async fn find_artifact(matches: &ArgMatches, config: &Configuration, progressbars: ProgressBars, repo: Repository, database_connection: PgConnection) -> Result<()> { @@ -50,6 +51,10 @@ pub async fn find_artifact(matches: &ArgMatches, config: &Configuration, progres .transpose()? .unwrap_or_default(); + let image_name = matches.value_of("image") + .map(String::from) + .map(ImageName::from); + log::debug!("Finding artifacts for '{:?}' '{:?}'", package_name_regex, package_version_constraint); let release_stores = config @@ -109,6 +114,7 @@ pub async fn find_artifact(matches: &ArgMatches, config: &Configuration, progres .database_connection(database.clone()) .env_filter(&env_filter) .script_filter(script_filter) + .image_name(image_name.as_ref()) .package(pkg) .build() .run()?; -- cgit v1.2.3