helm_rs/schema/generate/options.rs
1//! The options of the generator, mirroring the flags of the helm-schema CLI that change the
2//! generated schema.
3
4use std::collections::BTreeMap;
5
6/// A field of the generated schema that `skip-auto-generation` can leave out.
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
8pub enum SkipField {
9 /// The inferred `type`.
10 Type,
11 /// The `title` defaulting to the key.
12 Title,
13 /// The `description` taken from the comment.
14 Description,
15 /// The automatic `required` entries.
16 Required,
17 /// The `default` taken from the value.
18 Default,
19 /// The `additionalProperties: false` on mappings.
20 AdditionalProperties,
21}
22
23/// The options of helm-schema that change the generated schema (the flags of its CLI).
24#[derive(Debug, Clone, PartialEq, bon::Builder)]
25#[builder(on(String, into), on(bool, default))]
26pub struct GenerateOptions {
27 /// Flag `--keep-full-comment`: keep the whole leading comment instead of cutting at the
28 /// last empty line.
29 pub keep_full_comment: bool,
30 /// Flag `--uncomment`: read comments that hold valid YAML as YAML.
31 pub uncomment: bool,
32 /// Flag `--helm-docs-compatibility-mode`: read helm-docs comments (`# -- ...`).
33 pub helm_docs_compatibility_mode: bool,
34 /// Flag `--dont-strip-helm-docs-prefix`: keep helm-docs `--` prefixes and `@tags` in
35 /// descriptions.
36 pub dont_strip_helm_docs_prefix: bool,
37 /// Flag `--dont-add-global`: do not add the `global` property.
38 pub dont_add_global: bool,
39 /// Flag `--skip-auto-generation`: fields that are not generated by default.
40 #[builder(default)]
41 pub skip_auto_generation: Vec<SkipField>,
42 /// Flag `--no-dependencies`: do not merge subcharts into the schema.
43 pub no_dependencies: bool,
44 /// Flag `--dependencies-filter`: merge only the dependencies with these names (all when
45 /// empty).
46 #[builder(default)]
47 pub dependencies_filter: Vec<String>,
48 /// Flag `--skip-dependencies-schema-validation`: remove dependencies from `required` and let
49 /// them accept additional properties.
50 pub skip_dependencies_schema_validation: bool,
51 /// Flag `--keep-existing-dep-schemas`: use the `values.schema.json` a subchart already has
52 /// instead of generating one from its values.
53 pub keep_existing_dep_schemas: bool,
54 /// The files a relative `$ref` can name, by path relative to the chart root, with their
55 /// content. [`super::generate_chart`] adds the files of the chart.
56 #[builder(default)]
57 pub files: BTreeMap<String, String>,
58}
59
60impl Default for GenerateOptions {
61 fn default() -> Self {
62 Self::builder().build()
63 }
64}