render

package
v0.0.0-...-257ac8b Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package render defines the engine-agnostic interface that the component controller uses to render and apply manifests. Engine-specific code (Timoni CUE modules, Helm charts) lives in sibling packages and is wired in at controller startup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseEnvelope

func ParseEnvelope(data []byte) (conurev1alpha1.ComponentEngine, []byte, error)

ParseEnvelope returns the engine that produced the apply-set and the raw payload to feed to Engine.UnmarshalApplySets. Legacy un-enveloped Timoni payloads (a bare JSON array) are detected and reported as EngineTimoni so pre-refactor components continue to reconcile without migration.

func WrapEnvelope

func WrapEnvelope(engine conurev1alpha1.ComponentEngine, payload []byte) ([]byte, error)

WrapEnvelope wraps an engine-specific apply-set marshal output with the versioned envelope. Callers should pass the bytes returned by Engine.MarshalApplySets verbatim.

Types

type Builder

type Builder interface {
	// Build returns an Engine prepared to render the given component. creds is
	// the resolved "user:password" pair for the OCI registry hosting the
	// module/chart, or "" for anonymous pulls — the controller resolves it
	// before calling so the engine layer stays free of dockerconfigjson
	// plumbing.
	Build(ctx context.Context, def *conurev1alpha1.ComponentDefinition, comp *conurev1alpha1.Component, creds string) (Engine, error)
	// BuildForApply returns an Engine that can Unmarshal apply-sets and call
	// ApplyObject without performing a fetch/render. The drift sweep doesn't
	// have a ComponentDefinition handy, so only the Component is supplied.
	BuildForApply(ctx context.Context, comp *conurev1alpha1.Component) (Engine, error)
}

Builder constructs Engine instances for a specific component. Implementations are engine-specific (one per Timoni, one per Helm). The controller owns a map of builders keyed by ComponentEngine and selects the right one based on the ComponentDefinition (render path) or the apply-sets envelope (drift path).

The two-flavor split mirrors the two call sites on the handler today:

  • Build is invoked from RenderComponent and pulls/loads the source.
  • BuildForApply is invoked from ReconcileDeployedObjects and skips the fetch — it only needs to be able to UnmarshalApplySets and ApplyObject against the controller's REST config.

type Engine

type Engine interface {
	Render(ctx context.Context) ([]ResourceSet, error)

	// Digest returns the resolved OCI manifest digest of the pulled artifact,
	// or "" if the engine has not pulled (e.g. a BuildForApply instance) or
	// the source does not expose one.
	Digest() string

	MarshalApplySets(sets []ResourceSet) ([]byte, error)
	UnmarshalApplySets(data []byte) ([]ResourceSet, error)

	ApplyObject(ctx context.Context, obj *unstructured.Unstructured, force bool) (*ssa.ChangeSetEntry, error)
}

Engine renders a single component instance and applies its manifests to the cluster. Implementations encapsulate everything engine-specific: OCI pulls, templating, value coalescing. Callers only see ResourceSet and the SSA change-set entries returned by ApplyObject.

Render is called once per reconcile that needs a fresh template; the result is then persisted to the Component's apply-sets annotation. ApplyObject is called per object, both after Render and during the periodic drift sweep (which uses Unmarshal to rehydrate the cached set).

type ResourceSet

type ResourceSet struct {
	Name    string                       `json:"name"`
	Objects []*unstructured.Unstructured `json:"objects,omitempty"`
}

ResourceSet is a named group of rendered Kubernetes objects. Timoni emits one ResourceSet per top-level CUE field; Helm renders a single set named after the chart. JSON tags match the legacy Timoni shape so apply-set annotations written before the multi-engine refactor remain decodable.

type Selector

type Selector func(def *conurev1alpha1.ComponentDefinition) (Builder, error)

Selector returns the Builder configured for a given ComponentDefinition. The controller passes a Selector into ComponentReconciler so the handler stays decoupled from the concrete engines registered at startup.

type SelectorForEngine

type SelectorForEngine func(engine conurev1alpha1.ComponentEngine) (Builder, error)

SelectorForEngine returns the Builder for a previously rendered component's engine label (read from the apply-sets envelope). Used by the drift sweep, which doesn't have a ComponentDefinition handy and must dispatch on the engine that originally rendered the cached set.

Directories

Path Synopsis
Package apply wires the shared fluxcd/pkg/ssa apply path used by render adapters that don't have their own server-side-apply implementation.
Package apply wires the shared fluxcd/pkg/ssa apply path used by render adapters that don't have their own server-side-apply implementation.
Package helm adapts Helm v4 chart rendering to the render.Engine interface.
Package helm adapts Helm v4 chart rendering to the render.Engine interface.
Package timoni adapts the Timoni module manager to the render.Engine interface.
Package timoni adapts the Timoni module manager to the render.Engine interface.

Jump to

Keyboard shortcuts

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