Documentation
¶
Overview ¶
Package helm provides utilities for working with Helm charts and rendered manifests. It includes functions for extracting container images from Kubernetes manifests and injecting labels into resources for release tracking.
Index ¶
Constants ¶
const ( // AppLabelKey is the label key used to identify which application // owns a Kubernetes resource. This enables querying all resources // belonging to a specific application. AppLabelKey = "agent.flightctl.io/app" )
Variables ¶
This section is empty.
Functions ¶
func AppNamespace ¶
func ExtractImagesFromManifests ¶
ExtractImagesFromManifests parses Kubernetes manifests and returns all container image references. It handles multi-document YAML and extracts images from Pods, Deployments, StatefulSets, DaemonSets, ReplicaSets, Jobs, and CronJobs.
func SanitizeReleaseName ¶
SanitizeReleaseName combines a chart name and version into a valid Helm release name. It lowercases the input, replaces invalid characters with hyphens, removes consecutive hyphens, trims leading/trailing hyphens, and truncates to 53 characters.
Types ¶
type Labeler ¶
type Labeler struct {
// contains filtered or unexported fields
}
Labeler injects labels into Kubernetes manifests using kubectl kustomize. It leverages kustomize's built-in label transformer which automatically handles all Kubernetes resource types and their pod templates.
func NewLabeler ¶
func NewLabeler(kube *client.Kube, readWriter fileio.ReadWriter) *Labeler
NewLabeler creates a new Labeler that uses kubectl kustomize to inject labels.
func (*Labeler) InjectLabels ¶
func (l *Labeler) InjectLabels(ctx context.Context, input io.Reader, output io.Writer, labels map[string]string) error
InjectLabels reads multi-document YAML from input, injects the provided labels into each Kubernetes resource using kustomize, and writes the modified YAML to output.
This function is designed to be used as a Helm post-renderer. Helm pipes rendered templates through the post-renderer before applying them to the cluster.
Labels are injected using kustomize's label transformer with:
- includeSelectors: false (avoids modifying immutable selectors)
- includeTemplates: true (ensures pods inherit labels from their controllers)
This approach automatically handles all Kubernetes resource types including Deployments, StatefulSets, DaemonSets, Jobs, CronJobs, and any future types.