aboutsummaryrefslogtreecommitdiff
path: root/planetwars-server/src/modules/registry.rs
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-10-12 22:52:15 +0200
committerIlion Beyst <ilion.beyst@gmail.com>2022-10-12 22:52:15 +0200
commitae57359353cf31ff374a8932999742920878bf00 (patch)
tree0db27d394a2a61a5cc94e73014c82954829c1338 /planetwars-server/src/modules/registry.rs
parented016773b112460ebbf0ff023b0915545229ed41 (diff)
downloadplanetwars.dev-ae57359353cf31ff374a8932999742920878bf00.tar.xz
planetwars.dev-ae57359353cf31ff374a8932999742920878bf00.zip
upgrade to diesel 2.0
Diffstat (limited to 'planetwars-server/src/modules/registry.rs')
-rw-r--r--planetwars-server/src/modules/registry.rs40
1 files changed, 20 insertions, 20 deletions
diff --git a/planetwars-server/src/modules/registry.rs b/planetwars-server/src/modules/registry.rs
index 4a79d59..5e1e05b 100644
--- a/planetwars-server/src/modules/registry.rs
+++ b/planetwars-server/src/modules/registry.rs
@@ -112,8 +112,8 @@ where
Err(RegistryAuthError::InvalidCredentials)
}
} else {
- let db_conn = DatabaseConnection::from_request(req).await.unwrap();
- let user = authenticate_user(&credentials, &db_conn)
+ let mut db_conn = DatabaseConnection::from_request(req).await.unwrap();
+ let user = authenticate_user(&credentials, &mut db_conn)
.ok_or(RegistryAuthError::InvalidCredentials)?;
Ok(RegistryAuth::User(user))
@@ -159,12 +159,12 @@ pub struct RegistryError {
}
async fn check_blob_exists(
- db_conn: DatabaseConnection,
+ mut db_conn: DatabaseConnection,
auth: RegistryAuth,
Path((repository_name, raw_digest)): Path<(String, String)>,
Extension(config): Extension<Arc<GlobalConfig>>,
) -> Result<impl IntoResponse, StatusCode> {
- check_access(&repository_name, &auth, &db_conn)?;
+ check_access(&repository_name, &auth, &mut db_conn)?;
let digest = raw_digest.strip_prefix("sha256:").unwrap();
let blob_path = PathBuf::from(&config.registry_directory)
@@ -179,12 +179,12 @@ async fn check_blob_exists(
}
async fn get_blob(
- db_conn: DatabaseConnection,
+ mut db_conn: DatabaseConnection,
auth: RegistryAuth,
Path((repository_name, raw_digest)): Path<(String, String)>,
Extension(config): Extension<Arc<GlobalConfig>>,
) -> Result<impl IntoResponse, StatusCode> {
- check_access(&repository_name, &auth, &db_conn)?;
+ check_access(&repository_name, &auth, &mut db_conn)?;
let digest = raw_digest.strip_prefix("sha256:").unwrap();
let blob_path = PathBuf::from(&config.registry_directory)
@@ -200,12 +200,12 @@ async fn get_blob(
}
async fn create_upload(
- db_conn: DatabaseConnection,
+ mut db_conn: DatabaseConnection,
auth: RegistryAuth,
Path(repository_name): Path<String>,
Extension(config): Extension<Arc<GlobalConfig>>,
) -> Result<impl IntoResponse, StatusCode> {
- check_access(&repository_name, &auth, &db_conn)?;
+ check_access(&repository_name, &auth, &mut db_conn)?;
let uuid = gen_alphanumeric(16);
tokio::fs::File::create(
@@ -229,13 +229,13 @@ async fn create_upload(
}
async fn patch_upload(
- db_conn: DatabaseConnection,
+ mut db_conn: DatabaseConnection,
auth: RegistryAuth,
Path((repository_name, uuid)): Path<(String, String)>,
mut stream: BodyStream,
Extension(config): Extension<Arc<GlobalConfig>>,
) -> Result<impl IntoResponse, StatusCode> {
- check_access(&repository_name, &auth, &db_conn)?;
+ check_access(&repository_name, &auth, &mut db_conn)?;
// TODO: support content range header in request
let upload_path = PathBuf::from(&config.registry_directory)
@@ -275,14 +275,14 @@ struct UploadParams {
}
async fn put_upload(
- db_conn: DatabaseConnection,
+ mut db_conn: DatabaseConnection,
auth: RegistryAuth,
Path((repository_name, uuid)): Path<(String, String)>,
Query(params): Query<UploadParams>,
mut stream: BodyStream,
Extension(config): Extension<Arc<GlobalConfig>>,
) -> Result<impl IntoResponse, StatusCode> {
- check_access(&repository_name, &auth, &db_conn)?;
+ check_access(&repository_name, &auth, &mut db_conn)?;
let upload_path = PathBuf::from(&config.registry_directory)
.join("uploads")
@@ -332,12 +332,12 @@ async fn put_upload(
}
async fn get_manifest(
- db_conn: DatabaseConnection,
+ mut db_conn: DatabaseConnection,
auth: RegistryAuth,
Path((repository_name, reference)): Path<(String, String)>,
Extension(config): Extension<Arc<GlobalConfig>>,
) -> Result<impl IntoResponse, StatusCode> {
- check_access(&repository_name, &auth, &db_conn)?;
+ check_access(&repository_name, &auth, &mut db_conn)?;
let manifest_path = PathBuf::from(&config.registry_directory)
.join("manifests")
@@ -357,13 +357,13 @@ async fn get_manifest(
}
async fn put_manifest(
- db_conn: DatabaseConnection,
+ mut db_conn: DatabaseConnection,
auth: RegistryAuth,
Path((repository_name, reference)): Path<(String, String)>,
mut stream: BodyStream,
Extension(config): Extension<Arc<GlobalConfig>>,
) -> Result<impl IntoResponse, StatusCode> {
- let bot = check_access(&repository_name, &auth, &db_conn)?;
+ let bot = check_access(&repository_name, &auth, &mut db_conn)?;
let repository_dir = PathBuf::from(&config.registry_directory)
.join("manifests")
@@ -399,9 +399,9 @@ async fn put_manifest(
code_bundle_path: None,
container_digest: Some(&content_digest),
};
- let version =
- db::bots::create_bot_version(&new_version, &db_conn).expect("could not save bot version");
- db::bots::set_active_version(bot.id, Some(version.id), &db_conn)
+ let version = db::bots::create_bot_version(&new_version, &mut db_conn)
+ .expect("could not save bot version");
+ db::bots::set_active_version(bot.id, Some(version.id), &mut db_conn)
.expect("could not update bot version");
Ok(Response::builder()
@@ -421,7 +421,7 @@ async fn put_manifest(
fn check_access(
repository_name: &str,
auth: &RegistryAuth,
- db_conn: &DatabaseConnection,
+ db_conn: &mut DatabaseConnection,
) -> Result<db::bots::Bot, StatusCode> {
use diesel::OptionalExtension;