helm-rs 0.1.0

Typed Rust API for Helm 4: swappable backends, native chart, values and release reading
Documentation
//! The options of the generator, mirroring the flags of the helm-schema CLI that change the
//! generated schema.

use std::collections::BTreeMap;

/// A field of the generated schema that `skip-auto-generation` can leave out.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum SkipField {
    /// The inferred `type`.
    Type,
    /// The `title` defaulting to the key.
    Title,
    /// The `description` taken from the comment.
    Description,
    /// The automatic `required` entries.
    Required,
    /// The `default` taken from the value.
    Default,
    /// The `additionalProperties: false` on mappings.
    AdditionalProperties,
}

/// The options of helm-schema that change the generated schema (the flags of its CLI).
#[derive(Debug, Clone, PartialEq, bon::Builder)]
#[builder(on(String, into), on(bool, default))]
pub struct GenerateOptions {
    /// Flag `--keep-full-comment`: keep the whole leading comment instead of cutting at the
    /// last empty line.
    pub keep_full_comment: bool,
    /// Flag `--uncomment`: read comments that hold valid YAML as YAML.
    pub uncomment: bool,
    /// Flag `--helm-docs-compatibility-mode`: read helm-docs comments (`# -- ...`).
    pub helm_docs_compatibility_mode: bool,
    /// Flag `--dont-strip-helm-docs-prefix`: keep helm-docs `--` prefixes and `@tags` in
    /// descriptions.
    pub dont_strip_helm_docs_prefix: bool,
    /// Flag `--dont-add-global`: do not add the `global` property.
    pub dont_add_global: bool,
    /// Flag `--skip-auto-generation`: fields that are not generated by default.
    #[builder(default)]
    pub skip_auto_generation: Vec<SkipField>,
    /// Flag `--no-dependencies`: do not merge subcharts into the schema.
    pub no_dependencies: bool,
    /// Flag `--dependencies-filter`: merge only the dependencies with these names (all when
    /// empty).
    #[builder(default)]
    pub dependencies_filter: Vec<String>,
    /// Flag `--skip-dependencies-schema-validation`: remove dependencies from `required` and let
    /// them accept additional properties.
    pub skip_dependencies_schema_validation: bool,
    /// Flag `--keep-existing-dep-schemas`: use the `values.schema.json` a subchart already has
    /// instead of generating one from its values.
    pub keep_existing_dep_schemas: bool,
    /// The files a relative `$ref` can name, by path relative to the chart root, with their
    /// content. [`super::generate_chart`] adds the files of the chart.
    #[builder(default)]
    pub files: BTreeMap<String, String>,
}

impl Default for GenerateOptions {
    fn default() -> Self {
        Self::builder().build()
    }
}