Skip to main content

helm_rs/command/release/
history.rs

1use jiff::Timestamp;
2use serde::Deserialize;
3
4use crate::backend::Command;
5use crate::go_json::omit_zero;
6use crate::release::{Revision, Status};
7
8/// `helm history -o json` (`pkg/cmd/history.go`): the revisions of a release, oldest first.
9#[derive(Debug, Clone, PartialEq, Eq, bon::Builder)]
10#[builder(on(String, into), on(bool, default))]
11pub struct History {
12    /// The `RELEASE_NAME` argument.
13    #[builder(start_fn)]
14    pub release: String,
15    /// Flag `--max`: how many revisions to include (Helm's default is 256).
16    pub max: Option<u32>,
17    /// Flag `--show-rollback-revision`: Helm's table gets a rollback column. It has no effect on
18    /// the JSON, which always carries `rollback_revision`.
19    pub show_rollback_revision: bool,
20}
21
22impl History {
23    /// The history of `release` with every setting left to Helm.
24    #[must_use]
25    pub fn new(release: impl Into<String>) -> Self {
26        Self::builder(release).build()
27    }
28}
29
30impl Command for History {
31    type Output = Vec<HistoryEntry>;
32}
33
34/// One revision in `helm history -o json` (`releaseInfo`, `pkg/cmd/history.go`).
35#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
36pub struct HistoryEntry {
37    /// The revision.
38    pub revision: Revision,
39    /// When the revision was last deployed; `None` for Go's zero time.
40    #[serde(default, with = "omit_zero")]
41    pub updated: Option<Timestamp>,
42    /// The status of the revision.
43    pub status: Status,
44    /// `name-version` of the chart, or `MISSING` when the record has no chart.
45    pub chart: String,
46    /// The chart's application version, or `MISSING`.
47    pub app_version: String,
48    /// The revision this one rolled back to; zero when it is not a rollback.
49    #[serde(default)]
50    pub rollback_revision: Revision,
51    /// The release description.
52    pub description: String,
53}