helm-rs 0.1.2

Typed Rust API for Helm 4: swappable backends, native chart, values and release reading
Documentation

helm-rs

A typed Rust API for Helm 4.

helm-rs drives Helm and never reimplements its engine. Anything Helm defines by a file format or data is read natively in Rust:

  • charts (directories and archives), .helmignore, archive digests and a content digest of a loaded chart;
  • values schemas, with validation;
  • release records, including reading them straight from the cluster;
  • rendered manifests and repository indexes;
  • Helm-compatible version constraints.

Anything defined by Helm's behaviour goes through a backend: rendering, coalescing values, dependencies, hooks, and install, upgrade and wait.

use helm_rs::command::{ChartRef, Install, ReleaseName};
use helm_rs::{Helm, Values};

#[tokio::main]
async fn main() -> helm_rs::Result<()> {
    let helm = Helm::detect().await?.with_namespace("prod");
    let install = Install::builder(
        ReleaseName::Named("web".to_owned()),
        ChartRef::Repo("charts/web".to_owned()),
    )
    .values(Values::new().set("replicas", 3))
    .create_namespace(true)
    .label("team", "web")
    .build();
    let release = helm.run(install).await?;

    println!("{}", release.name);

    Ok(())
}

Features

Feature What it adds
cli (default) Cli, the backend that runs the helm binary (Helm 4.0 or newer)
mock Mock, a scriptable backend for testing code built on helm-rs
kube Native reads that need a cluster: release storage and typed manifest objects
schema-remote-refs Resolve http(s):// and file:// $refs in values schemas, as Helm does

The backend is a type parameter of Helm<B>, so the choice is made at compile time. A command a backend does not support is a compile error, not a runtime one.

Coverage

Every command and flag of the Helm 4.3 CLI that a program can drive is a typed command (completion and help are excluded). docs/cli-coverage.md tracks each flag.

Secrets never reach the command line:

  • the kube token travels in HELM_KUBETOKEN;
  • registry and repository passwords go through stdin or a private 0600 temporary config;
  • values given from Rust are written to 0600 temporary files.

Tests

cargo nextest run --all-features runs the pure tests. The tests that need the real helm binary, an OCI registry or a kind cluster are ignored by default; tests/README.md says how to run them.

License

Licensed under either of Apache License, Version 2.0 or MIT license, at your option.

Releasing

Releases use release-plz. Every push to master opens or updates a release PR with the next version and changelog. The version follows the conventional commits and a cargo-semver-checks run against the last published version, so a breaking API change can't ship as a patch. Merging the release PR publishes that version to crates.io and creates the v<version> tag and the GitHub release.

  • Release branches: work to try before it ships collects on a release/<name> branch, named after what it brings (release/chart-digest), or after its version when that is decided (release/1.0.0, for a major release). It merges into master like any PR.
  • Pre-release: run the Release workflow from the Actions tab on the release branch with a label (rc by default). It publishes the branch as <version>-rc.<n>, such as 0.2.0-rc.1, from a pre-release/v0.2.0-rc.1 branch, with a tag and a GitHub pre-release. The version is the branch's own when its name is one, otherwise the one the release PR would propose for it. Neither the release branch nor master ever holds a pre-release version.

.github/workflows/release.yaml lists the secrets the workflow needs.