Skip to main content

gen_helm/
adapter.rs

1//! `HelmAdapter` — gen-helm's implementation of the canonical
2//! `gen_types::Adapter` trait. Stub-level today; every verb
3//! returns `Unsupported` until the helm-side parser lands.
4
5use std::path::PathBuf;
6
7use gen_types::{
8    Adapter, AdapterCtx, AdapterError, AdapterResult, ConfirmReport, DiffRef, DiffReport,
9    LockOutcome, Plan, PlanIntent, Sbom, SbomFormat,
10};
11
12pub struct HelmAdapter;
13
14impl Adapter for HelmAdapter {
15    fn name(&self) -> &'static str {
16        "helm"
17    }
18    fn manifest_files(&self) -> &'static [&'static str] {
19        &["Chart.yaml"]
20    }
21
22    fn lock(&self, _ctx: &AdapterCtx) -> AdapterResult<LockOutcome> {
23        Err(AdapterError::Unsupported(
24            "helm lock not implemented".into(),
25        ))
26    }
27
28    fn build(&self, _ctx: &AdapterCtx) -> AdapterResult<gen_types::AdapterBuildSpec> {
29        Err(AdapterError::Unsupported(
30            "helm build not implemented".into(),
31        ))
32    }
33
34    fn plan(&self, _ctx: &AdapterCtx, _intent: &PlanIntent) -> AdapterResult<Plan> {
35        Err(AdapterError::Unsupported(
36            "helm plan not implemented".into(),
37        ))
38    }
39
40    fn confirm(&self, _ctx: &AdapterCtx) -> AdapterResult<ConfirmReport> {
41        Err(AdapterError::Unsupported(
42            "helm confirm not implemented".into(),
43        ))
44    }
45
46    fn diff(&self, _ctx: &AdapterCtx, _against: &DiffRef) -> AdapterResult<DiffReport> {
47        Err(AdapterError::Unsupported(
48            "helm diff not implemented".into(),
49        ))
50    }
51
52    fn sbom(&self, _ctx: &AdapterCtx, _format: SbomFormat) -> AdapterResult<Sbom> {
53        Err(AdapterError::Unsupported(
54            "helm sbom not implemented".into(),
55        ))
56    }
57
58    fn quirks_registry(&self) -> Vec<gen_types::AdapterQuirkEntry> {
59        use gen_types::QuirkRegistry;
60        <crate::quirks::HelmQuirks as QuirkRegistry>::registry()
61            .into_iter()
62            .map(|(p, qs)| gen_types::AdapterQuirkEntry {
63                package: p.to_string(),
64                quirks: qs
65                    .into_iter()
66                    .filter_map(|q| serde_json::to_value(&q).ok())
67                    .collect(),
68            })
69            .collect()
70    }
71
72    fn dispatcher_reflection(&self) -> Vec<gen_types::DispatcherVariant> {
73        use gen_types::TypedDispatcher;
74        <crate::quirks::HelmQuirk as TypedDispatcher>::variant_fields()
75            .into_iter()
76            .map(|(kind, fields)| gen_types::DispatcherVariant {
77                kind: kind.to_string(),
78                fields: fields.into_iter().map(str::to_string).collect(),
79            })
80            .collect()
81    }
82}
83
84pub fn ctx_for(workspace_root: PathBuf) -> AdapterCtx {
85    AdapterCtx {
86        workspace_root,
87        target: None,
88    }
89}
90
91// Distributed-slice registration. gen-cli discovers this adapter
92// at link time via the inventory iter — no per-adapter edit to
93// gen-cli when this crate ships.
94inventory::submit! {
95    gen_types::AdapterRegistration {
96        make: || Box::new(HelmAdapter),
97        name: "helm",
98    }
99}