pigeon-cli 0.4.24

Pigeon: authenticate, sink, and transform personal data from external services.
Documentation
use serde::{Deserialize, Serialize};

/// A single configured S3-compatible bucket-config's metadata, including its
/// secret access key as a plain field -- `keyring.toml` is this entry's sole
/// storage since ADR-0135 retired the OS keychain, protected only by
/// `Store::save`'s `0600` file permissions. Deliberately has no
/// `#[serde(default)]` on `secret_key`: a pre-ADR-0135 entry with no secret
/// field fails to parse loudly rather than silently loading an empty secret.
/// Metadata persistence itself lives in `crate::commands::keyring::store`
/// (ADR-0022) -- this struct is kept here since `client` (this module's
/// sibling) is its main consumer.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BucketConfig {
    pub alias: String,
    pub endpoint: String,
    pub bucket: String,
    pub access_key_id: String,
    /// S3 secret access key. See
    /// `crate::core::keyring::credentials::resolve_secret` for the one
    /// remaining override (ADR-0087's `PIGEON_SECRET_<ALIAS>`).
    pub secret_key: String,
    /// Alias of the encryption key this bucket encrypts with by default
    /// (ADR-0027). `None` means no default -- every job run gets asked
    /// explicitly with no bucket-level nudge either way.
    #[serde(default)]
    pub encryption_key_alias: Option<String>,
}

impl crate::core::keyring::KeyringEntry for BucketConfig {
    fn alias(&self) -> &str {
        &self.alias
    }
    fn kind(&self) -> &'static str {
        "bucket"
    }
    fn detail(&self) -> String {
        match &self.encryption_key_alias {
            Some(alias) => format!(
                "{} ({}), encrypts with '{alias}'",
                self.endpoint, self.bucket
            ),
            None => format!("{} ({})", self.endpoint, self.bucket),
        }
    }
}