sherpack_convert/
lib.rs

1#![allow(clippy::collapsible_if)]
2#![allow(clippy::or_fun_call)]
3
4//! Sherpack Convert - Helm chart to Sherpack pack converter
5//!
6//! This crate provides functionality to convert Helm charts to Sherpack packs,
7//! transforming Go templates into idiomatic Jinja2 syntax.
8//!
9//! # Philosophy
10//!
11//! Sherpack Convert prioritizes **Jinja2 elegance** over Helm compatibility.
12//! Instead of replicating Go template's quirky function-based syntax, we convert
13//! to natural Jinja2 patterns:
14//!
15//! | Helm (Go template)              | Sherpack (Jinja2)                |
16//! |---------------------------------|----------------------------------|
17//! | `{{ index .Values.list 0 }}`    | `{{ values.list[0] }}`           |
18//! | `{{ add 1 2 }}`                 | `{{ 1 + 2 }}`                    |
19//! | `{{ ternary "a" "b" .X }}`      | `{{ "a" if x else "b" }}`        |
20//! | `{{ printf "%s-%s" a b }}`      | `{{ a ~ "-" ~ b }}`              |
21//! | `{{ coalesce .A .B "c" }}`      | `{{ a or b or "c" }}`            |
22//!
23//! # Example
24//!
25//! ```no_run
26//! use std::path::Path;
27//! use sherpack_convert::{convert, ConvertOptions, convert_with_options};
28//!
29//! // Simple conversion
30//! let result = convert(
31//!     Path::new("./my-helm-chart"),
32//!     Path::new("./my-sherpack-pack"),
33//! ).unwrap();
34//!
35//! println!("Converted {} files", result.converted_files.len());
36//!
37//! // Check for unsupported features
38//! for warning in &result.warnings {
39//!     if warning.severity == sherpack_convert::WarningSeverity::Unsupported {
40//!         println!("Unsupported: {} - {}", warning.pattern, warning.message);
41//!         if let Some(ref suggestion) = warning.suggestion {
42//!             println!("  Alternative: {}", suggestion);
43//!         }
44//!     }
45//! }
46//!
47//! // Conversion with options
48//! let options = ConvertOptions {
49//!     force: true,
50//!     dry_run: false,
51//!     verbose: true,
52//! };
53//!
54//! let result = convert_with_options(
55//!     Path::new("./helm-chart"),
56//!     Path::new("./sherpack-pack"),
57//!     options,
58//! ).unwrap();
59//! ```
60//!
61//! # Unsupported Features
62//!
63//! Some Helm features are intentionally not supported because they are
64//! anti-patterns in a GitOps workflow:
65//!
66//! - **Crypto functions** (`genCA`, `genPrivateKey`, etc.)
67//!   → Use cert-manager or external-secrets
68//! - **Files API** (`.Files.Get`, `.Files.Glob`)
69//!   → Embed content in values.yaml or use ConfigMaps
70//! - **DNS lookups** (`getHostByName`)
71//!   → Use explicit values for deterministic rendering
72//! - **Random functions** (`randAlphaNum`, etc.)
73//!   → Pre-generate values or use external-secrets
74
75pub mod ast;
76pub mod chart;
77pub mod converter;
78pub mod error;
79pub mod macro_processor;
80pub mod parser;
81pub mod transformer;
82pub mod type_inference;
83
84// Re-exports
85pub use converter::{ConversionResult, ConvertOptions, Converter, convert, convert_with_options};
86pub use error::{ConversionWarning, ConvertError, Result, WarningCategory, WarningSeverity};
87pub use type_inference::{InferredType, TypeContext, TypeHeuristics};