admin api: expose routing rules, cors rules and lifecycle rules

This commit is contained in:
Alex Auvolat
2026-03-06 11:10:30 +01:00
committed by Alex
parent 6c0bb1c9b6
commit 64087172ff
10 changed files with 312 additions and 35 deletions
+10 -2
View File
@@ -12,7 +12,7 @@ use garage_rpc::*;
use garage_model::garage::Garage;
use garage_api_common::{common_error::CommonError, helpers::is_default};
use garage_api_common::{common_error::CommonError, helpers::is_default, xml};
use crate::api_server::{find_matching_nodes, AdminRpc, AdminRpcResponse};
use crate::error::Error;
@@ -857,9 +857,15 @@ pub struct GetBucketInfoResponse {
pub global_aliases: Vec<String>,
/// Whether website access is enabled for this bucket
pub website_access: bool,
#[serde(default)]
/// Website configuration for this bucket
pub website_config: Option<GetBucketInfoWebsiteResponse>,
// FIXME for v3: remove serde(default) for the two fields below
/// CORS rules for this bucket
#[serde(default)]
pub cors_rules: Option<Vec<xml::cors::CorsRule>>,
/// Object lifecycle rules for this bucket
#[serde(default)]
pub lifecycle_rules: Option<Vec<xml::lifecycle::LifecycleRule>>,
/// List of access keys that have permissions granted on this bucket
pub keys: Vec<GetBucketInfoKey>,
/// Number of objects in this bucket
@@ -883,6 +889,8 @@ pub struct GetBucketInfoResponse {
pub struct GetBucketInfoWebsiteResponse {
pub index_document: String,
pub error_document: Option<String>,
#[serde(default)]
pub routing_rules: Vec<xml::website::RoutingRule>,
}
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
+17
View File
@@ -18,6 +18,7 @@ use garage_model::s3::mpu_table;
use garage_model::s3::object_table::*;
use garage_api_common::common_error::CommonError;
use garage_api_common::xml;
use crate::api::*;
use crate::error::*;
@@ -693,8 +694,24 @@ async fn bucket_info_results(
GetBucketInfoWebsiteResponse {
index_document: wsc.index_document,
error_document: wsc.error_document,
routing_rules: wsc
.routing_rules
.into_iter()
.map(xml::website::RoutingRule::from_garage_routing_rule)
.collect::<Vec<_>>(),
}
}),
cors_rules: state.cors_config.get().as_ref().map(|rules| {
rules
.iter()
.map(xml::cors::CorsRule::from_garage_cors_rule)
.collect::<Vec<_>>()
}),
lifecycle_rules: state.lifecycle_config.get().as_ref().map(|lc| {
lc.iter()
.map(xml::lifecycle::LifecycleRule::from_garage_lifecycle_rule)
.collect::<Vec<_>>()
}),
keys: relevant_keys
.into_values()
.filter_map(|key| {