From ca58d7f0ec5105a515e26fb65ed33733b4a37948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Thu, 11 Jun 2026 17:04:50 +0800 Subject: [PATCH] refactor(config): migrate server config consumers (#3353) --- crates/audit/Cargo.toml | 2 +- crates/audit/README.md | 2 +- crates/audit/src/factory.rs | 2 +- crates/audit/src/global.rs | 2 +- crates/audit/src/registry.rs | 2 +- crates/audit/src/system.rs | 6 +- crates/audit/tests/config_parsing_test.rs | 2 +- crates/audit/tests/integration_test.rs | 2 +- crates/audit/tests/performance_test.rs | 10 +- crates/audit/tests/system_integration_test.rs | 2 +- crates/ecstore/src/config/audit.rs | 2 +- crates/ecstore/src/config/com.rs | 82 ++++++------- crates/ecstore/src/config/heal.rs | 2 +- crates/ecstore/src/config/notify.rs | 2 +- crates/ecstore/src/config/oidc.rs | 2 +- crates/ecstore/src/config/scanner.rs | 2 +- crates/ecstore/src/config/storageclass.rs | 3 +- crates/ecstore/src/store.rs | 7 +- crates/ecstore/src/store_init.rs | 3 +- crates/iam/Cargo.toml | 2 +- crates/iam/src/oidc.rs | 33 +++--- crates/notify/Cargo.toml | 2 +- crates/notify/examples/full_demo.rs | 2 +- crates/notify/examples/full_demo_one.rs | 2 +- crates/notify/src/config_manager.rs | 4 +- crates/notify/src/factory.rs | 2 +- crates/notify/src/global.rs | 2 +- crates/notify/src/integration.rs | 2 +- crates/notify/src/registry.rs | 2 +- crates/notify/src/services.rs | 4 +- crates/targets/Cargo.toml | 2 +- crates/targets/src/catalog/builtin.rs | 2 +- crates/targets/src/config/common.rs | 4 +- crates/targets/src/config/instance.rs | 4 +- crates/targets/src/config/loader.rs | 4 +- crates/targets/src/config/target_args.rs | 4 +- crates/targets/src/plugin.rs | 4 +- docs/architecture/migration-progress.md | 110 ++++++++++-------- rustfs/Cargo.toml | 2 +- rustfs/src/admin/handlers/audit.rs | 4 +- .../admin/handlers/audit_runtime_config.rs | 4 +- rustfs/src/admin/handlers/config_admin.rs | 3 +- rustfs/src/admin/handlers/event.rs | 4 +- .../admin/handlers/notify_runtime_access.rs | 4 +- rustfs/src/admin/handlers/oidc.rs | 7 +- .../src/admin/handlers/plugins_instances.rs | 4 +- rustfs/src/admin/handlers/site_replication.rs | 14 +-- .../src/admin/handlers/target_descriptor.rs | 6 +- rustfs/src/admin/router.rs | 59 +++++----- rustfs/src/admin/service/config.rs | 3 +- rustfs/src/app/context.rs | 3 +- rustfs/src/server/audit.rs | 4 +- rustfs/src/server/event.rs | 2 +- 53 files changed, 238 insertions(+), 213 deletions(-) diff --git a/crates/audit/Cargo.toml b/crates/audit/Cargo.toml index 9f3f05c38..8b27e25d7 100644 --- a/crates/audit/Cargo.toml +++ b/crates/audit/Cargo.toml @@ -27,7 +27,7 @@ categories = ["web-programming", "development-tools", "asynchronous", "api-bindi [dependencies] rustfs-targets = { workspace = true } -rustfs-config = { workspace = true, features = ["audit", "constants"] } +rustfs-config = { workspace = true, features = ["audit", "constants", "server-config-model"] } rustfs-ecstore = { workspace = true } rustfs-s3-types = { workspace = true } chrono = { workspace = true } diff --git a/crates/audit/README.md b/crates/audit/README.md index 57250eb66..075dd17dd 100644 --- a/crates/audit/README.md +++ b/crates/audit/README.md @@ -33,7 +33,7 @@ rustfs-audit = "0.1" ```rust use rustfs_audit::{start_audit_system, AuditLogger}; -use rustfs_ecstore::config::Config; +use rustfs_config::server_config::Config; #[tokio::main] async fn main() { diff --git a/crates/audit/src/factory.rs b/crates/audit/src/factory.rs index 83ae1ff7f..fe317dcc0 100644 --- a/crates/audit/src/factory.rs +++ b/crates/audit/src/factory.rs @@ -31,8 +31,8 @@ pub fn builtin_target_plugins() -> Vec> { mod tests { use super::builtin_target_descriptors; use rustfs_config::audit::AUDIT_AMQP_KEYS; + use rustfs_config::server_config::KVS; use rustfs_config::{AMQP_EXCHANGE, AMQP_QUEUE_DIR, AMQP_ROUTING_KEY, AMQP_URL}; - use rustfs_ecstore::config::KVS; use rustfs_targets::target::ChannelTargetType; fn amqp_base_config() -> KVS { diff --git a/crates/audit/src/global.rs b/crates/audit/src/global.rs index 2519e1174..56fdaa25c 100644 --- a/crates/audit/src/global.rs +++ b/crates/audit/src/global.rs @@ -13,7 +13,7 @@ // limitations under the License. use crate::{AuditEntry, AuditResult, AuditSystem, system::AuditTargetMetricSnapshot}; -use rustfs_ecstore::config::Config; +use rustfs_config::server_config::Config; use std::sync::{Arc, OnceLock}; use tracing::{debug, error, trace, warn}; diff --git a/crates/audit/src/registry.rs b/crates/audit/src/registry.rs index 2270c3194..d29442bff 100644 --- a/crates/audit/src/registry.rs +++ b/crates/audit/src/registry.rs @@ -14,7 +14,7 @@ use crate::{AuditEntry, AuditError, AuditResult, factory::builtin_target_plugins}; use rustfs_config::audit::AUDIT_ROUTE_PREFIX; -use rustfs_ecstore::config::{Config, KVS}; +use rustfs_config::server_config::{Config, KVS}; use rustfs_targets::arn::TargetID; use rustfs_targets::{SharedTarget, Target, TargetError, TargetPluginRegistry, TargetRuntimeManager}; use tracing::info; diff --git a/crates/audit/src/system.rs b/crates/audit/src/system.rs index 87bb50fc7..6c14c9c5b 100644 --- a/crates/audit/src/system.rs +++ b/crates/audit/src/system.rs @@ -16,7 +16,7 @@ use crate::{ AuditEntry, AuditError, AuditRegistry, AuditResult, observability, pipeline::{AuditPipeline, AuditRuntimeFacade, AuditRuntimeView}, }; -use rustfs_ecstore::config::Config; +use rustfs_config::server_config::Config; use rustfs_targets::{ReplayWorkerManager, Target}; use std::sync::Arc; use tokio::sync::{Mutex, RwLock}; @@ -537,7 +537,7 @@ mod tests { } system - .reload_config(rustfs_ecstore::config::Config(HashMap::new())) + .reload_config(rustfs_config::server_config::Config(HashMap::new())) .await .expect("reload with empty config should succeed"); @@ -545,6 +545,6 @@ mod tests { assert!(system.list_targets().await.is_empty()); assert_eq!(system.runtime_status_snapshot().await, ReplayWorkerManager::new().snapshot(0)); assert_eq!(close_calls.load(Ordering::SeqCst), 1); - assert_eq!(*system.config.read().await, Some(rustfs_ecstore::config::Config(HashMap::new()))); + assert_eq!(*system.config.read().await, Some(rustfs_config::server_config::Config(HashMap::new()))); } } diff --git a/crates/audit/tests/config_parsing_test.rs b/crates/audit/tests/config_parsing_test.rs index 74869efa2..d83a32653 100644 --- a/crates/audit/tests/config_parsing_test.rs +++ b/crates/audit/tests/config_parsing_test.rs @@ -14,7 +14,7 @@ //! Tests for audit configuration parsing and validation -use rustfs_ecstore::config::KVS; +use rustfs_config::server_config::KVS; #[test] fn test_webhook_valid_fields() { diff --git a/crates/audit/tests/integration_test.rs b/crates/audit/tests/integration_test.rs index 08f5f51e2..a1a530634 100644 --- a/crates/audit/tests/integration_test.rs +++ b/crates/audit/tests/integration_test.rs @@ -13,7 +13,7 @@ // limitations under the License. use rustfs_audit::*; -use rustfs_ecstore::config::{Config, KVS}; +use rustfs_config::server_config::{Config, KVS}; use std::collections::HashMap; use temp_env::with_vars; diff --git a/crates/audit/tests/performance_test.rs b/crates/audit/tests/performance_test.rs index 47780abc9..23a878214 100644 --- a/crates/audit/tests/performance_test.rs +++ b/crates/audit/tests/performance_test.rs @@ -26,7 +26,7 @@ async fn test_audit_system_startup_performance() { let start = Instant::now(); // Create minimal config for testing - let config = rustfs_ecstore::config::Config(std::collections::HashMap::new()); + let config = rustfs_config::server_config::Config(std::collections::HashMap::new()); // System should start quickly even with empty config let _result = timeout(Duration::from_secs(5), system.start(config)).await; @@ -47,12 +47,12 @@ async fn test_concurrent_target_creation() { let registry = AuditRegistry::new(); // Create config with multiple webhook instances - let mut config = rustfs_ecstore::config::Config(std::collections::HashMap::new()); + let mut config = rustfs_config::server_config::Config(std::collections::HashMap::new()); let mut webhook_section = std::collections::HashMap::new(); // Create multiple instances for concurrent creation test for i in 1..=5 { - let mut kvs = rustfs_ecstore::config::KVS::new(); + let mut kvs = rustfs_config::server_config::KVS::new(); kvs.insert("enable".to_string(), "on".to_string()); kvs.insert("endpoint".to_string(), format!("http://localhost:302{i}/webhook")); webhook_section.insert(format!("instance_{i}"), kvs); @@ -90,7 +90,7 @@ async fn test_audit_log_dispatch_performance() { let system = AuditSystem::new(); // Create minimal config - let config = rustfs_ecstore::config::Config(HashMap::new()); + let config = rustfs_config::server_config::Config(HashMap::new()); let start_result = system.start(config).await; if start_result.is_err() { println!("AuditSystem failed to start: {start_result:?}"); @@ -186,7 +186,7 @@ async fn test_system_state_transitions() { assert_eq!(system.get_state().await, rustfs_audit::system::AuditSystemState::Stopped); // Start system - let config = rustfs_ecstore::config::Config(std::collections::HashMap::new()); + let config = rustfs_config::server_config::Config(std::collections::HashMap::new()); let start_result = system.start(config).await; // Empty config keeps the audit system stopped even when start() succeeds. diff --git a/crates/audit/tests/system_integration_test.rs b/crates/audit/tests/system_integration_test.rs index d108227e0..b619a2428 100644 --- a/crates/audit/tests/system_integration_test.rs +++ b/crates/audit/tests/system_integration_test.rs @@ -15,7 +15,7 @@ //! Comprehensive integration tests for the complete audit system use rustfs_audit::*; -use rustfs_ecstore::config::{Config, KVS}; +use rustfs_config::server_config::{Config, KVS}; use std::collections::HashMap; use std::sync::Arc; use std::time::Duration; diff --git a/crates/ecstore/src/config/audit.rs b/crates/ecstore/src/config/audit.rs index 62d9804ef..3bb4ee545 100644 --- a/crates/ecstore/src/config/audit.rs +++ b/crates/ecstore/src/config/audit.rs @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::config::{KV, KVS}; use rustfs_config::audit::AUDIT_REDIS_DEFAULT_CHANNEL; +use rustfs_config::server_config::{KV, KVS}; use rustfs_config::{ AMQP_EXCHANGE, AMQP_MANDATORY, AMQP_PASSWORD, AMQP_PERSISTENT, AMQP_QUEUE_DIR, AMQP_QUEUE_LIMIT, AMQP_ROUTING_KEY, AMQP_TLS_CA, AMQP_TLS_CLIENT_CERT, AMQP_TLS_CLIENT_KEY, AMQP_URL, AMQP_USERNAME, COMMENT_KEY, DEFAULT_LIMIT, ENABLE_KEY, diff --git a/crates/ecstore/src/config/com.rs b/crates/ecstore/src/config/com.rs index b8061c521..d0a6e2d4a 100644 --- a/crates/ecstore/src/config/com.rs +++ b/crates/ecstore/src/config/com.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::config::{Config, KVS, audit, notify, oidc, set_global_storage_class, storageclass}; +use crate::config::{audit, notify, oidc, set_global_storage_class, storageclass}; use crate::disk::{MIGRATING_META_BUCKET, RUSTFS_META_BUCKET}; use crate::error::{Error, Result}; use crate::global::is_first_cluster_node_local; @@ -30,6 +30,7 @@ use rustfs_config::notify::{ NOTIFY_WEBHOOK_KEYS, NOTIFY_WEBHOOK_SUB_SYS, }; use rustfs_config::oidc::{IDENTITY_OPENID_KEYS, IDENTITY_OPENID_SUB_SYS, OIDC_REDIRECT_URI_DYNAMIC}; +use rustfs_config::server_config::{Config, KVS}; use rustfs_config::{COMMENT_KEY, DEFAULT_DELIMITER, ENABLE_KEY, EnableState, RUSTFS_REGION}; use rustfs_storage_api::StorageAdminApi; use rustfs_utils::path::SLASH_SEPARATOR; @@ -293,7 +294,7 @@ fn get_config_file() -> String { format!("{CONFIG_PREFIX}{SLASH_SEPARATOR}{CONFIG_FILE}") } -fn storage_class_kvs_mut(cfg: &mut Config) -> &mut crate::config::KVS { +fn storage_class_kvs_mut(cfg: &mut Config) -> &mut KVS { let sub_cfg = cfg.0.entry(STORAGE_CLASS_SUB_SYS.to_string()).or_insert_with(|| { let mut section = HashMap::new(); section.insert(DEFAULT_DELIMITER.to_string(), storageclass::DEFAULT_KVS.clone()); @@ -1210,7 +1211,7 @@ mod tests { configs_semantically_equal, decode_server_config_blob, encode_server_config_blob, is_standard_object_server_config, read_config_with_metadata, storage_class_kvs_mut, }; - use crate::config::{Config, audit, notify, oidc}; + use crate::config::{audit, notify, oidc}; use crate::disk::endpoint::Endpoint; use crate::endpoints::SetupType; use crate::error::{Error, Result}; @@ -1228,6 +1229,7 @@ mod tests { NOTIFY_AMQP_SUB_SYS, NOTIFY_KAFKA_SUB_SYS, NOTIFY_MQTT_SUB_SYS, NOTIFY_MYSQL_SUB_SYS, NOTIFY_WEBHOOK_SUB_SYS, }; use rustfs_config::oidc::IDENTITY_OPENID_SUB_SYS; + use rustfs_config::server_config::{Config, KV, KVS}; use rustfs_config::{ DEFAULT_DELIMITER, ENABLE_KEY, EnableState, MYSQL_DSN_STRING, MYSQL_MAX_OPEN_CONNECTIONS, MYSQL_QUEUE_DIR, MYSQL_TABLE, }; @@ -2152,18 +2154,18 @@ mod tests { webhook_section.insert(DEFAULT_DELIMITER.to_string(), notify::DEFAULT_NOTIFY_WEBHOOK_KVS.clone()); webhook_section.insert( "primary".to_string(), - crate::config::KVS(vec![ - crate::config::KV { + KVS(vec![ + KV { key: ENABLE_KEY.to_string(), value: EnableState::On.to_string(), hidden_if_empty: false, }, - crate::config::KV { + KV { key: rustfs_config::WEBHOOK_ENDPOINT.to_string(), value: "https://example.com/hook".to_string(), hidden_if_empty: false, }, - crate::config::KV { + KV { key: rustfs_config::WEBHOOK_QUEUE_DIR.to_string(), value: "/tmp/webhook-queue".to_string(), hidden_if_empty: false, @@ -2179,18 +2181,18 @@ mod tests { mqtt_section.insert(DEFAULT_DELIMITER.to_string(), mqtt_default); mqtt_section.insert( "analytics".to_string(), - crate::config::KVS(vec![ - crate::config::KV { + KVS(vec![ + KV { key: ENABLE_KEY.to_string(), value: EnableState::On.to_string(), hidden_if_empty: false, }, - crate::config::KV { + KV { key: rustfs_config::MQTT_BROKER.to_string(), value: "tcp://127.0.0.1:1883".to_string(), hidden_if_empty: false, }, - crate::config::KV { + KV { key: rustfs_config::MQTT_QUEUE_DIR.to_string(), value: "".to_string(), hidden_if_empty: false, @@ -2206,23 +2208,23 @@ mod tests { kafka_section.insert(DEFAULT_DELIMITER.to_string(), kafka_default); kafka_section.insert( "streaming".to_string(), - crate::config::KVS(vec![ - crate::config::KV { + KVS(vec![ + KV { key: ENABLE_KEY.to_string(), value: EnableState::On.to_string(), hidden_if_empty: false, }, - crate::config::KV { + KV { key: rustfs_config::KAFKA_BROKERS.to_string(), value: "127.0.0.1:9092,127.0.0.1:9093".to_string(), hidden_if_empty: false, }, - crate::config::KV { + KV { key: rustfs_config::KAFKA_ACKS.to_string(), value: "all".to_string(), hidden_if_empty: false, }, - crate::config::KV { + KV { key: rustfs_config::KAFKA_TLS_ENABLE.to_string(), value: EnableState::On.to_string(), hidden_if_empty: false, @@ -2234,33 +2236,33 @@ mod tests { let mut amqp_section = std::collections::HashMap::new(); amqp_section.insert( "primary".to_string(), - crate::config::KVS(vec![ - crate::config::KV { + KVS(vec![ + KV { key: ENABLE_KEY.to_string(), value: EnableState::On.to_string(), hidden_if_empty: false, }, - crate::config::KV { + KV { key: rustfs_config::AMQP_URL.to_string(), value: "amqp://127.0.0.1:5672/%2f".to_string(), hidden_if_empty: false, }, - crate::config::KV { + KV { key: rustfs_config::AMQP_EXCHANGE.to_string(), value: "rustfs.events".to_string(), hidden_if_empty: false, }, - crate::config::KV { + KV { key: rustfs_config::AMQP_ROUTING_KEY.to_string(), value: "objects".to_string(), hidden_if_empty: false, }, - crate::config::KV { + KV { key: rustfs_config::AMQP_MANDATORY.to_string(), value: "false".to_string(), hidden_if_empty: false, }, - crate::config::KV { + KV { key: rustfs_config::AMQP_PERSISTENT.to_string(), value: "false".to_string(), hidden_if_empty: false, @@ -2341,18 +2343,18 @@ mod tests { webhook_section.insert(DEFAULT_DELIMITER.to_string(), audit::DEFAULT_AUDIT_WEBHOOK_KVS.clone()); webhook_section.insert( "primary".to_string(), - crate::config::KVS(vec![ - crate::config::KV { + KVS(vec![ + KV { key: ENABLE_KEY.to_string(), value: EnableState::On.to_string(), hidden_if_empty: false, }, - crate::config::KV { + KV { key: rustfs_config::WEBHOOK_ENDPOINT.to_string(), value: "https://example.com/audit-hook".to_string(), hidden_if_empty: false, }, - crate::config::KV { + KV { key: rustfs_config::WEBHOOK_QUEUE_DIR.to_string(), value: "/tmp/audit-queue".to_string(), hidden_if_empty: false, @@ -2364,33 +2366,33 @@ mod tests { let mut amqp_section = std::collections::HashMap::new(); amqp_section.insert( "primary".to_string(), - crate::config::KVS(vec![ - crate::config::KV { + KVS(vec![ + KV { key: ENABLE_KEY.to_string(), value: EnableState::On.to_string(), hidden_if_empty: false, }, - crate::config::KV { + KV { key: rustfs_config::AMQP_URL.to_string(), value: "amqp://127.0.0.1:5672/%2f".to_string(), hidden_if_empty: false, }, - crate::config::KV { + KV { key: rustfs_config::AMQP_EXCHANGE.to_string(), value: "rustfs.audit".to_string(), hidden_if_empty: false, }, - crate::config::KV { + KV { key: rustfs_config::AMQP_ROUTING_KEY.to_string(), value: "audit".to_string(), hidden_if_empty: false, }, - crate::config::KV { + KV { key: rustfs_config::AMQP_MANDATORY.to_string(), value: "false".to_string(), hidden_if_empty: false, }, - crate::config::KV { + KV { key: rustfs_config::AMQP_PERSISTENT.to_string(), value: "false".to_string(), hidden_if_empty: false, @@ -2406,13 +2408,13 @@ mod tests { mqtt_section.insert(DEFAULT_DELIMITER.to_string(), mqtt_default); mqtt_section.insert( "analytics".to_string(), - crate::config::KVS(vec![ - crate::config::KV { + KVS(vec![ + KV { key: ENABLE_KEY.to_string(), value: EnableState::On.to_string(), hidden_if_empty: false, }, - crate::config::KV { + KV { key: rustfs_config::MQTT_BROKER.to_string(), value: "tcp://127.0.0.1:1883".to_string(), hidden_if_empty: false, @@ -2428,13 +2430,13 @@ mod tests { kafka_section.insert(DEFAULT_DELIMITER.to_string(), kafka_default); kafka_section.insert( "auditlog".to_string(), - crate::config::KVS(vec![ - crate::config::KV { + KVS(vec![ + KV { key: ENABLE_KEY.to_string(), value: EnableState::On.to_string(), hidden_if_empty: false, }, - crate::config::KV { + KV { key: rustfs_config::KAFKA_BROKERS.to_string(), value: "127.0.0.1:9092".to_string(), hidden_if_empty: false, diff --git a/crates/ecstore/src/config/heal.rs b/crates/ecstore/src/config/heal.rs index 9502cef0d..4505d3ce0 100644 --- a/crates/ecstore/src/config/heal.rs +++ b/crates/ecstore/src/config/heal.rs @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::config::{KV, KVS}; use crate::error::{Error, Result}; +use rustfs_config::server_config::{KV, KVS}; use rustfs_config::{DEFAULT_HEAL_BITROT_CYCLE_SECS, HEAL_BITROT_CYCLE}; use rustfs_utils::string::parse_bool; use std::sync::LazyLock; diff --git a/crates/ecstore/src/config/notify.rs b/crates/ecstore/src/config/notify.rs index 93ca49f56..a7130becd 100644 --- a/crates/ecstore/src/config/notify.rs +++ b/crates/ecstore/src/config/notify.rs @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::config::{KV, KVS}; use rustfs_config::notify::NOTIFY_REDIS_DEFAULT_CHANNEL; +use rustfs_config::server_config::{KV, KVS}; use rustfs_config::{ AMQP_EXCHANGE, AMQP_MANDATORY, AMQP_PASSWORD, AMQP_PERSISTENT, AMQP_QUEUE_DIR, AMQP_QUEUE_LIMIT, AMQP_ROUTING_KEY, AMQP_TLS_CA, AMQP_TLS_CLIENT_CERT, AMQP_TLS_CLIENT_KEY, AMQP_URL, AMQP_USERNAME, COMMENT_KEY, DEFAULT_LIMIT, ENABLE_KEY, diff --git a/crates/ecstore/src/config/oidc.rs b/crates/ecstore/src/config/oidc.rs index 65325dbea..bcf8e6125 100644 --- a/crates/ecstore/src/config/oidc.rs +++ b/crates/ecstore/src/config/oidc.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::config::{KV, KVS}; +use rustfs_config::server_config::{KV, KVS}; use rustfs_config::{ ENABLE_KEY, EnableState, oidc::{ diff --git a/crates/ecstore/src/config/scanner.rs b/crates/ecstore/src/config/scanner.rs index a2037d2ea..140f7c186 100644 --- a/crates/ecstore/src/config/scanner.rs +++ b/crates/ecstore/src/config/scanner.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::config::{KV, KVS}; +use rustfs_config::server_config::{KV, KVS}; use rustfs_config::{ DEFAULT_SCANNER_BITROT_CYCLE_SECS, DEFAULT_SCANNER_CACHE_SAVE_TIMEOUT_SECS, DEFAULT_SCANNER_CYCLE_MAX_DIRECTORIES, DEFAULT_SCANNER_CYCLE_MAX_DURATION_SECS, DEFAULT_SCANNER_CYCLE_MAX_OBJECTS, DEFAULT_SCANNER_IDLE_MODE, diff --git a/crates/ecstore/src/config/storageclass.rs b/crates/ecstore/src/config/storageclass.rs index faeb2ea09..1016d785f 100644 --- a/crates/ecstore/src/config/storageclass.rs +++ b/crates/ecstore/src/config/storageclass.rs @@ -12,9 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -use super::KVS; -use crate::config::KV; use crate::error::{Error, Result}; +use rustfs_config::server_config::{KV, KVS}; use serde::{Deserialize, Serialize}; use std::env; use std::sync::LazyLock; diff --git a/crates/ecstore/src/store.rs b/crates/ecstore/src/store.rs index cafa2ce18..f1cb4ba71 100644 --- a/crates/ecstore/src/store.rs +++ b/crates/ecstore/src/store.rs @@ -77,6 +77,7 @@ use lazy_static::lazy_static; use rand::RngExt as _; use rustfs_common::heal_channel::{HealItemType, HealOpts}; use rustfs_common::{GLOBAL_LOCAL_NODE_NAME, GLOBAL_RUSTFS_ADDR, GLOBAL_RUSTFS_HOST, GLOBAL_RUSTFS_PORT}; +use rustfs_config::server_config::Config; use rustfs_filemeta::FileInfo; use rustfs_lock::{LocalClient, LockClient, NamespaceLockWrapper}; use rustfs_madmin::heal_commands::HealResultItem; @@ -214,12 +215,12 @@ impl std::fmt::Debug for ECStore { /// remain the single source of truth until the migration is complete. impl ECStore { /// Get server configuration (delegates to global) - pub fn get_server_config(&self) -> Option { + pub fn get_server_config(&self) -> Option { crate::config::get_global_server_config() } /// Set server configuration (delegates to global) - pub fn set_server_config(&self, cfg: crate::config::Config) { + pub fn set_server_config(&self, cfg: Config) { crate::config::set_global_server_config(cfg); } @@ -264,7 +265,7 @@ impl ECStore { } /// Get the server configuration - pub fn server_config(&self) -> Option { + pub fn server_config(&self) -> Option { get_global_server_config() } diff --git a/crates/ecstore/src/store_init.rs b/crates/ecstore/src/store_init.rs index 6d49ec858..6b7969c4a 100644 --- a/crates/ecstore/src/store_init.rs +++ b/crates/ecstore/src/store_init.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::config::{KVS, storageclass}; +use crate::config::storageclass; use crate::disk::error_reduce::{count_errs, reduce_write_quorum_errs}; use crate::disk::{self, DiskAPI}; use crate::error::{Error, Result}; @@ -26,6 +26,7 @@ use crate::{ endpoints::Endpoints, }; use futures::future::join_all; +use rustfs_config::server_config::KVS; use std::collections::{HashMap, hash_map::Entry}; use tracing::{debug, info, warn}; use uuid::Uuid; diff --git a/crates/iam/Cargo.toml b/crates/iam/Cargo.toml index 0c106d84e..5a9831448 100644 --- a/crates/iam/Cargo.toml +++ b/crates/iam/Cargo.toml @@ -30,7 +30,7 @@ workspace = true [dependencies] rustfs-credentials = { workspace = true } -rustfs-config = { workspace = true, features = ["constants"] } +rustfs-config = { workspace = true, features = ["constants", "server-config-model"] } tokio.workspace = true time = { workspace = true, features = ["serde-human-readable"] } serde = { workspace = true, features = ["derive", "rc"] } diff --git a/crates/iam/src/oidc.rs b/crates/iam/src/oidc.rs index 51ec120d2..5192a4198 100644 --- a/crates/iam/src/oidc.rs +++ b/crates/iam/src/oidc.rs @@ -26,8 +26,9 @@ use openidconnect::{ }; use reqwest::Client; use rustfs_config::oidc::*; +use rustfs_config::server_config::{Config as ServerConfig, KVS}; use rustfs_config::{DEFAULT_DELIMITER, ENABLE_KEY, EnableState}; -use rustfs_ecstore::config::{Config as ServerConfig, KVS, get_global_server_config}; +use rustfs_ecstore::config::get_global_server_config; use rustfs_policy::policy::{ClaimLookup, get_claim_case_insensitive}; use serde::{Deserialize, Serialize}; use std::borrow::Cow; @@ -1867,17 +1868,17 @@ mod tests { fn test_parse_persisted_provider_config() { let mut cfg = ServerConfig::new(); let mut kvs = KVS(vec![ - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: ENABLE_KEY.to_string(), value: EnableState::Off.to_string(), hidden_if_empty: false, }, - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: OIDC_CONFIG_URL.to_string(), value: String::new(), hidden_if_empty: false, }, - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: OIDC_CLIENT_ID.to_string(), value: String::new(), hidden_if_empty: false, @@ -1908,17 +1909,17 @@ mod tests { fn test_parse_persisted_provider_config_omitted_roles_claim_is_empty() { let mut cfg = ServerConfig::new(); let mut kvs = KVS(vec![ - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: ENABLE_KEY.to_string(), value: EnableState::Off.to_string(), hidden_if_empty: false, }, - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: OIDC_CONFIG_URL.to_string(), value: String::new(), hidden_if_empty: false, }, - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: OIDC_CLIENT_ID.to_string(), value: String::new(), hidden_if_empty: false, @@ -2125,17 +2126,17 @@ mod tests { fn test_parse_persisted_hide_from_ui_off_is_false() { let mut cfg = ServerConfig::new(); let mut kvs = KVS(vec![ - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: ENABLE_KEY.to_string(), value: EnableState::On.to_string(), hidden_if_empty: false, }, - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: OIDC_CONFIG_URL.to_string(), value: "https://example.com/.well-known/openid-configuration".to_string(), hidden_if_empty: false, }, - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: OIDC_CLIENT_ID.to_string(), value: "console".to_string(), hidden_if_empty: false, @@ -2157,17 +2158,17 @@ mod tests { fn test_parse_persisted_hide_from_ui_missing_defaults_false() { let mut cfg = ServerConfig::new(); let kvs = KVS(vec![ - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: ENABLE_KEY.to_string(), value: EnableState::On.to_string(), hidden_if_empty: false, }, - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: OIDC_CONFIG_URL.to_string(), value: "https://example.com/.well-known/openid-configuration".to_string(), hidden_if_empty: false, }, - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: OIDC_CLIENT_ID.to_string(), value: "console".to_string(), hidden_if_empty: false, @@ -2188,17 +2189,17 @@ mod tests { fn test_parse_persisted_hide_from_ui() { let mut cfg = ServerConfig::new(); let mut kvs = KVS(vec![ - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: ENABLE_KEY.to_string(), value: EnableState::On.to_string(), hidden_if_empty: false, }, - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: OIDC_CONFIG_URL.to_string(), value: "https://example.com/.well-known/openid-configuration".to_string(), hidden_if_empty: false, }, - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: OIDC_CLIENT_ID.to_string(), value: "console".to_string(), hidden_if_empty: false, diff --git a/crates/notify/Cargo.toml b/crates/notify/Cargo.toml index aa54cea2e..2ae40cf84 100644 --- a/crates/notify/Cargo.toml +++ b/crates/notify/Cargo.toml @@ -26,7 +26,7 @@ categories = ["web-programming", "development-tools", "filesystem"] documentation = "https://docs.rs/rustfs-notify/latest/rustfs_notify/" [dependencies] -rustfs-config = { workspace = true, features = ["notify", "constants"] } +rustfs-config = { workspace = true, features = ["notify", "constants", "server-config-model"] } rustfs-ecstore = { workspace = true } rustfs-s3-types = { workspace = true } rustfs-s3-ops = { workspace = true } diff --git a/crates/notify/examples/full_demo.rs b/crates/notify/examples/full_demo.rs index facda2737..da5957213 100644 --- a/crates/notify/examples/full_demo.rs +++ b/crates/notify/examples/full_demo.rs @@ -17,11 +17,11 @@ mod base; use base::{LogLevel, init_logger}; use rustfs_config::EnableState::On; use rustfs_config::notify::{DEFAULT_TARGET, NOTIFY_MQTT_SUB_SYS, NOTIFY_WEBHOOK_SUB_SYS}; +use rustfs_config::server_config::{Config, KV, KVS}; use rustfs_config::{ DEFAULT_LIMIT, ENABLE_KEY, MQTT_BROKER, MQTT_PASSWORD, MQTT_QOS, MQTT_QUEUE_DIR, MQTT_QUEUE_LIMIT, MQTT_TOPIC, MQTT_USERNAME, WEBHOOK_AUTH_TOKEN, WEBHOOK_ENDPOINT, WEBHOOK_QUEUE_DIR, WEBHOOK_QUEUE_LIMIT, }; -use rustfs_ecstore::config::{Config, KV, KVS}; use rustfs_notify::{BucketNotificationConfig, Event, NotificationError}; use rustfs_notify::{initialize, notification_system}; use rustfs_s3_types::EventName; diff --git a/crates/notify/examples/full_demo_one.rs b/crates/notify/examples/full_demo_one.rs index afd4578a8..adf5bd60d 100644 --- a/crates/notify/examples/full_demo_one.rs +++ b/crates/notify/examples/full_demo_one.rs @@ -17,11 +17,11 @@ mod base; use base::{LogLevel, init_logger}; use rustfs_config::EnableState::On; use rustfs_config::notify::{DEFAULT_TARGET, NOTIFY_MQTT_SUB_SYS, NOTIFY_WEBHOOK_SUB_SYS}; +use rustfs_config::server_config::{Config, KV, KVS}; use rustfs_config::{ DEFAULT_LIMIT, ENABLE_KEY, MQTT_BROKER, MQTT_PASSWORD, MQTT_QOS, MQTT_QUEUE_DIR, MQTT_QUEUE_LIMIT, MQTT_TOPIC, MQTT_USERNAME, WEBHOOK_AUTH_TOKEN, WEBHOOK_ENDPOINT, WEBHOOK_QUEUE_DIR, WEBHOOK_QUEUE_LIMIT, }; -use rustfs_ecstore::config::{Config, KV, KVS}; use rustfs_notify::{BucketNotificationConfig, Event, NotificationError}; use rustfs_notify::{initialize, notification_system}; use rustfs_s3_types::EventName; diff --git a/crates/notify/src/config_manager.rs b/crates/notify/src/config_manager.rs index 956b77ee7..db7e54259 100644 --- a/crates/notify/src/config_manager.rs +++ b/crates/notify/src/config_manager.rs @@ -19,7 +19,7 @@ use rustfs_config::notify::{ NOTIFY_AMQP_SUB_SYS, NOTIFY_KAFKA_SUB_SYS, NOTIFY_MQTT_SUB_SYS, NOTIFY_MYSQL_SUB_SYS, NOTIFY_NATS_SUB_SYS, NOTIFY_POSTGRES_SUB_SYS, NOTIFY_PULSAR_SUB_SYS, NOTIFY_REDIS_SUB_SYS, NOTIFY_WEBHOOK_SUB_SYS, }; -use rustfs_ecstore::config::{Config, KVS}; +use rustfs_config::server_config::{Config, KVS}; use rustfs_targets::{Target, arn::TargetID}; use std::sync::Arc; use tokio::sync::RwLock; @@ -243,7 +243,7 @@ mod tests { NOTIFY_AMQP_SUB_SYS, NOTIFY_KAFKA_SUB_SYS, NOTIFY_MQTT_SUB_SYS, NOTIFY_NATS_SUB_SYS, NOTIFY_POSTGRES_SUB_SYS, NOTIFY_PULSAR_SUB_SYS, NOTIFY_REDIS_SUB_SYS, NOTIFY_WEBHOOK_SUB_SYS, }; - use rustfs_ecstore::config::Config; + use rustfs_config::server_config::Config; use rustfs_targets::ReplayWorkerManager; use std::sync::Arc; use tokio::sync::{RwLock, Semaphore}; diff --git a/crates/notify/src/factory.rs b/crates/notify/src/factory.rs index 08998b334..161c6ead6 100644 --- a/crates/notify/src/factory.rs +++ b/crates/notify/src/factory.rs @@ -31,8 +31,8 @@ pub fn builtin_target_plugins() -> Vec> { mod tests { use super::builtin_target_descriptors; use rustfs_config::notify::NOTIFY_AMQP_KEYS; + use rustfs_config::server_config::KVS; use rustfs_config::{AMQP_EXCHANGE, AMQP_QUEUE_DIR, AMQP_ROUTING_KEY, AMQP_URL}; - use rustfs_ecstore::config::KVS; use rustfs_targets::target::ChannelTargetType; fn amqp_base_config() -> KVS { diff --git a/crates/notify/src/global.rs b/crates/notify/src/global.rs index 0d61ee591..059917fe7 100644 --- a/crates/notify/src/global.rs +++ b/crates/notify/src/global.rs @@ -16,7 +16,7 @@ use crate::{ BucketNotificationConfig, Event, EventArgs, LifecycleError, NotificationError, NotificationMetricSnapshot, NotificationSystem, NotificationTargetMetricSnapshot, }; -use rustfs_ecstore::config::Config; +use rustfs_config::server_config::Config; use rustfs_s3_types::EventName; use rustfs_targets::arn::TargetID; use std::sync::{Arc, OnceLock}; diff --git a/crates/notify/src/integration.rs b/crates/notify/src/integration.rs index 70da7f8ea..35eb90cca 100644 --- a/crates/notify/src/integration.rs +++ b/crates/notify/src/integration.rs @@ -22,7 +22,7 @@ use crate::{ use hashbrown::HashMap; use metrics::{counter, gauge}; use rustfs_config::notify::{DEFAULT_NOTIFY_TARGET_STREAM_CONCURRENCY, ENV_NOTIFY_TARGET_STREAM_CONCURRENCY}; -use rustfs_ecstore::config::{Config, KVS}; +use rustfs_config::server_config::{Config, KVS}; use rustfs_s3_types::EventName; use rustfs_targets::arn::TargetID; use rustfs_targets::{ReplayWorkerManager, RuntimeTargetHealthSnapshot, SharedTarget}; diff --git a/crates/notify/src/registry.rs b/crates/notify/src/registry.rs index 3ee881d09..d5e22638e 100644 --- a/crates/notify/src/registry.rs +++ b/crates/notify/src/registry.rs @@ -15,7 +15,7 @@ use crate::Event; use crate::factory::builtin_target_plugins; use rustfs_config::notify::NOTIFY_ROUTE_PREFIX; -use rustfs_ecstore::config::{Config, KVS}; +use rustfs_config::server_config::{Config, KVS}; use rustfs_targets::{Target, TargetError, TargetPluginRegistry}; /// Registry for managing target factories diff --git a/crates/notify/src/services.rs b/crates/notify/src/services.rs index 49a7114c8..4ac1450dc 100644 --- a/crates/notify/src/services.rs +++ b/crates/notify/src/services.rs @@ -26,7 +26,7 @@ use crate::{ runtime_view::NotifyRuntimeView, status_view::NotifyStatusView, }; -use rustfs_ecstore::config::Config; +use rustfs_config::server_config::Config; use rustfs_targets::ReplayWorkerManager; use std::sync::Arc; use tokio::sync::{RwLock, Semaphore, broadcast}; @@ -81,7 +81,7 @@ mod tests { integration::NotificationMetrics, notification_system_subscriber::NotificationSystemSubscriberView, notifier::EventNotifier, pipeline::LiveEventHistory, registry::TargetRegistry, rule_engine::NotifyRuleEngine, }; - use rustfs_ecstore::config::Config; + use rustfs_config::server_config::Config; use rustfs_targets::ReplayWorkerManager; use std::sync::Arc; use tokio::sync::{RwLock, Semaphore, broadcast}; diff --git a/crates/targets/Cargo.toml b/crates/targets/Cargo.toml index aa906a741..dafe71bd7 100644 --- a/crates/targets/Cargo.toml +++ b/crates/targets/Cargo.toml @@ -12,7 +12,7 @@ categories = ["web-programming", "development-tools", "filesystem"] documentation = "https://docs.rs/rustfs-targets/latest/rustfs_targets/" [dependencies] -rustfs-config = { workspace = true, features = ["notify", "constants", "audit"] } +rustfs-config = { workspace = true, features = ["notify", "constants", "audit", "server-config-model"] } rustfs-ecstore = { workspace = true } rustfs-tls-runtime = { workspace = true } rustfs-s3-types = { workspace = true } diff --git a/crates/targets/src/catalog/builtin.rs b/crates/targets/src/catalog/builtin.rs index 83eb82dff..18738e01c 100644 --- a/crates/targets/src/catalog/builtin.rs +++ b/crates/targets/src/catalog/builtin.rs @@ -28,6 +28,7 @@ use rustfs_config::notify::{ NOTIFY_POSTGRES_SUB_SYS, NOTIFY_PULSAR_KEYS, NOTIFY_PULSAR_SUB_SYS, NOTIFY_REDIS_DEFAULT_CHANNEL, NOTIFY_REDIS_KEYS, NOTIFY_REDIS_SUB_SYS, NOTIFY_WEBHOOK_KEYS, NOTIFY_WEBHOOK_SUB_SYS, }; +use rustfs_config::server_config::KVS; use rustfs_config::{ AUDIT_DEFAULT_DIR, EVENT_DEFAULT_DIR, audit::{ @@ -35,7 +36,6 @@ use rustfs_config::{ AUDIT_POSTGRES_SUB_SYS, AUDIT_PULSAR_SUB_SYS, AUDIT_REDIS_SUB_SYS, AUDIT_WEBHOOK_SUB_SYS, }, }; -use rustfs_ecstore::config::KVS; use serde::Serialize; use serde::de::DeserializeOwned; diff --git a/crates/targets/src/config/common.rs b/crates/targets/src/config/common.rs index 7016c3c57..4de486f92 100644 --- a/crates/targets/src/config/common.rs +++ b/crates/targets/src/config/common.rs @@ -15,12 +15,12 @@ use crate::TargetError; use crate::target::pulsar::validate_pulsar_broker; use async_nats::ServerAddr; +use rustfs_config::server_config::KVS; use rustfs_config::{ DEFAULT_DELIMITER, ENABLE_KEY, EnableState, NATS_CREDENTIALS_FILE, NATS_PASSWORD, NATS_QUEUE_DIR, NATS_SUBJECT, NATS_TLS_CA, NATS_TLS_CLIENT_CERT, NATS_TLS_CLIENT_KEY, NATS_TOKEN, NATS_USERNAME, PULSAR_AUTH_TOKEN, PULSAR_PASSWORD, PULSAR_QUEUE_DIR, PULSAR_TLS_ALLOW_INSECURE, PULSAR_TLS_CA, PULSAR_TLS_HOSTNAME_VERIFICATION, PULSAR_TOPIC, PULSAR_USERNAME, }; -use rustfs_ecstore::config::KVS; use std::collections::HashSet; use std::path::Path; use std::str::FromStr; @@ -185,10 +185,10 @@ pub(super) fn parse_url(value: &str, field_label: &str) -> Result TargetPluginInstanceCompatDescriptor<'static> { diff --git a/crates/targets/src/config/loader.rs b/crates/targets/src/config/loader.rs index 2fd5cbd50..3c372dbd7 100644 --- a/crates/targets/src/config/loader.rs +++ b/crates/targets/src/config/loader.rs @@ -13,8 +13,8 @@ // limitations under the License. use super::common::{is_target_enabled, split_env_field_and_instance}; +use rustfs_config::server_config::{Config, KVS}; use rustfs_config::{DEFAULT_DELIMITER, ENV_PREFIX}; -use rustfs_ecstore::config::{Config, KVS}; use std::collections::{HashMap, HashSet}; use tracing::{debug, warn}; @@ -244,10 +244,10 @@ mod tests { ENV_NOTIFY_REDIS_ENABLE, ENV_NOTIFY_REDIS_RECONNECT_RETRY_ATTEMPTS, ENV_NOTIFY_REDIS_TLS_ALLOW_INSECURE, ENV_NOTIFY_REDIS_URL, NOTIFY_REDIS_KEYS, NOTIFY_ROUTE_PREFIX, }; + use rustfs_config::server_config::{Config, KVS}; use rustfs_config::{ ENABLE_KEY, REDIS_RECONNECT_RETRY_ATTEMPTS, REDIS_TLS_ALLOW_INSECURE, REDIS_URL, WEBHOOK_ENDPOINT, WEBHOOK_QUEUE_LIMIT, }; - use rustfs_ecstore::config::{Config, KVS}; use std::collections::{HashMap, HashSet}; #[test] diff --git a/crates/targets/src/config/target_args.rs b/crates/targets/src/config/target_args.rs index 57af9c875..564a766ce 100644 --- a/crates/targets/src/config/target_args.rs +++ b/crates/targets/src/config/target_args.rs @@ -27,6 +27,7 @@ use crate::target::{ webhook::WebhookArgs, }; use rumqttc::QoS; +use rustfs_config::server_config::KVS; use rustfs_config::{ AMQP_EXCHANGE, AMQP_MANDATORY, AMQP_PASSWORD, AMQP_PERSISTENT, AMQP_QUEUE_DIR, AMQP_QUEUE_LIMIT, AMQP_ROUTING_KEY, AMQP_TLS_CA, AMQP_TLS_CLIENT_CERT, AMQP_TLS_CLIENT_KEY, AMQP_URL, AMQP_USERNAME, DEFAULT_LIMIT, KAFKA_ACKS, KAFKA_BROKERS, @@ -47,7 +48,6 @@ use rustfs_config::{ REDIS_USERNAME, RUSTFS_WEBHOOK_SKIP_TLS_VERIFY_DEFAULT, WEBHOOK_AUTH_TOKEN, WEBHOOK_CLIENT_CA, WEBHOOK_CLIENT_CERT, WEBHOOK_CLIENT_KEY, WEBHOOK_ENDPOINT, WEBHOOK_QUEUE_DIR, WEBHOOK_QUEUE_LIMIT, WEBHOOK_SKIP_TLS_VERIFY, }; -use rustfs_ecstore::config::KVS; use std::path::Path; use std::time::Duration; @@ -602,6 +602,7 @@ mod tests { kafka::{KAFKA_SASL_PLAIN, KAFKA_SASL_SCRAM_SHA_512}, postgres::PostgresFormat, }; + use rustfs_config::server_config::KVS; use rustfs_config::{ AMQP_EXCHANGE, AMQP_MANDATORY, AMQP_PASSWORD, AMQP_PERSISTENT, AMQP_QUEUE_DIR, AMQP_ROUTING_KEY, AMQP_TLS_CLIENT_CERT, AMQP_TLS_CLIENT_KEY, AMQP_URL, AMQP_USERNAME, KAFKA_ACKS, KAFKA_BROKERS, KAFKA_SASL_ENABLE, KAFKA_SASL_MECHANISM, @@ -611,7 +612,6 @@ mod tests { REDIS_CHANNEL, REDIS_CONNECTION_TIMEOUT, REDIS_MAX_RETRY_DELAY, REDIS_MIN_RETRY_DELAY, REDIS_PIPELINE_BUFFER_SIZE, REDIS_RECONNECT_RETRY_ATTEMPTS, REDIS_RESPONSE_TIMEOUT, REDIS_TLS_ALLOW_INSECURE, REDIS_URL, }; - use rustfs_ecstore::config::KVS; fn absolute_test_path(path: &str) -> String { std::env::temp_dir().join(path).to_string_lossy().into_owned() diff --git a/crates/targets/src/plugin.rs b/crates/targets/src/plugin.rs index 21d9d09df..3b8f5dce3 100644 --- a/crates/targets/src/plugin.rs +++ b/crates/targets/src/plugin.rs @@ -18,7 +18,7 @@ use crate::{ manifest::{TargetPluginManifest, builtin_target_manifest}, }; use hashbrown::HashMap; -use rustfs_ecstore::config::{Config, KVS}; +use rustfs_config::server_config::{Config, KVS}; use serde::Serialize; use serde::de::DeserializeOwned; use std::collections::HashSet; @@ -349,7 +349,7 @@ mod tests { use crate::{StoreError, Target, TargetError}; use async_trait::async_trait; use rustfs_config::ENABLE_KEY; - use rustfs_ecstore::config::{Config, KVS}; + use rustfs_config::server_config::{Config, KVS}; use serde::{Serialize, de::DeserializeOwned}; use std::collections::HashMap; use std::sync::Arc; diff --git a/docs/architecture/migration-progress.md b/docs/architecture/migration-progress.md index 7a235b03d..d31eb70db 100644 --- a/docs/architecture/migration-progress.md +++ b/docs/architecture/migration-progress.md @@ -5,18 +5,17 @@ Status values: `[ ]` not started, `[~]` in progress, `[x]` complete, `[!]` block ## Current Context - Issue: [`rustfs/backlog#660`](https://github.com/rustfs/backlog/issues/660) -- Branch: `overtrue/arch-config-model-extraction` -- Baseline: `origin/main` at `dd5035916e62c031d40ecdf9363763a881517abb` -- PR type for this branch: `api-extraction` +- Branch: `overtrue/arch-config-consumers` +- Baseline: `origin/main` at `22059911807158aae9617415a916cf1156558b7b` +- PR type for this branch: `consumer-migration` - Runtime behavior changes: none. -- Rust code changes: move the pure server-config model (`Config`, `KV`, `KVS`, - `DEFAULT_KVS`, and `register_default_kvs`) into - `rustfs_config::server_config`, keep the old `rustfs_ecstore::config` model - path as a temporary re-export, and leave persistence helpers/global server - config state in ECStore. +- Rust code changes: migrate admin/runtime/audit/notify/targets/iam and + ECStore service/default model consumers from the temporary + `rustfs_ecstore::config` model path to `rustfs_config::server_config`, and + enable the `server-config-model` feature in affected crates. - CI/script changes: none. -- Docs changes: record API-012 completion, current CFG-003/CFG-004 extraction - context, compatibility cleanup marker, and verification evidence. +- Docs changes: record CFG-005/CFG-006 consumer-migration context, verification + evidence, and the preserved ECStore runtime-state boundary. ## Phase 0 Tasks @@ -79,16 +78,32 @@ Status values: `[ ]` not started, `[~]` in progress, `[x]` complete, `[!]` block `rustfs-config` as the target package, `server_config` as the future model module, allowed dependencies, forbidden dependencies, preserved shape, and extraction verification gates. -- [~] `CFG-003` Move pure model definitions. - - Current branch: move only `Config`, `KV`, `KVS`, and - default-registration surface into `rustfs-config`; keep persistence helpers - and global server-config state in `ecstore`. +- [x] `CFG-003` Move pure model definitions. + - Completed slice: `rustfs/rustfs#3351` moved only `Config`, `KV`, `KVS`, + and default-registration surface into `rustfs-config`; persistence helpers + and global server-config state remain in `ecstore`. - Must preserve: tuple struct shapes, serde alias behavior, default application, internal JSON shape, and existing persisted config semantics. -- [~] `CFG-004` Keep old `ecstore::config::*` compatibility path. - - Current branch: re-export moved model types and default-registration - surface from `rustfs_ecstore::config` with `RUSTFS_COMPAT_TODO(CFG-004)` - and cleanup-register coverage. +- [x] `CFG-004` Keep old `ecstore::config::*` compatibility path. + - Completed slice: `rustfs/rustfs#3351` re-exported moved model types and + default-registration surface from `rustfs_ecstore::config` with + `RUSTFS_COMPAT_TODO(CFG-004)` and cleanup-register coverage. +- [x] `CFG-005` Migrate external server-config model consumers. + - Current branch: migrate admin handlers, admin services, runtime context, + server audit/event setup, and the audit/notify/targets/iam crates from the + temporary `rustfs_ecstore::config::{Config, KV, KVS}` model path to + `rustfs_config::server_config`. + - Acceptance: external consumers use the model crate for pure config types + while still using ECStore for persistence helpers, global server-config + accessors, storage-class helpers, and startup initialization. +- [x] `CFG-006` Migrate ECStore service/default model consumers. + - Current branch: migrate ECStore config default modules, shared config + helpers, and store accessor signatures to the `rustfs_config` model type + while preserving ECStore-owned persistence and runtime state. + - Acceptance: ECStore internals no longer depend on the old compatibility + model import path except the deliberate compatibility smoke test; the old + public re-export remains available for downstream callers until CFG-004 is + cleaned up. ## Phase 1 Security Governance Tasks @@ -313,41 +328,45 @@ Status values: `[ ]` not started, `[~]` in progress, `[x]` complete, `[!]` block ## Next PRs -1. `api-extraction`: move only the pure server-config model into rustfs-config - as CFG-003 and keep the old rustfs_ecstore::config::* path with - RUSTFS_COMPAT_TODO(CFG-004) and cleanup-register coverage. -2. `consumer-migration`: migrate external consumers one group at a time only - after the model path and compatibility shim are stable. -3. `security-change`: make Local KMS unsafe defaults explicit development +1. `api-extraction`: remove the temporary `rustfs_ecstore::config` model + re-export after downstream compatibility policy allows CFG-004 cleanup. +2. `security-change`: make Local KMS unsafe defaults explicit development opt-ins or production failures in KMSD-002. -4. `security-change`: make Vault unsafe defaults explicit development opt-ins +3. `security-change`: make Vault unsafe defaults explicit development opt-ins or production failures in KMSD-003. ## Pre-Push Review Log | Expert | Status | Notes | |---|---|---| -| Quality/architecture | pass | Confirmed this stays a pure model extraction into `rustfs_config::server_config`; persistence helpers, global state, runtime consumers, startup wiring, and storage hot paths remain in ECStore or unchanged. | -| Migration preservation | pass | Confirmed the old `rustfs_ecstore::config` model path remains available through `RUSTFS_COMPAT_TODO(CFG-004)`, while tuple shapes, serde alias behavior, defaults, marshal/unmarshal, and persisted JSON shape are preserved. | -| Testing/verification | pass | Confirmed focused config/model tests, compile checks, dependency tree, migration guards, diff hygiene, and added-line risk scan are sufficient before push; full pre-commit is skipped under the current larger-granularity instruction. | +| Quality/architecture | pass | Confirmed this is only a model-consumer migration and feature-gate update; ECStore persistence helpers, global state, startup wiring, config persistence, and storage hot paths stay unchanged. | +| Migration preservation | pass | Confirmed the old `rustfs_ecstore::config` model path remains available through `RUSTFS_COMPAT_TODO(CFG-004)`, with no tuple-shape, serde, default, or persisted JSON changes. | +| Testing/verification | pass | Confirmed focused config/admin/audit/notify/targets/iam tests, compile checks, migration guards, boundary scans, and added-line risk scan are sufficient; full pre-commit is skipped under the current larger-granularity instruction. | ## Verification Notes Passed: - `cargo fmt --all --check`. -- `cargo check -p rustfs-config --features server-config-model`. -- `cargo check -p rustfs-config`. -- `cargo check -p rustfs-ecstore`. -- `cargo check -p rustfs-config -p rustfs-ecstore -p rustfs --lib`. -- `cargo check -p rustfs-targets -p rustfs-notify -p rustfs-audit -p rustfs-iam -p rustfs-scanner -p rustfs --lib`. -- `cargo test -p rustfs-config --features server-config-model server_config --lib`; 3 passed. +- `cargo check -p rustfs-config -p rustfs-audit -p rustfs-notify -p rustfs-targets -p rustfs-iam -p rustfs-ecstore -p rustfs --lib`. +- `cargo test -p rustfs-config --features server-config-model --lib`; 29 passed. - `cargo test -p rustfs-ecstore config --lib`; 60 passed. +- `cargo test -p rustfs-targets config --lib`; 65 passed. +- `cargo test -p rustfs-notify config_manager --lib`; 12 passed. +- `cargo test -p rustfs-audit --lib`; 5 passed. +- `cargo test -p rustfs-iam oidc --lib`; 53 passed. +- `cargo test -p rustfs admin::handlers::config_admin --lib`; 29 passed. +- `cargo test -p rustfs admin::service::config --lib`; 6 passed. - `./scripts/check_architecture_migration_rules.sh`. - `./scripts/check_layer_dependencies.sh`. - `./scripts/check_metrics_migration_refs.sh`. - `./scripts/check_unsafe_code_allowances.sh`. - `git diff --check`. -- `cargo tree -p rustfs-config --edges normal --features server-config-model`. +- External old-model path scan: + `rustfs_ecstore::config::{Config, KV, KVS}` is absent from `rustfs/src`, + `crates/audit`, `crates/notify`, `crates/targets`, and `crates/iam`. +- ECStore runtime helper scan: no `rustfs_config::server_config::{init, + get_global_server_config, set_global_server_config, + set_global_storage_class, com, storageclass}` usage exists. - Added-line risk scan found no production `unwrap`/`expect`, lossy numeric casts, stringly public errors, boxed dynamic errors, stdout/stderr printing, or relaxed atomic ordering. @@ -355,25 +374,22 @@ Passed: Notes: - Full pre-commit may be skipped if focused tests, compile checks, and guards pass, per the current instruction to increase PR granularity. -- This slice moves only the pure server-config model and default-registration - surface. ECStore retains persistence helpers, ConfigSys, global server-config - state, storage-class global state, startup wiring, and all runtime consumers. +- This slice migrates model consumers only. ECStore retains persistence helpers, + ConfigSys, global server-config state, storage-class global state, startup + wiring, and all storage/config persistence logic. - The old rustfs_ecstore::config model path intentionally remains as a temporary compatibility re-export with `RUSTFS_COMPAT_TODO(CFG-004)` and a matching cleanup-register entry. -- A focused ECStore test proves the old path re-exports the moved model type; - rustfs-config tests cover KVS behavior, legacy hiddenIfEmpty alias - compatibility, and marshal/unmarshal internal JSON shape. +- The remaining ECStore old-path references are limited to the deliberate + compatibility smoke test in `crates/ecstore/src/config/mod.rs`. ## Handoff Notes -- Keep this CFG-003/CFG-004 slice as an `api-extraction` PR that only moves the - pure server-config model to `rustfs_config::server_config` and keeps old - `rustfs_ecstore::config` model import paths compiling. +- Keep this CFG-005/CFG-006 slice as a `consumer-migration` PR that only + updates model type imports and affected crate feature gates. - Do not move `ConfigSys`, `GLOBAL_SERVER_CONFIG`, storage-class global state, `read_config_without_migrate`, `save_server_config`, config-object helpers, - startup wiring, runtime consumers, or storage persistence logic in this PR. -- Do not migrate external consumers in this PR; consumer migration starts after - the new model path and compatibility shim are merged. + startup wiring, storage-class helpers, ECStore persistence helpers, or storage + persistence logic in this PR. - Do not add temporary compatibility code unless a matching `RUSTFS_COMPAT_TODO()` marker and cleanup-register entry are added. diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index 0d05d680c..3b8f19e27 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -64,7 +64,7 @@ workspace = true rustfs-heal = { workspace = true } rustfs-audit = { workspace = true } rustfs-common = { workspace = true } -rustfs-config = { workspace = true, features = ["constants", "notify"] } +rustfs-config = { workspace = true, features = ["constants", "notify", "server-config-model"] } rustfs-crypto = { workspace = true } rustfs-credentials = { workspace = true } rustfs-ecstore = { workspace = true } diff --git a/rustfs/src/admin/handlers/audit.rs b/rustfs/src/admin/handlers/audit.rs index a25e6b07f..6c218afa9 100644 --- a/rustfs/src/admin/handlers/audit.rs +++ b/rustfs/src/admin/handlers/audit.rs @@ -32,8 +32,8 @@ use hyper::Method; use matchit::Params; use rustfs_audit::audit_system; use rustfs_config::audit::AUDIT_ROUTE_PREFIX; +use rustfs_config::server_config::Config; use rustfs_config::{AUDIT_DEFAULT_DIR, MAX_ADMIN_REQUEST_BODY_SIZE}; -use rustfs_ecstore::config::Config; use rustfs_policy::policy::action::{Action, AdminAction}; use rustfs_targets::catalog::builtin::builtin_audit_target_admin_descriptors; use s3s::{Body, S3Request, S3Response, S3Result, s3_error}; @@ -263,8 +263,8 @@ mod tests { use crate::admin::handlers::target_descriptor::collect_validated_key_values as shared_collect_validated_key_values; use matchit::Router; use rustfs_config::audit::{AUDIT_AMQP_SUB_SYS, AUDIT_KAFKA_SUB_SYS, AUDIT_WEBHOOK_KEYS, AUDIT_WEBHOOK_SUB_SYS}; + use rustfs_config::server_config::{KV, KVS}; use rustfs_config::{DEFAULT_DELIMITER, ENABLE_KEY, ENV_PREFIX}; - use rustfs_ecstore::config::{KV, KVS}; use serial_test::serial; use std::collections::{HashMap, HashSet}; use temp_env::{with_var, with_vars, with_vars_unset}; diff --git a/rustfs/src/admin/handlers/audit_runtime_config.rs b/rustfs/src/admin/handlers/audit_runtime_config.rs index 1d9dbeeea..a8b6b2ca4 100644 --- a/rustfs/src/admin/handlers/audit_runtime_config.rs +++ b/rustfs/src/admin/handlers/audit_runtime_config.rs @@ -15,7 +15,7 @@ use crate::admin::handlers::target_descriptor::AdminTargetSpec; use rustfs_audit::{audit_system, start_audit_system as start_global_audit_system, system::AuditSystemState}; use rustfs_config::DEFAULT_DELIMITER; -use rustfs_ecstore::config::Config; +use rustfs_config::server_config::Config; use s3s::{S3Result, s3_error}; pub(crate) async fn load_server_config_from_store() -> S3Result { @@ -100,7 +100,7 @@ pub(crate) async fn set_audit_target_config( specs: &[AdminTargetSpec], subsystem: &str, target_name: &str, - kvs: rustfs_ecstore::config::KVS, + kvs: rustfs_config::server_config::KVS, ) -> S3Result<()> { update_audit_config_and_reload(specs, |config| { config diff --git a/rustfs/src/admin/handlers/config_admin.rs b/rustfs/src/admin/handlers/config_admin.rs index 254bf8062..436e46b39 100644 --- a/rustfs/src/admin/handlers/config_admin.rs +++ b/rustfs/src/admin/handlers/config_admin.rs @@ -48,6 +48,7 @@ use rustfs_config::oidc::{ OIDC_CLIENT_ID, OIDC_CLIENT_SECRET, OIDC_CONFIG_URL, OIDC_DISPLAY_NAME, OIDC_EMAIL_CLAIM, OIDC_GROUPS_CLAIM, OIDC_REDIRECT_URI, OIDC_REDIRECT_URI_DYNAMIC, OIDC_ROLE_POLICY, OIDC_SCOPES, OIDC_USERNAME_CLAIM, }; +use rustfs_config::server_config::{Config as ServerConfig, DEFAULT_KVS, KV, KVS}; use rustfs_config::{ COMMENT_KEY, DEFAULT_DELIMITER, ENABLE_KEY, ENV_PREFIX, ENV_SCANNER_ALERT_EXCESS_FOLDERS, ENV_SCANNER_ALERT_EXCESS_VERSION_SIZE, ENV_SCANNER_ALERT_EXCESS_VERSIONS, ENV_SCANNER_BITROT_CYCLE_SECS, @@ -68,7 +69,7 @@ use rustfs_credentials::Credentials; use rustfs_ecstore::config::com::STORAGE_CLASS_SUB_SYS; use rustfs_ecstore::config::com::{delete_config, read_config, read_config_without_migrate, save_config, save_server_config}; use rustfs_ecstore::config::storageclass::{INLINE_BLOCK_ENV, OPTIMIZE_ENV, RRS_ENV, STANDARD_ENV}; -use rustfs_ecstore::config::{Config as ServerConfig, DEFAULT_KVS, KV, KVS, get_global_server_config, set_global_server_config}; +use rustfs_ecstore::config::{get_global_server_config, set_global_server_config}; use rustfs_ecstore::disk::RUSTFS_META_BUCKET; use rustfs_ecstore::new_object_layer_fn; use rustfs_ecstore::store_api::ListOperations; diff --git a/rustfs/src/admin/handlers/event.rs b/rustfs/src/admin/handlers/event.rs index c78673ead..6a882fe33 100644 --- a/rustfs/src/admin/handlers/event.rs +++ b/rustfs/src/admin/handlers/event.rs @@ -32,8 +32,8 @@ use http::StatusCode; use hyper::Method; use matchit::Params; use rustfs_config::notify::NOTIFY_ROUTE_PREFIX; +use rustfs_config::server_config::Config; use rustfs_config::{EVENT_DEFAULT_DIR, MAX_ADMIN_REQUEST_BODY_SIZE}; -use rustfs_ecstore::config::Config; use rustfs_policy::policy::action::{Action, AdminAction}; use rustfs_targets::catalog::builtin::builtin_notify_target_admin_descriptors; use s3s::{Body, S3Request, S3Response, S3Result, s3_error}; @@ -299,8 +299,8 @@ mod tests { }; use matchit::Router; use rustfs_config::notify::{NOTIFY_AMQP_SUB_SYS, NOTIFY_KAFKA_SUB_SYS, NOTIFY_MQTT_SUB_SYS, NOTIFY_WEBHOOK_SUB_SYS}; + use rustfs_config::server_config::{KV, KVS}; use rustfs_config::{DEFAULT_DELIMITER, ENABLE_KEY}; - use rustfs_ecstore::config::{KV, KVS}; use rustfs_targets::arn::TargetID; use serial_test::serial; use std::collections::{HashMap, HashSet}; diff --git a/rustfs/src/admin/handlers/notify_runtime_access.rs b/rustfs/src/admin/handlers/notify_runtime_access.rs index c108ff255..77cc57b53 100644 --- a/rustfs/src/admin/handlers/notify_runtime_access.rs +++ b/rustfs/src/admin/handlers/notify_runtime_access.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use rustfs_ecstore::config::Config; +use rustfs_config::server_config::Config; use s3s::{S3Result, s3_error}; use std::sync::Arc; @@ -29,7 +29,7 @@ pub(crate) async fn load_notification_config_snapshot() -> S3Result<(Arc S3Result<()> { let system = get_notification_system()?; system diff --git a/rustfs/src/admin/handlers/oidc.rs b/rustfs/src/admin/handlers/oidc.rs index 53e5ffa91..7c860d2c8 100644 --- a/rustfs/src/admin/handlers/oidc.rs +++ b/rustfs/src/admin/handlers/oidc.rs @@ -26,9 +26,10 @@ use rustfs_config::oidc::{ OIDC_DEFAULT_USERNAME_CLAIM, OIDC_DISPLAY_NAME, OIDC_EMAIL_CLAIM, OIDC_GROUPS_CLAIM, OIDC_HIDE_FROM_UI, OIDC_OTHER_AUDIENCES, OIDC_REDIRECT_URI, OIDC_REDIRECT_URI_DYNAMIC, OIDC_ROLE_POLICY, OIDC_ROLES_CLAIM, OIDC_SCOPES, OIDC_USERNAME_CLAIM, }; +use rustfs_config::server_config::Config as ServerConfig; use rustfs_config::{DEFAULT_DELIMITER, ENABLE_KEY, EnableState, MAX_ADMIN_REQUEST_BODY_SIZE}; use rustfs_ecstore::config::com::{read_config_without_migrate, save_server_config}; -use rustfs_ecstore::config::{Config as ServerConfig, get_global_server_config}; +use rustfs_ecstore::config::get_global_server_config; use rustfs_ecstore::new_object_layer_fn; use rustfs_policy::policy::action::{Action, AdminAction}; use s3s::{Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result, s3_error}; @@ -791,13 +792,13 @@ fn oidc_restart_required_from_active_config(config: &ServerConfig, active_config != rustfs_iam::oidc::load_effective_oidc_provider_configs(active_config) } -fn default_oidc_kvs() -> s3s::S3Result { +fn default_oidc_kvs() -> s3s::S3Result { ServerConfig::new() .get_value(IDENTITY_OPENID_SUB_SYS, DEFAULT_DELIMITER) .ok_or_else(|| s3_error!(InternalError, "default OIDC configuration missing")) } -fn set_kvs_value(kvs: &mut rustfs_ecstore::config::KVS, key: &str, value: String) { +fn set_kvs_value(kvs: &mut rustfs_config::server_config::KVS, key: &str, value: String) { if let Some(existing) = kvs.0.iter_mut().find(|kv| kv.key == key) { existing.value = value; return; diff --git a/rustfs/src/admin/handlers/plugins_instances.rs b/rustfs/src/admin/handlers/plugins_instances.rs index aa2797dc8..5fe3bbbc3 100644 --- a/rustfs/src/admin/handlers/plugins_instances.rs +++ b/rustfs/src/admin/handlers/plugins_instances.rs @@ -39,8 +39,8 @@ use matchit::Params; use rustfs_audit::audit_system; use rustfs_config::audit::AUDIT_ROUTE_PREFIX; use rustfs_config::notify::NOTIFY_ROUTE_PREFIX; +use rustfs_config::server_config::{Config, KVS}; use rustfs_config::{AUDIT_DEFAULT_DIR, EVENT_DEFAULT_DIR, MAX_ADMIN_REQUEST_BODY_SIZE}; -use rustfs_ecstore::config::{Config, KVS}; use rustfs_policy::policy::action::{Action, AdminAction}; use rustfs_targets::catalog::builtin::{builtin_audit_target_admin_descriptors, builtin_notify_target_admin_descriptors}; use rustfs_targets::manifest::builtin_target_manifest; @@ -868,8 +868,8 @@ mod tests { use rustfs_config::audit::AUDIT_WEBHOOK_SUB_SYS; use rustfs_config::notify::NOTIFY_ROUTE_PREFIX; use rustfs_config::notify::NOTIFY_WEBHOOK_SUB_SYS; + use rustfs_config::server_config::{Config, KV, KVS}; use rustfs_config::{ENABLE_KEY, WEBHOOK_AUTH_TOKEN, WEBHOOK_ENDPOINT}; - use rustfs_ecstore::config::{Config, KV, KVS}; use rustfs_targets::TargetDomain; use s3s::{Body, S3Request}; use std::collections::HashMap; diff --git a/rustfs/src/admin/handlers/site_replication.rs b/rustfs/src/admin/handlers/site_replication.rs index d64ca45f6..d18675063 100644 --- a/rustfs/src/admin/handlers/site_replication.rs +++ b/rustfs/src/admin/handlers/site_replication.rs @@ -691,7 +691,7 @@ fn config_enabled(value: Option) -> bool { matches!(value.as_deref(), Some("on" | "true" | "enabled")) } -fn ldap_settings_from_kvs(kvs: &rustfs_ecstore::config::KVS) -> (LDAPSettings, LDAPConfigSettings) { +fn ldap_settings_from_kvs(kvs: &rustfs_config::server_config::KVS) -> (LDAPSettings, LDAPConfigSettings) { let enabled = config_enabled(kvs.lookup("enable")); let settings = LDAPSettings { is_ldap_enabled: enabled, @@ -4508,28 +4508,28 @@ mod tests { #[test] fn test_ldap_settings_from_kvs_reads_minio_style_keys() { - let kvs = rustfs_ecstore::config::KVS(vec![ - rustfs_ecstore::config::KV { + let kvs = rustfs_config::server_config::KVS(vec![ + rustfs_config::server_config::KV { key: "enable".to_string(), value: "on".to_string(), hidden_if_empty: false, }, - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: "user_dn_search_base_dn".to_string(), value: "ou=people,dc=example,dc=com".to_string(), hidden_if_empty: false, }, - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: "user_dn_search_filter".to_string(), value: "(uid=%s)".to_string(), hidden_if_empty: false, }, - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: "group_search_base_dn".to_string(), value: "ou=groups,dc=example,dc=com".to_string(), hidden_if_empty: false, }, - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: "group_search_filter".to_string(), value: "(&(objectclass=groupOfNames)(member=%s))".to_string(), hidden_if_empty: false, diff --git a/rustfs/src/admin/handlers/target_descriptor.rs b/rustfs/src/admin/handlers/target_descriptor.rs index b76ed80a6..d7ea4b4ef 100644 --- a/rustfs/src/admin/handlers/target_descriptor.rs +++ b/rustfs/src/admin/handlers/target_descriptor.rs @@ -16,12 +16,12 @@ use futures::StreamExt; use futures::future::BoxFuture; use hashbrown::HashSet as HbHashSet; use http::{HeaderMap, HeaderValue, StatusCode}; +use rustfs_config::server_config::{Config, KVS}; use rustfs_config::{ AMQP_QUEUE_DIR, ENABLE_KEY, EnableState, KAFKA_BROKERS, KAFKA_QUEUE_DIR, KAFKA_TOPIC, MQTT_BROKER, MQTT_PASSWORD, MQTT_QOS, MQTT_TLS_CA, MQTT_TLS_CLIENT_CERT, MQTT_TLS_CLIENT_KEY, MQTT_TLS_POLICY, MQTT_TLS_TRUST_LEAF_AS_CA, MQTT_TOPIC, MQTT_USERNAME, MQTT_WS_PATH_ALLOWLIST, MYSQL_QUEUE_DIR, POSTGRES_QUEUE_DIR, REDIS_QUEUE_DIR, }; -use rustfs_ecstore::config::{Config, KVS}; use rustfs_targets::SharedTarget; use rustfs_targets::{ BuiltinTargetAdminDescriptor, TargetAdminMetadata, TargetDomain, TargetError, TargetRequestValidator, @@ -904,8 +904,8 @@ async fn validate_redis_request( }) } -fn to_kvs(kv_map: &HashMap) -> rustfs_ecstore::config::KVS { - let mut kvs = rustfs_ecstore::config::KVS::new(); +fn to_kvs(kv_map: &HashMap) -> rustfs_config::server_config::KVS { + let mut kvs = rustfs_config::server_config::KVS::new(); for (key, value) in kv_map { kvs.insert(key.clone(), value.clone()); } diff --git a/rustfs/src/admin/router.rs b/rustfs/src/admin/router.rs index 150213906..f7dd08cd7 100644 --- a/rustfs/src/admin/router.rs +++ b/rustfs/src/admin/router.rs @@ -36,6 +36,7 @@ use matchit::Params; use matchit::Router; use reqwest::Url; use rustfs_config::notify::NOTIFY_WEBHOOK_SUB_SYS; +use rustfs_config::server_config::Config; use rustfs_config::{ ENABLE_KEY, WEBHOOK_AUTH_TOKEN, WEBHOOK_CLIENT_CA, WEBHOOK_CLIENT_CERT, WEBHOOK_CLIENT_KEY, WEBHOOK_ENDPOINT, WEBHOOK_SKIP_TLS_VERIFY, @@ -54,7 +55,7 @@ use rustfs_ecstore::bucket::target::{BucketTarget, BucketTargetType, BucketTarge use rustfs_ecstore::bucket::versioning::VersioningApi; use rustfs_ecstore::bucket::versioning_sys::BucketVersioningSys; use rustfs_ecstore::config::com::read_config_without_migrate; -use rustfs_ecstore::config::{Config, get_global_server_config}; +use rustfs_ecstore::config::get_global_server_config; use rustfs_ecstore::global::GLOBAL_BOOT_TIME; use rustfs_ecstore::notification_sys::get_global_notification_sys; use rustfs_ecstore::rpc::PeerRestClient; @@ -3265,22 +3266,22 @@ mod tests { let arn = "arn:acme:s3-object-lambda::transformer:webhook" .parse::() .expect("arn should parse"); - let config = rustfs_ecstore::config::Config(std::collections::HashMap::from([( + let config = rustfs_config::server_config::Config(std::collections::HashMap::from([( LAMBDA_WEBHOOK_SUB_SYS.to_string(), std::collections::HashMap::from([( "transformer".to_string(), - rustfs_ecstore::config::KVS(vec![ - rustfs_ecstore::config::KV { + rustfs_config::server_config::KVS(vec![ + rustfs_config::server_config::KV { key: ENABLE_KEY.to_string(), value: "on".to_string(), hidden_if_empty: false, }, - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: WEBHOOK_ENDPOINT.to_string(), value: "https://example.com/transform".to_string(), hidden_if_empty: false, }, - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: WEBHOOK_AUTH_TOKEN.to_string(), value: "secret-token".to_string(), hidden_if_empty: true, @@ -3302,17 +3303,17 @@ mod tests { let arn = "arn:acme:s3-object-lambda::transformer:webhook-csv" .parse::() .expect("arn should parse"); - let config = rustfs_ecstore::config::Config(std::collections::HashMap::from([( + let config = rustfs_config::server_config::Config(std::collections::HashMap::from([( LAMBDA_WEBHOOK_SUB_SYS.to_string(), std::collections::HashMap::from([( "transformer".to_string(), - rustfs_ecstore::config::KVS(vec![ - rustfs_ecstore::config::KV { + rustfs_config::server_config::KVS(vec![ + rustfs_config::server_config::KV { key: ENABLE_KEY.to_string(), value: "on".to_string(), hidden_if_empty: false, }, - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: WEBHOOK_ENDPOINT.to_string(), value: "https://example.com/transform-csv".to_string(), hidden_if_empty: false, @@ -3330,22 +3331,22 @@ mod tests { let arn = "arn:acme:s3-object-lambda::transformer:webhook" .parse::() .expect("arn should parse"); - let config = rustfs_ecstore::config::Config(std::collections::HashMap::from([( + let config = rustfs_config::server_config::Config(std::collections::HashMap::from([( LAMBDA_WEBHOOK_SUB_SYS.to_string(), std::collections::HashMap::from([( "transformer".to_string(), - rustfs_ecstore::config::KVS(vec![ - rustfs_ecstore::config::KV { + rustfs_config::server_config::KVS(vec![ + rustfs_config::server_config::KV { key: ENABLE_KEY.to_string(), value: "on".to_string(), hidden_if_empty: false, }, - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: WEBHOOK_ENDPOINT.to_string(), value: "https://example.com/transform".to_string(), hidden_if_empty: false, }, - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: WEBHOOK_RESPONSE_HEADER_TIMEOUT.to_string(), value: "2s".to_string(), hidden_if_empty: false, @@ -3363,17 +3364,17 @@ mod tests { let arn = "arn:acme:s3-object-lambda::transformer:webhook" .parse::() .expect("arn should parse"); - let config = rustfs_ecstore::config::Config(std::collections::HashMap::from([( + let config = rustfs_config::server_config::Config(std::collections::HashMap::from([( NOTIFY_WEBHOOK_SUB_SYS.to_string(), std::collections::HashMap::from([( "transformer".to_string(), - rustfs_ecstore::config::KVS(vec![ - rustfs_ecstore::config::KV { + rustfs_config::server_config::KVS(vec![ + rustfs_config::server_config::KV { key: ENABLE_KEY.to_string(), value: "on".to_string(), hidden_if_empty: false, }, - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: WEBHOOK_ENDPOINT.to_string(), value: "https://example.com/notify-transform".to_string(), hidden_if_empty: false, @@ -3391,22 +3392,22 @@ mod tests { let arn = "arn:acme:s3-object-lambda::transformer:webhook" .parse::() .expect("arn should parse"); - let config = rustfs_ecstore::config::Config(std::collections::HashMap::from([( + let config = rustfs_config::server_config::Config(std::collections::HashMap::from([( LAMBDA_WEBHOOK_SUB_SYS.to_string(), std::collections::HashMap::from([( "transformer".to_string(), - rustfs_ecstore::config::KVS(vec![ - rustfs_ecstore::config::KV { + rustfs_config::server_config::KVS(vec![ + rustfs_config::server_config::KV { key: ENABLE_KEY.to_string(), value: "on".to_string(), hidden_if_empty: false, }, - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: WEBHOOK_ENDPOINT.to_string(), value: "https://example.com/transform".to_string(), hidden_if_empty: false, }, - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: WEBHOOK_RESPONSE_HEADER_TIMEOUT.to_string(), value: "definitely-not-a-duration".to_string(), hidden_if_empty: false, @@ -3425,7 +3426,7 @@ mod tests { let unsupported = "arn:acme:s3-object-lambda::transformer:mqtt" .parse::() .expect("arn should parse"); - let empty_config = rustfs_ecstore::config::Config(std::collections::HashMap::new()); + let empty_config = rustfs_config::server_config::Config(std::collections::HashMap::new()); let unsupported_err = resolve_object_lambda_webhook_config_from_server_config(&empty_config, &unsupported) .expect_err("unsupported target type should fail"); assert_eq!(unsupported_err.code(), &S3ErrorCode::NotImplemented); @@ -3433,17 +3434,17 @@ mod tests { let webhook = "arn:acme:s3-object-lambda::transformer:webhook" .parse::() .expect("arn should parse"); - let disabled_config = rustfs_ecstore::config::Config(std::collections::HashMap::from([( + let disabled_config = rustfs_config::server_config::Config(std::collections::HashMap::from([( LAMBDA_WEBHOOK_SUB_SYS.to_string(), std::collections::HashMap::from([( "transformer".to_string(), - rustfs_ecstore::config::KVS(vec![ - rustfs_ecstore::config::KV { + rustfs_config::server_config::KVS(vec![ + rustfs_config::server_config::KV { key: ENABLE_KEY.to_string(), value: "off".to_string(), hidden_if_empty: false, }, - rustfs_ecstore::config::KV { + rustfs_config::server_config::KV { key: WEBHOOK_ENDPOINT.to_string(), value: "https://example.com/transform".to_string(), hidden_if_empty: false, diff --git a/rustfs/src/admin/service/config.rs b/rustfs/src/admin/service/config.rs index 2f757a4bd..4bf21c922 100644 --- a/rustfs/src/admin/service/config.rs +++ b/rustfs/src/admin/service/config.rs @@ -16,12 +16,13 @@ use rustfs_audit::reload_audit_config; use rustfs_config::audit::{AUDIT_MQTT_SUB_SYS, AUDIT_REDIS_DEFAULT_CHANNEL, AUDIT_WEBHOOK_SUB_SYS}; use rustfs_config::notify::{NOTIFY_MQTT_SUB_SYS, NOTIFY_REDIS_DEFAULT_CHANNEL, NOTIFY_WEBHOOK_SUB_SYS}; use rustfs_config::oidc::IDENTITY_OPENID_SUB_SYS; +use rustfs_config::server_config::{Config as ServerConfig, KVS}; use rustfs_config::{AUDIT_DEFAULT_DIR, EVENT_DEFAULT_DIR}; use rustfs_config::{DEFAULT_DELIMITER, ENABLE_KEY, EnableState}; use rustfs_config::{HEAL_SUB_SYS, SCANNER_SUB_SYS}; use rustfs_ecstore::config::com::{STORAGE_CLASS_SUB_SYS, read_config_without_migrate}; use rustfs_ecstore::config::storageclass; -use rustfs_ecstore::config::{Config as ServerConfig, KVS, set_global_server_config, set_global_storage_class}; +use rustfs_ecstore::config::{set_global_server_config, set_global_storage_class}; use rustfs_ecstore::new_object_layer_fn; use rustfs_ecstore::notification_sys::get_global_notification_sys; use rustfs_iam::oidc::load_oidc_provider_configs_from_server_config; diff --git a/rustfs/src/app/context.rs b/rustfs/src/app/context.rs index f18bce2c6..dc8366058 100644 --- a/rustfs/src/app/context.rs +++ b/rustfs/src/app/context.rs @@ -18,8 +18,9 @@ use crate::config::{RustFSBufferConfig, get_global_buffer_config}; use async_trait::async_trait; +use rustfs_config::server_config::Config; use rustfs_ecstore::bucket::metadata_sys::{BucketMetadataSys, get_global_bucket_metadata_sys}; -use rustfs_ecstore::config::{Config, get_global_server_config}; +use rustfs_ecstore::config::get_global_server_config; use rustfs_ecstore::endpoints::EndpointServerPools; use rustfs_ecstore::global::{get_global_endpoints_opt, get_global_region, get_global_tier_config_mgr}; use rustfs_ecstore::store::ECStore; diff --git a/rustfs/src/server/audit.rs b/rustfs/src/server/audit.rs index ceb42b65a..e72ad29c2 100644 --- a/rustfs/src/server/audit.rs +++ b/rustfs/src/server/audit.rs @@ -20,7 +20,7 @@ use tracing::{info, warn}; static AUDIT_MODULE_ENABLED: AtomicBool = AtomicBool::new(rustfs_config::DEFAULT_AUDIT_ENABLE); -fn server_config_from_context() -> Option { +fn server_config_from_context() -> Option { resolve_server_config() } @@ -34,7 +34,7 @@ pub fn is_audit_module_enabled() -> bool { AUDIT_MODULE_ENABLED.load(Ordering::Relaxed) } -fn has_any_audit_targets(config: &rustfs_ecstore::config::Config) -> bool { +fn has_any_audit_targets(config: &rustfs_config::server_config::Config) -> bool { for &subsystem in rustfs_config::audit::AUDIT_SUB_SYSTEMS { let Some(targets) = config.0.get(subsystem) else { continue; diff --git a/rustfs/src/server/event.rs b/rustfs/src/server/event.rs index 4b39a0914..36b75221d 100644 --- a/rustfs/src/server/event.rs +++ b/rustfs/src/server/event.rs @@ -24,7 +24,7 @@ use tracing::{error, info, instrument, warn}; static NOTIFY_MODULE_ENABLED: AtomicBool = AtomicBool::new(rustfs_config::DEFAULT_NOTIFY_ENABLE); -fn server_config_from_context() -> Option { +fn server_config_from_context() -> Option { resolve_server_config() }