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
//! Semantic assertions for reloader: the un-spaced pipe idiom
//! (`{{- toYaml .| nindent 6 }}` under `with .Values.reloader.podMonitor.
//! tlsConfig`) must type `tlsConfig` as the `PodMonitor` CRD object. The
//! v0.0.6 grammar absorbed the pipe into the argument and emitted an
//! unsatisfiable "truthy tlsConfig must be null-or-string" clause, so a
//! user setting the map the CRD requires was rejected while `helm template`
//! rendered it fine. Values validation and the full-schema pin live in
//! `chart_corpus.rs`; these behavior assertions keep a future fixture
//! regeneration from silently re-pinning the defect.
use color_eyre::eyre;
#[path = "common/chart_instances.rs"]
mod chart_instances;
#[path = "common/schema_roundtrip.rs"]
mod schema_roundtrip;
#[path = "common/values_yaml.rs"]
mod values_yaml;
#[test]
fn reloader_pod_monitor_tls_config_accepts_the_map_helm_renders() -> eyre::Result<()> {
let schema = schema_roundtrip::generate_chart_schema_for_path("reloader")?;
let validator = jsonschema::validator_for(&schema)?;
// `helm template` renders this overlay byte-identically to the spaced
// `toYaml . | nindent 6` form; the schema must accept it.
let map_instance = chart_instances::with_override(
"reloader",
serde_json::json!({
"reloader": {
"podMonitor": {
"enabled": true,
"tlsConfig": { "insecureSkipVerify": true },
}
}
}),
)?;
let errors: Vec<String> = validator
.iter_errors(&map_instance)
.map(|error| error.to_string())
.collect();
assert!(
errors.is_empty(),
"podMonitor.tlsConfig map must validate: {errors:?}"
);
// A scalar where the CRD requires an object still fails: the fix must
// not degrade the sink typing into "anything goes".
let scalar_instance = chart_instances::with_override(
"reloader",
serde_json::json!({
"reloader": {
"podMonitor": { "enabled": true, "tlsConfig": "text" }
}
}),
)?;
assert!(
!validator.is_valid(&scalar_instance),
"a scalar podMonitor.tlsConfig must still be rejected"
);
Ok(())
}