summaryrefslogtreecommitdiffstats
path: root/src/db
AgeCommit message (Collapse)Author
2021-11-19Update Copyright string to 2020-2022Matthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-09-17Add GitHash::with_id() to get GitHash object from DB with specific idMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-09-06Add support for filtering by image nameMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-09-06Refactor: Use ? operator to remove indention levelMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-09-06Rewrite interface for finding artifacts with builderMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-17Revert "Add spinner for establishing database connection"Matthias Beyer
This reverts commit ab04d88ae84c33f3577870c10378f0166adf27bc. Having a progress bar for establishing the database connection was just too much noise visually. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-07-27Merge branch 'connecting-spinner'Matthias Beyer
2021-06-30Remove unused codeMatthias Beyer
This piece of code actually did nothing except trace!()-printing. Thus, remove it. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-06-24Add spinner for establishing database connectionMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-06-08Insert-and-get should be executed as transactionMatthias Beyer
This patch makes sure all database functions are executed as transactions, so that we do not accidentially end up in a data race if two butido instances are executing these functions at the same time. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-05-17Fix: Check whether environments are equalMatthias Beyer
This change fixes a bug where two submits that differed only in an environment variable where considered equal: butido build pkg butido build pkg -E FOO=1 the second build reused the artifacts from the first one, which is a bug. Signed-off-by: Matthias Beyer <mail@beyermatthias.de> Tested-by: Matthias Beyer <mail@beyermatthias.de>
2021-05-17Fix: Do not print database password in debug logMatthias Beyer
We have to manually implement Debug here, because otherwise we would print the database password in the debug output, which is CLEARLY a bad idea. Hence, change the debug!() call in the establish_connection() function to (debug-)print `self` and hand-implement the `Debug` trait. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2021-05-11Refactor: Parsing and connection establishing should be member functionsMatthias Beyer
This refactors the parsing of the `DbConnectionConfig` object and the establishing of the connection to be member functions of the type, rather than free functions. Way more idomatic. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-05-11Refactor: Simplify by removing Into<String> implementationMatthias Beyer
This is actually an antipattern, because one should rather implement `ToString` (or rather `Display`). But because our type is nothing that would be displayed anyways, remove it entirely. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-05-11Refactor: Database connection setup codeMatthias Beyer
This patch refactors the database connection setup code to involve less copying of data in memory. It also changes the configuration value type of the database port and the database connection timeout setting to be `u16` instead of `String`, which is another improvement. Because the `DbConnectionConfig` type no longer holds owned values, it must be annotated with a lifetime. Usages were adapted. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-04-26Add support for database connection timeoutMatthias Beyer
This patch adds support for a database connection timeout, giving the user the option to configure one, but hardcoding a default timeout to 30 seconds. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-04-22Add helper functions to load Package from DBMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-04-22Add helper functions to load Image from DBMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-04-22Add helper functions to load Endpoint from DBMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-04-12Fix typoMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-03-11Endpoint configuration as MapMatthias Beyer
This patch rewrites the endpoint configuration format to be a map. The problem here is, that a list of endpoints cannot easily be used with layered configuration, where a part of the configuration lives in the XDG config home of the user and the rest lives in the repository. With this patch, the endpoints are configured with a map instead of an array, which makes it less complicated to overwrite. The name of an endpoint is now the key in the map. A type `EndpointName` was introduced to take advantage of strong typing. Thus, the patch touches a bit more code to adapt to the new type in use. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net> Tested-by: Matthias Beyer <matthias.beyer@atos.net>
2021-03-01Fix: Ignore conflict on duplicated release store nameMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2021-02-25Multiple release storesMatthias Beyer
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>
2021-02-25Add release stores in databaseMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-02-22Merge branch 'misc'Matthias Beyer
2021-02-22Fix: Add missing license headerMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-02-22Fix: Re-use submit UUID if staging directory is overwrittenMatthias Beyer
This patch changes the behaviour if the staging directory is re-used. If the staging directory is re-used, we take the submit UUID from there instead of generating a new one. This way, database entries are added to the already existing submit instead of added to a new one, but the artifacts are put into the staging store of the reused one. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net> Tested-by: Matthias Beyer <matthias.beyer@atos.net>
2021-02-17Pass MergedStores to endpoint/jobs rather than only staging storeMatthias Beyer
This patch changes the code so that the MergedStores object is known in the endpoints and job execution code. This is necessary, because the jobs must be able to load artifacts from the release store as well, for example if a library was released in another submit and we can reuse it because the script for that library didn't change. For that, the interface of StoreRoot::join() was changed - -> Result<FullArtifactPath<'a>> + -> Result<Option<FullArtifactPath<'a>>> whereas it returns an Ok(None) if the artifact requested does not exist. This was necessary to try-joining a path on the store root of the staging store, and if there is no such file continue with try-joining the path on the release store. The calling code got a bit more complex with that change, though. Next, the MergedStores got a `derive(Clone)` because clone()ing it is cheap (two `Arc`s) and necessary to pass it easily to the jobs. Each instance of the code where the staging store was consulted was changed to consult the the release store as well. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-02-16Fix find_artifacts() to not fail if FS object movedMatthias Beyer
This patch fixes a bug in the crate::db::find_artifacts() implementation, which caused the function to fail if the filesystem object was removed. For example, if a package X was built and released, but then removed on the filesystem, this function would try to find that object but fail and cause butido to stop. Because that's not what we want, this function does not fail anymore but simply ignore the not-found object and return nothing for it. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net> Tested-by: Matthias Beyer <matthias.beyer@atos.net>
2021-02-15Add more trace output when filtering jobs by ENVMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-02-15Fix: Remove zero-bytes from script/log before inserting into databaseMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-02-15Log query before executing itMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-02-15Add more error contextMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-02-11Fix: Query must root in the packages tableMatthias Beyer
This fixes the query, because it must start from the packages table and filter for package namd and version, and then join the other tables. The dependency filtering was removed because it was too complex at this points. Also, the release finding was changed so that the Release object is retrieved later in the process of artifact selection. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-02-11Add Artifact::get_release() to get a Release object for the artifact, if it ↵Matthias Beyer
exists Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-02-11Implement find-artifact subcommandMatthias Beyer
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>
2021-02-11Add Job:env() helper to get the ENV of a jobMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-02-05Remove "tree" from submitMatthias Beyer
This removes the "tree" column from the "submits" table. This is because we do not store the build-tree in the database anymore. We don't actually need this feature and we can always re-build the tree from an old commit in the repository. Thus, this is not required anymore. Also, it is less easy to do as soon as the internal implementation changes from a "tree" structure to a "DAG" structure. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2021-01-19Make database types Eq, PartialEqMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-01-18Run `cargo fmt`Matthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-01-15Allow too many arguments for crate::db::models::Job::create()Matthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2021-01-15Merge branch 'released-artifacts'Matthias Beyer
2021-01-14Fix: Submit is associated with Package and ImageMatthias Beyer
Make sure the inner_join() in the "submits" command implementation joins on the jobs table, not on the packages table. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-01-14Update implementation for dedicated release tableMatthias Beyer
This patch updates the implementation for the dedicated release table. First of all, it updates the model types and adds the new `crate::db::models::Release` type for representing releases in the database (which are just pointers to the released artifact). The `db artifacts` command is updated by using a LEFT JOIN with the "releases" table. The `release` command is updated as well, though the change was a bit more complex. First of all, a LEFT OUTER JOIN was added which is essentially the same as the filter for un-released artifacts from before the change. Then, a `.select()` call was added, so we don't load all the objects we don't need anyways. This reduces overhead not only with the database querying but also in the code here, as we do not allocate objects from the database we destruct right away. The updating of the artifact object in the database was changed to generate a new release object in the "releases" table, of course. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-01-13Add LICENSE file and license headersMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-12-14Fix: Add constraints that artifact entries must be unique by path and job idMatthias Beyer
This patch alters the database so that artifact entries in the db are unique by path and job they belong to. The `db::models::Artifact` implementation was updated to select the newly created Artifact object by path and by job id. The uniqueness constraint on the `path` column in the `artifacts` table was dropped. Uncool: We did not generate the constraint name explicitely. That's unfortunate as we have to gamble here that the constraint name is always guaranteed to be the same ("artifacts_path_key"). Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-12-14Add debug output in release subcommandMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-12-08Use EnvironmentVariableName type for names of ENV variablesMatthias Beyer
This makes the typing a bit more helpful by using a type for the name of environment variables. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-12-07Add ArtifactPath, StoreRootMatthias Beyer
This is the first step towards strong path typing for distinction between artifact pathes. It adds a type for Store root pathes and a type for artifact pathes. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-12-07Deny macro_use from external crateMatthias Beyer
Diesel is an exception here, because the generated src/schema.rs file does not automatically contain the necessary imports. All imports were added where necessary. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>