helm-rs 0.1.0

Typed Rust API for Helm 4: swappable backends, native chart, values and release reading
Documentation
//! The value types of the flags several release commands share.

/// The `--dry-run` strategies (`addDryRunFlag`, `pkg/cmd/helpers.go`). The bare `--dry-run` and
/// the boolean forms are deprecated legacy spellings of [`DryRun::Client`] and [`DryRun::None`]
/// and are not modelled.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DryRun {
    /// `none`: run for real (Helm's default).
    None,
    /// `client`: render and simulate without contacting the cluster.
    Client,
    /// `server`: simulate on the API server, which needs a cluster connection.
    Server,
}

impl DryRun {
    /// The flag value.
    #[must_use]
    pub fn as_str(self) -> &'static str {
        match self {
            Self::None => "none",
            Self::Client => "client",
            Self::Server => "server",
        }
    }
}

/// The `--wait` strategies (`waitValue`, `pkg/cmd/flags.go`). Helm's default when the flag is
/// omitted is `hookOnly`; the bare `--wait` means `watcher`, so the CLI backend always writes the
/// explicit `--wait=<strategy>` form.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum WaitStrategy {
    /// `watcher`: wait until every resource reports ready, using status watchers.
    Watcher,
    /// `hookOnly`: wait for hooks only, not for the release's resources.
    HookOnly,
    /// `legacy`: the Helm 3 polling wait.
    Legacy,
}

impl WaitStrategy {
    /// The flag value.
    #[must_use]
    pub fn as_str(self) -> &'static str {
        match self {
            Self::Watcher => "watcher",
            Self::HookOnly => "hookOnly",
            Self::Legacy => "legacy",
        }
    }
}

/// The `--server-side` choice of `upgrade` and `rollback` (a string flag there; `install` has a
/// plain boolean instead).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ServerSide {
    /// `auto`: take the method of the previous release (Helm's default).
    Auto,
    /// `true`: apply objects on the server.
    Enabled,
    /// `false`: apply objects on the client.
    Disabled,
}

impl ServerSide {
    /// The flag value.
    #[must_use]
    pub fn as_str(self) -> &'static str {
        match self {
            Self::Auto => "auto",
            Self::Enabled => "true",
            Self::Disabled => "false",
        }
    }
}

/// How to resolve a conflict with live objects. Helm rejects `--force-replace` together with
/// `--force-conflicts`, so the two are one choice.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Force {
    /// `--force-replace`: replace the objects instead of patching them.
    Replace,
    /// `--force-conflicts`: with server-side apply, take over fields owned by other managers.
    Conflicts,
}

/// Which values an upgrade starts from. Helm documents `--reset-values` as winning over
/// `--reuse-values`, which wins over `--reset-then-reuse-values`, so only the winner is modelled.
/// Without a mode, Helm starts from the chart's values.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ValuesMode {
    /// `--reset-values`: the values built into the chart.
    Reset,
    /// `--reuse-values`: the last release's values.
    Reuse,
    /// `--reset-then-reuse-values`: the chart's values, then the last release's, then the
    /// overrides given now.
    ResetThenReuse,
}

/// How the release of an install is named. Helm refuses a name together with `--generate-name`
/// or `--name-template`, so the three are one choice.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ReleaseName {
    /// The `NAME` argument.
    Named(String),
    /// `--generate-name`: Helm derives a name from the chart and the time.
    Generated,
    /// `--name-template`: Helm renders the name from this template.
    Template(String),
}