summaryrefslogtreecommitdiffstats
path: root/src/filestore
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-01-25 12:58:38 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-02-11 18:40:48 +0100
commit94d062da9a2040b2a424dd530a647d3827eb4989 (patch)
treebf04e03db48a1db327074f4797d26c5bef0e4136 /src/filestore
parent2c4adce9fe8cef616ded756bb10b50e5ec782ecc (diff)
Implement find-artifact subcommand
This patch implements the find-artifact subcommand, which is the basis for artifact finding. Right now we have the problem that finding artifacts after the fact is non-trivial. What we can do, though, is search for them in the database using the same inputs as the ones that created the artifact. That means that if we want to find an artifact or multiple artifacts for a package P in version V, we have to search the database for jobs that built that package in that version, with the same script and the same variables (environment, used container image, etc). So if a package was built with the same script, the same environment variables and on an image that is, for example, not in the denylist of the package, chances are good that the artifacts produced by the job for the package are the ones we search for. In the `crate::command::find_artifact()` function, results are sorted before they are printed, so that we preferrably print results with a release date. Env filtering is also implemented, so a user has to provide the appropriate additional environment variables, as they were submitted for the `buid` command when the artifact was built. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net> Tested-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src/filestore')
-rw-r--r--src/filestore/path.rs2
-rw-r--r--src/filestore/release.rs9
-rw-r--r--src/filestore/util.rs5
3 files changed, 14 insertions, 2 deletions
diff --git a/src/filestore/path.rs b/src/filestore/path.rs
index c26b9c6..eeb946d 100644
--- a/src/filestore/path.rs
+++ b/src/filestore/path.rs
@@ -98,7 +98,7 @@ impl StoreRoot {
pub struct ArtifactPath(PathBuf);
impl ArtifactPath {
- pub(in crate::filestore) fn new(p: PathBuf) -> Result<Self> {
+ pub fn new(p: PathBuf) -> Result<Self> {
if p.is_relative() {
Ok(ArtifactPath(p))
} else {
diff --git a/src/filestore/release.rs b/src/filestore/release.rs
index d7a7232..f19f69a 100644
--- a/src/filestore/release.rs
+++ b/src/filestore/release.rs
@@ -13,6 +13,7 @@ use std::fmt::Debug;
use anyhow::Result;
use indicatif::ProgressBar;
+use crate::filestore::path::ArtifactPath;
use crate::filestore::path::StoreRoot;
use crate::filestore::util::FileStoreImpl;
@@ -29,4 +30,12 @@ impl ReleaseStore {
pub fn load(root: StoreRoot, progress: ProgressBar) -> Result<Self> {
FileStoreImpl::load(root, progress).map(ReleaseStore)
}
+
+ pub fn root_path(&self) -> &StoreRoot {
+ self.0.root_path()
+ }
+
+ pub fn get(&self, p: &ArtifactPath) -> Option<&ArtifactPath> {
+ self.0.get(p)
+ }
}
diff --git a/src/filestore/util.rs b/src/filestore/util.rs
index 0d98404..53f5919 100644
--- a/src/filestore/util.rs
+++ b/src/filestore/util.rs
@@ -35,7 +35,10 @@ impl FileStoreImpl {
pub fn load(root: StoreRoot, progress: ProgressBar) -> Result<Self> {
let store = root
.find_artifacts_recursive()
- .inspect(|_| progress.tick())
+ .inspect(|path| {
+ log::trace!("Found artifact path: {:?}", path);
+ progress.tick();
+ })
.collect::<Result<HashSet<ArtifactPath>>>()?;
Ok(FileStoreImpl { root, store })