helm-schema-cli 0.0.4

Generate an accurate JSON schema for any helm chart
Documentation
//! Semantic assertions for the datadog chart: `agents.image.tag` flows
//! through `toString | trimSuffix "-jmx"` pipelines (conditions and local
//! assignments), where the conversion runs BEFORE the string consumer, so
//! any input type renders. Values validation and the full-schema pin live
//! in `chart_corpus.rs`.

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 datadog_image_tag_accepts_non_strings() -> eyre::Result<()> {
    let schema = schema_roundtrip::generate_chart_schema_for_path("datadog")?;
    let validator = jsonschema::validator_for(&schema).expect("schema validator");

    // Cases compose over the chart defaults: helm validates the coalesced
    // document, and the chart navigates hosts these overrides do not touch.
    for tag in [serde_json::json!(7), serde_json::json!("7.68.2")] {
        assert!(
            validator.is_valid(&chart_instances::with_override(
                "datadog",
                serde_json::json!({
                    "agents": { "image": { "tag": tag, "doNotCheckTag": true } }
                })
            )?),
            "toString converts the tag before trimSuffix consumes it: tag={tag}"
        );
    }
    Ok(())
}