Skip to main content

gen_helm/
invariants.rs

1//! Invariants over the helm `BuildSpec`. Implements
2//! `gen_types::Invariants` so cse-lint + gen confirm can call into
3//! the adapter uniformly.
4
5use serde::{Deserialize, Serialize};
6
7use crate::build_spec::BuildSpec;
8
9#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
10#[serde(tag = "rule", rename_all = "kebab-case")]
11pub enum Violation {
12    StaleSchemaVersion { found: u32, expected: u32 },
13    // TODO: ecosystem-specific violations.
14}
15
16pub fn check(spec: &BuildSpec) -> Vec<Violation> {
17    let mut out = Vec::new();
18    if spec.version < crate::build_spec::SCHEMA_VERSION {
19        out.push(Violation::StaleSchemaVersion {
20            found: spec.version,
21            expected: crate::build_spec::SCHEMA_VERSION,
22        });
23    }
24    out
25}
26
27pub struct HelmInvariants;
28
29impl gen_types::Invariants for HelmInvariants {
30    type Spec = BuildSpec;
31    type Violation = Violation;
32    fn check(spec: &Self::Spec) -> Vec<Self::Violation> {
33        check(spec)
34    }
35}