mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-12 07:16:52 +00:00
Merge branch 'main' into next-v2
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
[package]
|
||||
name = "garage_api_admin"
|
||||
version = "1.0.1"
|
||||
authors = ["Alex Auvolat <alex@adnab.me>"]
|
||||
edition = "2018"
|
||||
license = "AGPL-3.0"
|
||||
description = "Admin API server crate for the Garage object store"
|
||||
repository = "https://git.deuxfleurs.fr/Deuxfleurs/garage"
|
||||
readme = "../../README.md"
|
||||
|
||||
[lib]
|
||||
path = "lib.rs"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
garage_model.workspace = true
|
||||
garage_table.workspace = true
|
||||
garage_util.workspace = true
|
||||
garage_rpc.workspace = true
|
||||
garage_api_common.workspace = true
|
||||
|
||||
argon2.workspace = true
|
||||
async-trait.workspace = true
|
||||
err-derive.workspace = true
|
||||
hex.workspace = true
|
||||
paste.workspace = true
|
||||
tracing.workspace = true
|
||||
|
||||
futures.workspace = true
|
||||
tokio.workspace = true
|
||||
http.workspace = true
|
||||
hyper = { workspace = true, default-features = false, features = ["server", "http1"] }
|
||||
url.workspace = true
|
||||
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
|
||||
opentelemetry.workspace = true
|
||||
opentelemetry-prometheus = { workspace = true, optional = true }
|
||||
prometheus = { workspace = true, optional = true }
|
||||
|
||||
[features]
|
||||
metrics = [ "opentelemetry-prometheus", "prometheus" ]
|
||||
@@ -8,10 +8,11 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use garage_model::garage::Garage;
|
||||
|
||||
use crate::admin::error::Error;
|
||||
use crate::admin::macros::*;
|
||||
use crate::admin::EndpointHandler;
|
||||
use crate::helpers::is_default;
|
||||
use garage_api_common::helpers::is_default;
|
||||
|
||||
use crate::error::Error;
|
||||
use crate::macros::*;
|
||||
use crate::EndpointHandler;
|
||||
|
||||
// This generates the following:
|
||||
//
|
||||
|
||||
@@ -19,15 +19,15 @@ use garage_model::garage::Garage;
|
||||
use garage_util::error::Error as GarageError;
|
||||
use garage_util::socket_address::UnixOrTCPSocketAddress;
|
||||
|
||||
use crate::generic_server::*;
|
||||
use garage_api_common::generic_server::*;
|
||||
use garage_api_common::helpers::*;
|
||||
|
||||
use crate::admin::api::*;
|
||||
use crate::admin::error::*;
|
||||
use crate::admin::router_v0;
|
||||
use crate::admin::router_v1;
|
||||
use crate::admin::Authorization;
|
||||
use crate::admin::EndpointHandler;
|
||||
use crate::helpers::*;
|
||||
use crate::api::*;
|
||||
use crate::error::*;
|
||||
use crate::router_v0;
|
||||
use crate::router_v1;
|
||||
use crate::Authorization;
|
||||
use crate::EndpointHandler;
|
||||
|
||||
pub type ResBody = BoxBody<Error>;
|
||||
|
||||
|
||||
@@ -16,10 +16,11 @@ use garage_model::permission::*;
|
||||
use garage_model::s3::mpu_table;
|
||||
use garage_model::s3::object_table::*;
|
||||
|
||||
use crate::admin::api::*;
|
||||
use crate::admin::error::*;
|
||||
use crate::admin::EndpointHandler;
|
||||
use crate::common_error::CommonError;
|
||||
use garage_api_common::common_error::CommonError;
|
||||
|
||||
use crate::api::*;
|
||||
use crate::error::*;
|
||||
use crate::EndpointHandler;
|
||||
|
||||
#[async_trait]
|
||||
impl EndpointHandler for ListBucketsRequest {
|
||||
|
||||
@@ -10,9 +10,9 @@ use garage_rpc::layout;
|
||||
|
||||
use garage_model::garage::Garage;
|
||||
|
||||
use crate::admin::api::*;
|
||||
use crate::admin::error::*;
|
||||
use crate::admin::EndpointHandler;
|
||||
use crate::api::*;
|
||||
use crate::error::*;
|
||||
use crate::EndpointHandler;
|
||||
|
||||
#[async_trait]
|
||||
impl EndpointHandler for GetClusterStatusRequest {
|
||||
|
||||
+8
-15
@@ -6,17 +6,19 @@ use hyper::{HeaderMap, StatusCode};
|
||||
|
||||
pub use garage_model::helper::error::Error as HelperError;
|
||||
|
||||
use crate::common_error::CommonError;
|
||||
pub use crate::common_error::{CommonErrorDerivative, OkOrBadRequest, OkOrInternalError};
|
||||
use crate::generic_server::ApiError;
|
||||
use crate::helpers::*;
|
||||
use garage_api_common::common_error::{commonErrorDerivative, CommonError};
|
||||
pub use garage_api_common::common_error::{
|
||||
CommonErrorDerivative, OkOrBadRequest, OkOrInternalError,
|
||||
};
|
||||
use garage_api_common::generic_server::ApiError;
|
||||
use garage_api_common::helpers::*;
|
||||
|
||||
/// Errors of this crate
|
||||
#[derive(Debug, Error)]
|
||||
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
|
||||
@@ -31,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
|
||||
@@ -53,8 +48,6 @@ impl From<HelperError> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl CommonErrorDerivative for Error {}
|
||||
|
||||
impl Error {
|
||||
pub fn code(&self) -> &'static str {
|
||||
match self {
|
||||
|
||||
@@ -8,9 +8,9 @@ use garage_table::*;
|
||||
use garage_model::garage::Garage;
|
||||
use garage_model::key_table::*;
|
||||
|
||||
use crate::admin::api::*;
|
||||
use crate::admin::error::*;
|
||||
use crate::admin::EndpointHandler;
|
||||
use crate::api::*;
|
||||
use crate::error::*;
|
||||
use crate::EndpointHandler;
|
||||
|
||||
#[async_trait]
|
||||
impl EndpointHandler for ListKeysRequest {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#[macro_use]
|
||||
extern crate tracing;
|
||||
|
||||
pub mod api_server;
|
||||
mod error;
|
||||
mod macros;
|
||||
@@ -2,8 +2,9 @@ use std::borrow::Cow;
|
||||
|
||||
use hyper::{Method, Request};
|
||||
|
||||
use crate::admin::error::*;
|
||||
use crate::router_macros::*;
|
||||
use garage_api_common::router_macros::*;
|
||||
|
||||
use crate::error::*;
|
||||
|
||||
router_match! {@func
|
||||
|
||||
|
||||
@@ -2,9 +2,10 @@ use std::borrow::Cow;
|
||||
|
||||
use hyper::{Method, Request};
|
||||
|
||||
use crate::admin::error::*;
|
||||
use crate::admin::router_v0;
|
||||
use crate::router_macros::*;
|
||||
use garage_api_common::router_macros::*;
|
||||
|
||||
use crate::error::*;
|
||||
use crate::router_v0;
|
||||
|
||||
router_match! {@func
|
||||
|
||||
|
||||
@@ -4,12 +4,13 @@ use hyper::body::Incoming as IncomingBody;
|
||||
use hyper::{Method, Request};
|
||||
use paste::paste;
|
||||
|
||||
use crate::admin::api::*;
|
||||
use crate::admin::error::*;
|
||||
use crate::admin::router_v1;
|
||||
use crate::admin::Authorization;
|
||||
use crate::helpers::*;
|
||||
use crate::router_macros::*;
|
||||
use garage_api_common::helpers::*;
|
||||
use garage_api_common::router_macros::*;
|
||||
|
||||
use crate::api::*;
|
||||
use crate::error::*;
|
||||
use crate::router_v1;
|
||||
use crate::Authorization;
|
||||
|
||||
impl AdminApiRequest {
|
||||
/// Determine which S3 endpoint a request is for using the request, and a bucket which was
|
||||
|
||||
@@ -10,11 +10,12 @@ use hyper::{Response, StatusCode};
|
||||
use garage_model::garage::Garage;
|
||||
use garage_rpc::system::ClusterHealthStatus;
|
||||
|
||||
use crate::admin::api::{CheckDomainRequest, HealthRequest, OptionsRequest};
|
||||
use crate::admin::api_server::ResBody;
|
||||
use crate::admin::error::*;
|
||||
use crate::admin::EndpointHandler;
|
||||
use crate::helpers::*;
|
||||
use garage_api_common::helpers::*;
|
||||
|
||||
use crate::api::{CheckDomainRequest, HealthRequest, OptionsRequest};
|
||||
use crate::api_server::ResBody;
|
||||
use crate::error::*;
|
||||
use crate::EndpointHandler;
|
||||
|
||||
#[async_trait]
|
||||
impl EndpointHandler for OptionsRequest {
|
||||
|
||||
Reference in New Issue
Block a user