Core Engine

The core engine (jhelm-core) handles chart management and the rendering pipeline.

1. Key Classes

  • Engine.java — Main rendering engine that orchestrates template processing

  • Chart.java — Represents a Helm chart with metadata and templates

  • RepoManager.java — Manages Helm chart repositories

2. Rendering Pipeline

The engine handles:

  • Named template collection and caching

  • Subchart rendering with recursion prevention

  • Value merging from chart defaults and user overrides

  • Template context management (Release, Chart, Values, Capabilities, etc.)

3. Implementation Details

  1. Template Rendering: The Engine class creates a new GoTemplate for each render to avoid template accumulation.

  2. Action Classes: Logic for Helm operations is encapsulated in Action classes (e.g., InstallAction, UpgradeAction, RollbackAction, TemplateAction, ShowAction).

  3. Recursion Protection: Stack depth tracking prevents infinite template recursion.

  4. Named Templates: define blocks are collected before rendering begins.

  5. Value Merging: Chart values are merged with user-provided values and release info.

  6. Capabilities: .Capabilities.KubeVersion and .Capabilities.APIVersions are supplied via a Capabilities override. During install/upgrade the engine reads the live server version from the KubeService so version-gated charts render against the real target; when the cluster is unreachable, or for the offline template command, it uses a built-in default (v1.35.0) that the template command can override with --kube-version / --api-versions. Null-valued keys in the coalesced .Values are pruned under the Helm 4 default and kept under jhelm.helm-compatibility=3. Two versions are exposed: .Capabilities.HelmVersion.Version is the Helm compatibility version charts gate on (default v4.3.0, set with jhelm.helm-version; it follows jhelm.helm-compatibility), and .Capabilities.JhelmVersion.Version is the jhelm build that rendered the chart, which is not configurable.

  7. Error Handling: Custom exceptions for parsing, execution, and not-found scenarios.