helm-rs 0.1.2

Typed Rust API for Helm 4: swappable backends, native chart, values and release reading
Documentation
use std::path::PathBuf;

use crate::backend::Command;
use crate::options::Secret;

/// `helm registry login`: stores credentials for an OCI registry in the registry config.
///
/// The password or identity token reaches Helm through `--password-stdin` (never argv). Without a
/// password Helm prompts on a terminal, which a backend run does not have, so it fails.
#[derive(Debug, Clone, PartialEq, bon::Builder)]
#[builder(
    on(String, into),
    on(PathBuf, into),
    on(Secret, into),
    on(bool, default)
)]
pub struct RegistryLogin {
    /// The registry host (`host`).
    #[builder(start_fn)]
    pub host: String,
    /// Flag `--username` (`-u`); empty with a password means an identity token.
    pub username: Option<String>,
    /// Flag `--password-stdin`: the password or identity token, written to Helm's stdin.
    pub password: Option<Secret>,
    /// Flag `--cert-file`: the SSL client certificate.
    pub cert_file: Option<PathBuf>,
    /// Flag `--key-file`: the SSL client key.
    pub key_file: Option<PathBuf>,
    /// Flag `--ca-file`: the CA bundle that verifies the server.
    pub ca_file: Option<PathBuf>,
    /// Flag `--insecure`: allow connections to a TLS registry without certificates.
    pub insecure: bool,
    /// Flag `--plain-http`: use insecure HTTP connections.
    pub plain_http: bool,
}

impl RegistryLogin {
    /// Logs in to `host` with Helm's defaults.
    #[must_use]
    pub fn new(host: impl Into<String>) -> Self {
        Self::builder(host).build()
    }
}

impl Command for RegistryLogin {
    type Output = ();
}

/// `helm registry logout`: removes the stored credentials of a registry.
#[derive(Debug, Clone, PartialEq, Eq, bon::Builder)]
#[builder(on(String, into))]
pub struct RegistryLogout {
    /// The registry host (`host`).
    #[builder(start_fn)]
    pub host: String,
}

impl RegistryLogout {
    /// Logs out of `host`.
    #[must_use]
    pub fn new(host: impl Into<String>) -> Self {
        Self::builder(host).build()
    }
}

impl Command for RegistryLogout {
    type Output = ();
}