Skip to main content

codetether_rlm/events/
s3_config.rs

1//! S3/MinIO config for trace persistence.
2
3/// Decoupled from the host crate's `S3Config`.
4#[derive(Debug, Clone)]
5pub struct S3Config {
6    pub endpoint: String,
7    pub access_key: String,
8    pub secret_key: String,
9    pub bucket: String,
10    pub prefix: String,
11    pub secure: bool,
12    pub ignore_cert: bool,
13}
14impl S3Config {
15    /// Build from standard environment variables.
16    pub fn from_env_or_vault() -> anyhow::Result<Self> {
17        Ok(Self {
18            endpoint: std::env::var("MINIO_ENDPOINT")
19                .unwrap_or_else(|_| "http://localhost:9000".into()),
20            access_key: std::env::var("MINIO_ACCESS_KEY")?,
21            secret_key: std::env::var("MINIO_SECRET_KEY")?,
22            bucket: std::env::var("MINIO_RLM_BUCKET")
23                .unwrap_or_else(|_| "codetether-rlm-traces".into()),
24            prefix: std::env::var("MINIO_RLM_PREFIX").unwrap_or_else(|_| "training/".into()),
25            secure: std::env::var("MINIO_SECURE").as_deref() == Ok("true"),
26            ignore_cert: std::env::var("MINIO_IGNORE_CERT").as_deref() == Ok("true"),
27        })
28    }
29}