diff options
author | Matthias Beyer <matthias.beyer@atos.net> | 2021-02-22 10:44:19 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-02-25 10:40:16 +0100 |
commit | fe5b97425fa08854b4f1ce37451166f8a81d54d2 (patch) | |
tree | 01f3c7f85b4599e16fff44425c93789b825aeccc /src/db | |
parent | df1ab6c67de7591f849b14b8bdd94aadfc8fe961 (diff) |
Multiple release stores
This patch adds the ability to have more than one release store.
With this patch, a user can (has to) configure release store names in the
configuration file, and can then specify one of the configured names to release
the artifacts to.
This way, different release "channels" can be served, for example a stable
channel and a rolling release channel (although "channel" is not in our wording).
The code was adapted to be able to fetch releases from multiple release
directories, in the crate::db::find_artifact implementation, so that re-using
artifacts works across all release directories.
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src/db')
-rw-r--r-- | src/db/find_artifacts.rs | 11 | ||||
-rw-r--r-- | src/db/models/artifact.rs | 4 | ||||
-rw-r--r-- | src/db/models/releases.rs | 1 |
3 files changed, 11 insertions, 5 deletions
diff --git a/src/db/find_artifacts.rs b/src/db/find_artifacts.rs index e3e418d..b4fbe3b 100644 --- a/src/db/find_artifacts.rs +++ b/src/db/find_artifacts.rs @@ -54,7 +54,7 @@ pub fn find_artifacts<'a>( database_connection: Arc<PgConnection>, config: &Configuration, pkg: &Package, - release_store: &'a ReleaseStore, + release_stores: &'a [Arc<ReleaseStore>], staging_store: Option<&'a StagingStore>, additional_env: &[(EnvironmentVariableName, String)], script_filter: bool, @@ -220,11 +220,14 @@ pub fn find_artifacts<'a>( // If we cannot find the artifact in the release store either, we return None. // This is the case if there indeed was a release, but it was removed from the // filesystem. - if let Some(art) = release_store.get(&artpath) { - trace!("Found in release: {:?}", art); - return release_store.root_path().join(art).map(|p| p.map(|p| (p, ndt))) + for release_store in release_stores { + if let Some(art) = release_store.get(&artpath) { + trace!("Found in release: {:?}", art); + return release_store.root_path().join(art).map(|p| p.map(|p| (p, ndt))) + } } + trace!("Found no release for artifact {:?} in any release store", artpath.display()); Ok(None) }) .filter_map_ok(|opt| opt) diff --git a/src/db/models/artifact.rs b/src/db/models/artifact.rs index 11e2cec..e5adbaf 100644 --- a/src/db/models/artifact.rs +++ b/src/db/models/artifact.rs @@ -48,8 +48,10 @@ impl Artifact { self, database_connection: &PgConnection, release_date: &NaiveDateTime, + release_store_name: &str, ) -> Result<crate::db::models::Release> { - crate::db::models::Release::create(database_connection, &self, release_date) + let rs = crate::db::models::ReleaseStore::create(database_connection, release_store_name)?; + crate::db::models::Release::create(database_connection, &self, release_date, &rs) } pub fn get_release(&self, database_connection: &PgConnection) -> Result<Option<Release>> { diff --git a/src/db/models/releases.rs b/src/db/models/releases.rs index 9136fee..48e4f02 100644 --- a/src/db/models/releases.rs +++ b/src/db/models/releases.rs @@ -47,6 +47,7 @@ impl Release { let new_rel = NewRelease { artifact_id: art.id, release_date: date, + release_store_id: store.id, }; diesel::insert_into(releases::table) |