fix things up

This commit is contained in:
Alex Auvolat
2025-01-31 18:34:57 +01:00
parent 9fa20d45be
commit 84f1db91c4
34 changed files with 130 additions and 102 deletions
+3
View File
@@ -69,3 +69,6 @@ quick-xml.workspace = true
opentelemetry.workspace = true
opentelemetry-prometheus = { workspace = true, optional = true }
prometheus = { workspace = true, optional = true }
[features]
metrics = [ "opentelemetry-prometheus", "prometheus", "garage_api_common/metrics" ]
+1 -1
View File
@@ -21,6 +21,7 @@ use garage_util::error::Error as GarageError;
use garage_util::socket_address::UnixOrTCPSocketAddress;
use garage_api_common::generic_server::*;
use garage_api_common::helpers::*;
use crate::bucket::*;
use crate::cluster::*;
@@ -28,7 +29,6 @@ use crate::error::*;
use crate::key::*;
use crate::router_v0;
use crate::router_v1::{Authorization, Endpoint};
use garage_api_common::helpers::*;
pub type ResBody = BoxBody<Error>;
+3 -2
View File
@@ -17,11 +17,12 @@ use garage_model::permission::*;
use garage_model::s3::mpu_table;
use garage_model::s3::object_table::*;
use garage_api_common::common_error::CommonError;
use garage_api_common::helpers::*;
use crate::api_server::ResBody;
use crate::error::*;
use crate::key::ApiBucketKeyPerm;
use garage_api_common::common_error::CommonError;
use garage_api_common::helpers::*;
pub async fn handle_list_buckets(garage: &Arc<Garage>) -> Result<Response<ResBody>, Error> {
let buckets = garage
+2 -1
View File
@@ -12,9 +12,10 @@ use garage_rpc::layout;
use garage_model::garage::Garage;
use garage_api_common::helpers::{json_ok_response, parse_json_body};
use crate::api_server::ResBody;
use crate::error::*;
use garage_api_common::helpers::{json_ok_response, parse_json_body};
pub async fn handle_get_cluster_status(garage: &Arc<Garage>) -> Result<Response<ResBody>, Error> {
let layout = garage.system.cluster_layout();
+3 -12
View File
@@ -6,7 +6,7 @@ use hyper::{HeaderMap, StatusCode};
pub use garage_model::helper::error::Error as HelperError;
use garage_api_common::common_error::CommonError;
use garage_api_common::common_error::{commonErrorDerivative, CommonError};
pub use garage_api_common::common_error::{
CommonErrorDerivative, OkOrBadRequest, OkOrInternalError,
};
@@ -18,7 +18,7 @@ use garage_api_common::helpers::*;
pub enum Error {
#[error(display = "{}", _0)]
/// Error from common error
Common(CommonError),
Common(#[error(source)] CommonError),
// Category: cannot process
/// The API access key does not exist
@@ -33,14 +33,7 @@ pub enum Error {
KeyAlreadyExists(String),
}
impl<T> From<T> for Error
where
CommonError: From<T>,
{
fn from(err: T) -> Self {
Error::Common(CommonError::from(err))
}
}
commonErrorDerivative!(Error);
/// FIXME: helper errors are transformed into their corresponding variants
/// in the Error struct, but in many case a helper error should be considered
@@ -55,8 +48,6 @@ impl From<HelperError> for Error {
}
}
impl CommonErrorDerivative for Error {}
impl Error {
fn code(&self) -> &'static str {
match self {
+2 -1
View File
@@ -9,9 +9,10 @@ use garage_table::*;
use garage_model::garage::Garage;
use garage_model::key_table::*;
use garage_api_common::helpers::*;
use crate::api_server::ResBody;
use crate::error::*;
use garage_api_common::helpers::*;
pub async fn handle_list_keys(garage: &Arc<Garage>) -> Result<Response<ResBody>, Error> {
let res = garage
+2 -1
View File
@@ -2,9 +2,10 @@ use std::borrow::Cow;
use hyper::{Method, Request};
use crate::error::*;
use garage_api_common::router_macros::*;
use crate::error::*;
router_match! {@func
/// List of all Admin API endpoints.
+2 -1
View File
@@ -2,9 +2,10 @@ use std::borrow::Cow;
use hyper::{Method, Request};
use garage_api_common::router_macros::*;
use crate::error::*;
use crate::router_v0;
use garage_api_common::router_macros::*;
pub enum Authorization {
None,