1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! 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()
}
}