-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add DB initialization module #556
Conversation
1ae2321
to
228bc45
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm, reviewed for English conventions and with limited Rust knowledge.
718e550
to
7585e98
Compare
Moving this PR back to draft since we need separate sql initialization files. |
Updated, there are now three different databases. Build/tests blocked until puiterwijk/rust-openssl-kdf#16 goes in and a new release is made. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
The `StoredItem` struct is no longer needed just in the rendezvous server, we are making it public and moving it to the data-formats lib so that it can be easily included in other modules. Signed-off-by: Irene Diez <[email protected]>
This provides an interface defining the methods that we expect to be used for OV handling operations. Added an implementation for sqlite and postgress. Added db creation files and tests. Signed-off-by: Irene Diez <[email protected]>
Adds new dependencies and creates a sqlite database to be used in the tests. Signed-off-by: Irene Diez <[email protected]>
This adds the store interface methods for the SqliteManufacturerStore. Signed-off-by: Irene Diez <[email protected]>
Signed-off-by: Irene Diez <[email protected]>
This adds the store trait for the Sqlite Owner DB. Signed-off-by: Irene Diez <[email protected]>
This implements the store trait for the Sqlite Rendezvous DB. Signed-off-by: Irene Diez <[email protected]>
When selecting to use the DB as the store type in the configuration files, this requires to select the DB type (sqlite or postgres) and the server type. Signed-off-by: Irene Diez <[email protected]>
When we are trying to parse raw data to make an ownership voucher we did not check whether the slice was empty or not, causing a panic in such case. This change explicitly checks if the slice is empty or not, and in the former case returns an error. Signed-off-by: Irene Diez <[email protected]>
This adds the `export_manufacturer_vouchers` option to the Owner CLI, which allows to export OVs from the Manufacturer Server's DB to a directory. The options are to export a single OV by GUID or all of them. Updated the DB trait to add the `select *` query that yields all the OVs in the Manufacturer. Signed-off-by: Irene Diez <[email protected]>
Signed-off-by: Irene Diez <[email protected]>
We are going to propagate the errors unless those are related to getting a connection to the DB. Signed-off-by: Irene Diez <[email protected]>
Signed-off-by: Irene Diez <[email protected]>
The `query_data` method makes no sense when using databases since it uses different types of lists to query the required data, when that's a single query in a database; thereby we are adding the `query_ovs_db` method which explicitly queries the required data from the database. We are also adding a new error type `StoreError::MethodNotAvailable` that will be yielded when we call `query_data` from a database store implementation, or when we call the new `query_ovs_db` method from a directory store implementation. Signed-off-by: Irene Diez <[email protected]>
When the Owner server needs to report OVs to the Rendezvous server, check whether we have the old `query_data` method available or the new `query_ovs_db` method to choose the most effective one. Signed-off-by: Irene Diez <[email protected]>
Replace all the `StoreError::Unspecified` errors with the new `StoreError::Database` when there is an internal database error. Signed-off-by: Irene Diez <[email protected]>
This changes the filters so that they correctly take into account NULL values. In order to set a NULL value we need to use None in rust, but for filtering instead of using None we need to filter by `is_null()`. Signed-off-by: Irene Diez <[email protected]>
This changes the `store_data` method so that it expects a Value of type `StoredItem` for the serialization and deserialization of data. Signed-off-by: Irene Diez <[email protected]>
Signed-off-by: Irene Diez <[email protected]>
Signed-off-by: Irene Diez <[email protected]>
Signed-off-by: Irene Diez <[email protected]>
Since the migrations are unified in a single folder the tests have been updated accordingly. Signed-off-by: Irene Diez <[email protected]>
Adds sqlite and libpq crates to devcontainer creation for successful building and testing in dev container. Also adds diesel scripts to dev container build to enable successful dev container integration testing. Signed-off-by: djach7 <[email protected]>
Signed-off-by: Irene Diez <[email protected]>
This provides an interface defining the methods that we expect to be used for OV handling operations.
Added an implementation for sqlite and postgress. I have been unable to make the implementation more generic (aka just one definition of each of the functions of the lib) with a trait with two generic types instead of one, because the
Connection
trait (which holdsSqliteConnection
andPgConnection
) cannot be made into an object. But I'm happy to learn how to refactor it if someone has ideas.Added db creation files and tests,
the PR is marked as draft since I still need to wire the tests to our upstream CI, making just the sqlite dependencies required, we don't want to install a postgresql server.Update: This also adds the capability to select the DB storage method in the relevant server configuration files, the store interface implementation, and two new functions in the fdo-owner-cli in order to export OVs from the manufacturing server and import OVs into the owner-onboarding server.