helm-rs 0.1.0

Typed Rust API for Helm 4: swappable backends, native chart, values and release reading
Documentation
//! The one definition of the fields `install`, `upgrade` and `template` have in common
//! (`addInstallFlags`, `pkg/cmd/install.go`).

/// Declares a command struct made of its own `required` fields (the arguments of
/// `builder(...)` and `new(...)`), its own `collections` (repeated flags, each with a builder
/// setter for the whole collection and one for a single item), its own `flags` and the fields every
/// install-like command shares, with the derived builder (`$builder`, in the state module
/// `$state`) of all of them.
macro_rules! release_command {
    (
        $(#[$meta:meta])*
        $name:ident, $builder:ident, $state:ident {
            required { $($(#[$rmeta:meta])* $rfield:ident: $rty:ty,)* }
            collections { $($efield:ident / $esingle:ident: $eitem:ty, $eflag:literal, $ewhat:literal;)* }
            flags { $($(#[$fmeta:meta])* $field:ident: $ty:ty,)* }
        }
    ) => {
        $(#[$meta])*
        #[derive(Debug, Clone, PartialEq, ::bon::Builder)]
        #[builder(on(String, into), on(PathBuf, into), on(bool, default))]
        #[allow(clippy::struct_excessive_bools, reason = "one field per Helm flag")]
        pub struct $name {
            $(#[builder(start_fn)] $(#[$rmeta])* pub $rfield: $rty,)*
            /// The `CHART` argument.
            #[builder(start_fn)]
            pub chart: $crate::command::ChartRef,
            /// Flag `--labels`: labels for the release record (on `upgrade` they are merged into
            /// the release's and the value `null` removes a label).
            #[builder(field)]
            pub labels: ::std::collections::BTreeMap<String, String>,
            /// Flag `--post-renderer-args`, repeated: arguments for the post-renderer.
            #[builder(field)]
            pub post_renderer_args: Vec<String>,
            $(
                #[doc = concat!("Flag `", $eflag, "`, repeated: ", $ewhat, ".")]
                #[builder(field)]
                pub $efield: Vec<$eitem>,
            )*
            /// Where to find the chart and how to authenticate.
            #[builder(default)]
            pub chart_path: $crate::command::ChartPathOptions,
            /// Flags `-f`, `--set`, `--set-string`, `--set-file`, `--set-json` and `--set-literal`.
            #[builder(default)]
            pub values: $crate::values::Values,
            $($(#[$fmeta])* pub $field: $ty,)*
            /// Flag `--create-namespace`: create the release namespace if it is missing (`upgrade`
            /// only with `--install`).
            pub create_namespace: bool,
            /// Flag `--dependency-update`: fetch missing chart dependencies first.
            pub dependency_update: bool,
            /// Flag `--description`: a custom release description.
            pub description: Option<String>,
            /// Flag `--devel`: also consider development versions (ignored when a version is set).
            pub devel: bool,
            /// Flag `--disable-openapi-validation`: do not validate against the Kubernetes `OpenAPI`
            /// schema.
            pub disable_openapi_validation: bool,
            /// Flag `--dry-run`.
            pub dry_run: Option<$crate::command::DryRun>,
            /// Flag `--enable-dns`: allow DNS lookups while rendering.
            pub enable_dns: bool,
            /// Flags `--force-replace` and `--force-conflicts`.
            pub force: Option<$crate::command::Force>,
            /// Flag `--no-hooks`: skip hooks.
            pub no_hooks: bool,
            /// Flag `--post-renderer`: the name of a post-renderer plugin.
            pub post_renderer: Option<String>,
            /// Flag `--rollback-on-failure`: undo the operation when it fails (waits with `watcher`
            /// unless `wait` says otherwise).
            pub rollback_on_failure: bool,
            /// Flag `--skip-crds`: do not install CRDs (`upgrade` only with `--install`).
            pub skip_crds: bool,
            /// Flag `--skip-schema-validation`: do not validate the values against the chart's
            /// schema.
            pub skip_schema_validation: bool,
            /// Flag `--take-ownership`: adopt existing resources without Helm's ownership
            /// annotations.
            pub take_ownership: bool,
            /// Flag `--timeout` for any single Kubernetes operation (Helm's default is five
            /// minutes).
            pub timeout: Option<::std::time::Duration>,
            /// Flag `--wait` (Helm's default is `hookOnly`).
            pub wait: Option<$crate::command::WaitStrategy>,
            /// Flag `--wait-for-jobs`: with a wait, also wait for Jobs to complete.
            pub wait_for_jobs: bool,
        }

        $crate::command::builder_collections! {
            $builder, $state;
            map labels / label: String, "flag `--labels`", "labels for the release record";
            vec post_renderer_args / post_renderer_arg: String, "repeated flag `--post-renderer-args`",
                "arguments for the post-renderer";
            $(vec $efield / $esingle: $eitem, concat!("repeated flag `", $eflag, "`"), $ewhat;)*
        }
    };
}

pub(crate) use release_command;