helm-rs 0.1.1

Typed Rust API for Helm 4: swappable backends, native chart, values and release reading
Documentation
use jiff::Timestamp;
use serde::Deserialize;

use crate::backend::Command;
use crate::go_json::omit_zero;
use crate::release::{Revision, Status};

/// `helm history -o json` (`pkg/cmd/history.go`): the revisions of a release, oldest first.
#[derive(Debug, Clone, PartialEq, Eq, bon::Builder)]
#[builder(on(String, into), on(bool, default))]
pub struct History {
    /// The `RELEASE_NAME` argument.
    #[builder(start_fn)]
    pub release: String,
    /// Flag `--max`: how many revisions to include (Helm's default is 256).
    pub max: Option<u32>,
    /// Flag `--show-rollback-revision`: Helm's table gets a rollback column. It has no effect on
    /// the JSON, which always carries `rollback_revision`.
    pub show_rollback_revision: bool,
}

impl History {
    /// The history of `release` with every setting left to Helm.
    #[must_use]
    pub fn new(release: impl Into<String>) -> Self {
        Self::builder(release).build()
    }
}

impl Command for History {
    type Output = Vec<HistoryEntry>;
}

/// One revision in `helm history -o json` (`releaseInfo`, `pkg/cmd/history.go`).
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
pub struct HistoryEntry {
    /// The revision.
    pub revision: Revision,
    /// When the revision was last deployed; `None` for Go's zero time.
    #[serde(default, with = "omit_zero")]
    pub updated: Option<Timestamp>,
    /// The status of the revision.
    pub status: Status,
    /// `name-version` of the chart, or `MISSING` when the record has no chart.
    pub chart: String,
    /// The chart's application version, or `MISSING`.
    pub app_version: String,
    /// The revision this one rolled back to; zero when it is not a rollback.
    #[serde(default)]
    pub rollback_revision: Revision,
    /// The release description.
    pub description: String,
}