helm-schema-cli 0.0.7

Generate an accurate JSON schema for any helm chart
Documentation
//! Semantic assertions for the falco chart: the falcosidekick `rolearn`
//! branch pair. The quote branch (`useirsa=true`, service-account
//! annotation) renders any value, while the b64enc branch (`useirsa=false`,
//! secret data) fails rendering for non-strings — even though the quote
//! branch sits behind the compound guard
//! `or .Values.config.azure.workloadIdentityClientID (and .Values.config.aws.useirsa .Values.config.aws.rolearn)`.
//! 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 falco_rolearn_contract_is_branch_scoped() -> eyre::Result<()> {
    let schema = schema_roundtrip::generate_chart_schema_for_path("falco")?;
    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.
    let instance = |rolearn: serde_json::Value, useirsa: bool| {
        chart_instances::with_override(
            "falco",
            serde_json::json!({
                "falcosidekick": {
                    "enabled": true,
                    "config": { "aws": { "rolearn": rolearn, "useirsa": useirsa } }
                }
            }),
        )
        .expect("compose falco instance")
    };

    assert!(
        validator.is_valid(&instance(serde_json::json!({ "bad": true }), true)),
        "the quoted annotation renders a map when useirsa=true"
    );
    assert!(
        !validator.is_valid(&instance(serde_json::json!({ "bad": true }), false)),
        "the b64enc secret branch fails rendering for a map when useirsa=false"
    );
    for useirsa in [true, false] {
        assert!(
            validator.is_valid(&instance(
                serde_json::json!("arn:aws:iam::1:role/x"),
                useirsa
            )),
            "strings render in both states (useirsa={useirsa})"
        );
    }
    Ok(())
}