fluxrenderer

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package fluxrenderer provides functionality for rendering Flux HelmRelease and Kustomization resources to Kubernetes manifests.

Index

Constants

View Source
const (
	// HelmReleaseKind is the kind for Flux HelmRelease resources.
	HelmReleaseKind = "HelmRelease"
	// HelmReleaseAPIVersionPrefix is the API version prefix for Flux HelmRelease.
	HelmReleaseAPIVersionPrefix = "helm.toolkit.fluxcd.io/"

	// HelmChartKind is the kind for Flux HelmChart resources.
	HelmChartKind = "HelmChart"
	// HelmChartAPIVersionPrefix is the API version prefix for Flux HelmChart.
	HelmChartAPIVersionPrefix = "source.toolkit.fluxcd.io/"
)
View Source
const (
	// KustomizationKind is the kind for Flux Kustomization resources.
	KustomizationKind = "Kustomization"
	// KustomizationAPIVersionPrefix is the API version prefix for Flux Kustomization.
	KustomizationAPIVersionPrefix = "kustomize.toolkit.fluxcd.io/"

	// SubstituteAnnotation is the annotation to disable variable substitution.
	SubstituteAnnotation = "kustomize.toolkit.fluxcd.io/substitute"
)
View Source
const DefaultTimeout = 5 * time.Minute

DefaultTimeout is the default timeout for artifact fetching.

Variables

This section is empty.

Functions

func FetchArtifact

func FetchArtifact(ctx context.Context, url, digest string) (string, func(), error)

FetchArtifact downloads an artifact from URL, verifies its digest, and extracts it to a temporary directory. It returns the path to the temporary directory and a cleanup function that should be called to remove the directory when done.

func FindAllDocumentsByKindAndAPIVersion

func FindAllDocumentsByKindAndAPIVersion(docs []*unstructured.Unstructured, kind, apiVersionPrefix string) []*unstructured.Unstructured

FindAllDocumentsByKindAndAPIVersion finds all documents matching the given kind and API version prefix.

Types

type ArtifactSource

type ArtifactSource struct {
	// URL is the HTTP URL to the artifact (chart tgz or kustomize tarball).
	URL string

	// Digest is the SHA256 digest for verification (e.g., "sha256:abc123...").
	Digest string
}

ArtifactSource represents where to fetch the artifact from.

type ParsedDocuments

type ParsedDocuments struct {
	// All unstructured documents
	Documents []*unstructured.Unstructured

	// ConfigMaps keyed by namespace/name
	ConfigMaps map[string]*corev1.ConfigMap

	// Secrets keyed by namespace/name
	Secrets map[string]*corev1.Secret

	// HelmCharts keyed by namespace/name
	HelmCharts map[string]*unstructured.Unstructured
}

ParsedDocuments holds the parsed resources from a multi-document YAML input.

func ParseDocumentsWithResources

func ParseDocumentsWithResources(data []byte) (*ParsedDocuments, error)

ParseDocumentsWithResources parses YAML documents and extracts ConfigMaps, Secrets, and HelmCharts.

type RenderInput

type RenderInput struct {
	// Documents is the multi-document YAML input.
	Documents []byte

	// Options configures rendering behavior.
	Options RenderOptions
}

RenderInput represents the input to the renderer. The input byte slice can contain multiple YAML documents: - The HelmRelease or Kustomization resource (required) - ConfigMaps referenced by ValuesFrom (optional) - Secrets referenced by ValuesFrom (optional) - ConfigMaps/Secrets for PostBuild substitution (optional)

type RenderOptions

type RenderOptions struct {
	// Namespace to use for rendering (defaults to resource namespace).
	Namespace string

	// ReleaseName override for Helm (defaults to HelmRelease name).
	ReleaseName string

	// ArtifactSource specifies where to fetch the chart/kustomize artifact.
	ArtifactSource ArtifactSource

	// Timeout for artifact fetching. Defaults to 5 minutes if not set.
	Timeout time.Duration
}

RenderOptions configures the rendering behavior.

func (RenderOptions) GetTimeout

func (o RenderOptions) GetTimeout() time.Duration

GetTimeout returns the timeout, using DefaultTimeout if not set.

type RenderResult

type RenderResult struct {
	// Manifests is the rendered YAML documents as a byte slice.
	Manifests []byte

	// Revision is the source revision used (chart version or git commit).
	Revision string
}

RenderResult contains the rendered manifests.

func RenderFlux

func RenderFlux(ctx context.Context, input RenderInput) (*RenderResult, error)

RenderFlux renders a Flux HelmRelease or Kustomization to Kubernetes manifests. It automatically detects the resource type and calls the appropriate renderer.

The input can be a multi-document YAML containing: - A HelmRelease or Kustomization resource (required, exactly one) - ConfigMaps/Secrets referenced by ValuesFrom or PostBuild.substituteFrom (optional)

Returns an error if: - No HelmRelease or Kustomization is found - More than one HelmRelease is found - More than one Kustomization is found - Both HelmRelease and Kustomization are found

func RenderHelmRelease

func RenderHelmRelease(ctx context.Context, input RenderInput) (*RenderResult, error)

RenderHelmRelease renders a HelmRelease to Kubernetes manifests. The input can be a multi-document YAML containing: - HelmRelease (required) - ConfigMaps/Secrets referenced by ValuesFrom (optional)

func RenderKustomization

func RenderKustomization(ctx context.Context, input RenderInput) (*RenderResult, error)

RenderKustomization renders a Flux Kustomization to Kubernetes manifests. The input can be a multi-document YAML containing: - Kustomization (required) - ConfigMaps/Secrets referenced by PostBuild.substituteFrom (optional)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL