Documentation
¶
Index ¶
- Constants
- func IsHelmChart(unitLabels map[string]string) bool
- func LoadChart(src *HelmSource) (*chart.Chart, error)
- func MergeValues(valuesFiles []string, setValues []string) (map[string]any, error)
- func NamespaceUnitSlug(namespace, componentSlug string) string
- func UnitSlugForPath(path, prefix string) string
- type GenerateResult
- type GeneratedUnit
- type HelmMetadata
- type HelmSource
- type HelmSourceChart
- type HelmSourceMetadata
- type HelmSourceRelease
- type HelmSourceSpec
- type HelmSourceStatus
Constants ¶
const ( HelmChartLabel = "HelmChart" // Chart name from Chart.yaml metadata.Name HelmReleaseLabel = "HelmRelease" // Release name specified by user HelmChartAPIVersionLabel = "HelmChartAPIVersion" // Chart API version from Chart.yaml metadata.APIVersion (e.g., "v2") HelmChartVersionLabel = "HelmChartVersion" // Chart version from Chart.yaml metadata.Version (semver) HelmAppVersionLabel = "HelmAppVersion" // Application version from Chart.yaml metadata.AppVersion )
Helm label constants All label values are sourced from Chart.yaml metadata
const ( // HelmSourceAPIVersion is the apiVersion of the HelmSource document. HelmSourceAPIVersion = "confighub.com/v1alpha1" // HelmSourceKind is the kind of the HelmSource document. HelmSourceKind = "HelmSource" // PlaceholderNamespace is rendered into the base variant when no release // namespace is specified; deployments replace it via set-namespace. PlaceholderNamespace = "confighubplaceholder" )
Variables ¶
This section is empty.
Functions ¶
func IsHelmChart ¶
IsHelmChart determines if a unit is a Helm chart by checking for all required Helm metadata labels. A unit is considered a Helm chart only if it has ALL required Helm labels set with non-empty values. These labels are set by 'cub helm install' and serve as the authoritative indicator. Required labels: HelmRelease, HelmChart, HelmChartVersion, HelmChartAPIVersion
func LoadChart ¶ added in v0.1.98
func LoadChart(src *HelmSource) (*chart.Chart, error)
LoadChart locates and loads the chart a HelmSource refers to: an oci:// reference, a local path, or a chart name resolved against spec.chart.repo. The version constraint from spec.chart.version is applied during resolution.
func MergeValues ¶ added in v0.1.98
MergeValues loads and merges Helm values from files and --set expressions with standard Helm precedence: defaults < file1 < file2 < ... < --set.
func NamespaceUnitSlug ¶ added in v0.1.98
NamespaceUnitSlug names the synthesized Namespace unit: <namespace>-ns, or <component>-ns when the namespace is the placeholder.
func UnitSlugForPath ¶ added in v0.1.98
UnitSlugForPath derives a unit slug from a chart-relative file path: the chart-name segment and any "templates" or "charts" segments are dropped, the remaining segments are joined with "-", and the file extension is stripped. For example templates/rbac/role.yaml -> rbac-role, crds/foo.yaml -> crds-foo, charts/postgres/templates/ss.yaml -> postgres-ss. The prefix, when non-empty, is prepended with a "-".
Types ¶
type GenerateResult ¶ added in v0.1.98
type GenerateResult struct {
Units []GeneratedUnit
// UnitLabels are the Helm metadata labels to stamp on every generated unit.
UnitLabels map[string]string
// ResolvedVersion is the concrete chart version that was rendered.
ResolvedVersion string
AppVersion string
// DroppedHooks describes hook manifests omitted from the output, for
// reporting to the user.
DroppedHooks []string
// SkippedCRDFiles lists crds/ files omitted due to spec.skipCRDs, for
// reporting to the user.
SkippedCRDFiles []string
}
GenerateResult is the rendered output of one HelmSource.
func Generate ¶ added in v0.1.98
func Generate(chrt *chart.Chart, src *HelmSource, componentSlug string) (*GenerateResult, error)
Generate renders the chart per the HelmSource and groups the output into units by source file. Rendering is entirely client-side: hooks are dropped unless spec.includeHooks is set, lookup returns nothing, and capabilities are Helm's defaults, not a cluster's. componentSlug names the synthesized Namespace unit when the release namespace is the placeholder.
type GeneratedUnit ¶ added in v0.1.98
type GeneratedUnit struct {
// Slug is the unit slug, derived from the chart-relative source path and
// the HelmSource's unit prefix.
Slug string
// Content is the unit's YAML data.
Content string
// Source is the chart-relative path the unit was generated from, for
// reporting. Empty for the synthesized Namespace unit.
Source string
}
GeneratedUnit is one unit of rendered configuration destined for the base variant space.
type HelmMetadata ¶
type HelmMetadata struct {
ReleaseName string
ChartName string
ChartAPIVersion string
ChartVersion string
AppVersion string
}
HelmMetadata represents Helm chart metadata stored in unit labels
func ExtractHelmMetadata ¶
func ExtractHelmMetadata(unitLabels map[string]string, unitSlug string) *HelmMetadata
ExtractHelmMetadata extracts Helm chart metadata from unit labels. Unit labels are set by 'cub helm install' and contain authoritative Helm metadata. If a label is not found, it uses the provided default value or a standard default.
Parameters:
- unitLabels: Map of unit labels containing Helm metadata
- unitSlug: The unit slug to use as default for ReleaseName if not found in labels
Returns:
- *HelmMetadata: Extracted Helm metadata with defaults applied where necessary
type HelmSource ¶ added in v0.1.98
type HelmSource struct {
APIVersion string `json:"apiVersion"`
Kind string `json:"kind"`
Metadata HelmSourceMetadata `json:"metadata"`
Spec HelmSourceSpec `json:"spec"`
Status HelmSourceStatus `json:"status,omitempty"`
}
HelmSource is the KRM-shaped document stored in a helm source space unit. One HelmSource describes one Helm release: which chart to render, with which values, and how the rendered output maps to units in the base variant space. It is the source of truth for upgrades — nothing about a release lives only on a command line.
func ParseHelmSource ¶ added in v0.1.98
func ParseHelmSource(data []byte) (*HelmSource, error)
ParseHelmSource parses and validates a HelmSource document.
func (*HelmSource) Marshal ¶ added in v0.1.98
func (s *HelmSource) Marshal() ([]byte, error)
Marshal serializes the HelmSource document to YAML.
func (*HelmSource) RenderNamespace ¶ added in v0.1.98
func (s *HelmSource) RenderNamespace() string
RenderNamespace returns the namespace used during rendering: the release namespace, or the placeholder when none is specified.
type HelmSourceChart ¶ added in v0.1.98
type HelmSourceChart struct {
// Ref locates the chart: an oci:// reference, a local path, or a chart
// name resolved against Repo.
Ref string `json:"ref"`
// Repo is a classic chart repository URL, used when Ref is a bare chart name.
Repo string `json:"repo,omitempty"`
// Version is the chart version constraint as given by the user (exact or range).
Version string `json:"version,omitempty"`
}
type HelmSourceMetadata ¶ added in v0.1.98
type HelmSourceMetadata struct {
Name string `json:"name"`
}
type HelmSourceRelease ¶ added in v0.1.98
type HelmSourceSpec ¶ added in v0.1.98
type HelmSourceSpec struct {
Chart HelmSourceChart `json:"chart"`
Release HelmSourceRelease `json:"release"`
// CreateNamespace synthesizes a Namespace unit for the release namespace,
// mirroring helm install --create-namespace. Synthesis is skipped when the
// rendered output already contains a Namespace resource with that name.
CreateNamespace bool `json:"createNamespace,omitempty"`
// UnitPrefix namespaces the generated unit slugs in the base space. Empty
// is allowed for exactly one HelmSource per source space.
UnitPrefix string `json:"unitPrefix,omitempty"`
IncludeHooks bool `json:"includeHooks,omitempty"`
SkipCRDs bool `json:"skipCRDs,omitempty"`
// Values are the fully merged user-supplied values.
Values map[string]any `json:"values,omitempty"`
}
type HelmSourceStatus ¶ added in v0.1.98
type HelmSourceStatus struct {
// ResolvedVersion is the concrete chart version the constraint resolved to.
ResolvedVersion string `json:"resolvedVersion,omitempty"`
AppVersion string `json:"appVersion,omitempty"`
}
HelmSourceStatus records render outcomes so regeneration is reproducible.