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