helm_rs/lib.rs
1//! Typed Rust API for [Helm](https://helm.sh) 4.
2//!
3//! helm-rs drives Helm; it never reimplements Helm's engine. Everything Helm defines by a file
4//! format or data (charts, values, schemas, release records, rendered manifests) is read natively
5//! in Rust. Everything defined by Helm's behaviour (rendering, coalescing values, dependencies,
6//! hooks, install, upgrade, wait) goes through a [`Backend`].
7//!
8//! The backend is a type parameter of [`Helm`], chosen statically; each backend sits behind its
9//! own Cargo feature:
10//!
11//! - `cli` (default): [`cli::Cli`] runs the `helm` binary, Helm 4 only.
12//! - `mock`: [`mock::Mock`], a scriptable backend for tests.
13//! - `kube`: native reads that need a cluster connection ([`release::store`]).
14
15//!
16//! See [`cli::Cli`] for a `no_run` example against a real Helm and [`mock::Mock`] for a
17//! runnable one.
18//!
19//! # Building commands
20//!
21//! Every command in [`command`] has a builder derived with [`bon`](https://bon-rs.com). The
22//! arguments Helm requires go to `builder(...)`, so leaving one out does not compile; each flag
23//! is a setter, with `maybe_<flag>` taking an `Option` and `&str` accepted wherever a `String` or
24//! a path is stored. Repeated flags have a setter for the whole list and one for a single item.
25//! `Command::new(...)` is the same command with every flag left to Helm.
26//!
27//! ```no_run
28//! # async fn demo() -> helm_rs::Result<()> {
29//! use std::time::Duration;
30//!
31//! use helm_rs::command::{ChartPathOptions, ChartRef, Install, ReleaseName, WaitStrategy};
32//! use helm_rs::{Helm, Values};
33//!
34//! let helm = Helm::detect().await?.with_namespace("prod");
35//! let install = Install::builder(
36//! ReleaseName::Named("web".to_owned()),
37//! ChartRef::Repo("charts/web".to_owned()),
38//! )
39//! .chart_path(ChartPathOptions::builder().version("^2.0.0").build())
40//! .values(Values::new().set("replicas", 3))
41//! .create_namespace(true)
42//! .label("team", "web")
43//! .wait(WaitStrategy::Watcher)
44//! .timeout(Duration::from_secs(300))
45//! .build();
46//! let release = helm.run(install).await?;
47//!
48//! println!("{}", release.name);
49//! # Ok(()) }
50//! ```
51//!
52//! # Loading charts
53//!
54//! [`Chart::fetch`] loads a chart from wherever it lives: a path natively, a repository, URL or
55//! `oci://` chart through `helm pull` into a temporary directory that is removed afterwards.
56//!
57//! ```no_run
58//! # async fn demo() -> helm_rs::Result<()> {
59//! use helm_rs::command::{ChartPathOptions, ChartRef};
60//! use helm_rs::{Chart, Helm};
61//!
62//! let helm = Helm::detect().await?;
63//! let options = ChartPathOptions::builder().version("1.2.3").build();
64//! let chart = Chart::fetch(&helm, &ChartRef::Repo("charts/web".into()), &options).await?;
65//!
66//! println!("{}", chart.name());
67//! # Ok(()) }
68//! ```
69
70mod error;
71mod go_json;
72
73pub mod backend;
74pub mod chart;
75pub mod command;
76pub mod helm;
77pub mod manifest;
78pub mod options;
79pub mod release;
80pub mod repo;
81pub mod schema;
82pub mod values;
83pub mod version;
84
85#[cfg(feature = "cli")]
86pub mod cli;
87#[cfg(feature = "mock")]
88pub mod mock;
89
90pub use backend::{Backend, Command, Execute};
91pub use chart::Chart;
92#[cfg(feature = "cli")]
93pub use cli::Cli;
94pub use error::{Error, Result};
95pub use helm::Helm;
96pub use manifest::Manifest;
97pub use options::{GlobalOptions, Secret};
98pub use release::Release;
99pub use values::Values;