render

package
v1.0.0-alpha.22 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package render contains OPM render orchestration boundaries.

Index

Constants

View Source
const KindModuleInstance = "ModuleInstance"

KindModuleInstance surfaces the CUE `kind` field for the only renderable instance kind, so the reconciler can record it without re-evaluating the value.

Variables

View Source
var ErrPlatformNotReady = errors.New("platform not ready: no generated platform module")

ErrPlatformNotReady is returned by the renderers when the platform store holds no generated platform module. It is a typed sentinel so the reconciler-side mapping to a custom-resource condition can branch on it via errors.Is without string matching.

View Source
var ErrUnsupportedKind = errors.New("unsupported instance kind")

ErrUnsupportedKind indicates the loaded CUE value has a `kind` field that this controller cannot render. Only #ModuleInstance is renderable; any other kind is rejected with this error.

Functions

This section is empty.

Types

type BundleRenderer

type BundleRenderer any

BundleRenderer derives child module releases from bundle input.

type KernelModuleRenderer added in v0.7.0

type KernelModuleRenderer struct {
	// Kernel is the shared, long-lived library Kernel (one per process).
	Kernel *kernel.Kernel

	// Store holds the generated platform written by the PlatformReconciler.
	Store *platformstore.Store

	// Registry is passed through to moduleacquire.Acquire's retained registry
	// parameter and does not affect resolution: the Kernel resolves the
	// mapping it was constructed with (kernel.WithRegistry).
	Registry string

	// RuntimeName is the runtime identity injected into each transformer's
	// #context (e.g. "opm-controller").
	RuntimeName string
}

KernelModuleRenderer renders a ModuleInstance entirely through the library kernel behind the ModuleRenderer seam: it leases the generated platform record from the store, acquires the target module from the registry, synthesizes the instance, and renders it against the platform module through the kernel's single-build render (0019:D9).

func (*KernelModuleRenderer) RenderModule added in v0.7.0

func (r *KernelModuleRenderer) RenderModule(
	ctx context.Context,
	name, namespace, modulePath, moduleVersion string,
	values *releasesv1alpha1.RawValues,
) (*RenderResult, error)

RenderModule renders the module at modulePath@moduleVersion into a RenderResult via the kernel. It leases the generated platform from the store (returning ErrPlatformNotReady before any I/O when absent), acquires the module, loads the values as one values source with origin spec.values (an empty document when none are supplied, letting the module's #config defaults apply) and checks it against the module's #config, synthesizes the instance, renders it against the platform, and adapts the compiled output to operator resources plus inventory entries.

Every kernel call shares nothing (library ADR-005, ADR-007): acquisition, synthesis and the render build each evaluate in a context of their own, so renders of different objects overlap under --max-concurrent-renders with no gate. The lease is held for the whole call: the build reads the platform module directory the record names.

type KernelPackageRenderer

type KernelPackageRenderer struct {
	// Kernel is the shared, long-lived library Kernel (one per process). The
	// registry mapping it was constructed with resolves the package's imports.
	Kernel *kernel.Kernel

	// Store holds the generated platform written by the PlatformReconciler.
	Store *platformstore.Store

	// RuntimeName is the runtime identity injected into each transformer's
	// #context (e.g. "opm-controller").
	RuntimeName string
}

KernelPackageRenderer renders a Flux-fetched ModulePackage through the library kernel behind the PackageRenderer seam: for a kind: ModuleInstance package it acquires the instance from its directory as a source-carrying artifact, leases the generated platform from the store, renders the instance against it through the kernel's single-build render, and adapts the compiled output to operator resources plus inventory entries. Any package whose kind is not #ModuleInstance is rejected with ErrUnsupportedKind.

No values are injected: a ModulePackage references an authored #ModuleInstance that already carries its own values — there is no SynthesizeInstance step.

func (*KernelPackageRenderer) Render

func (r *KernelPackageRenderer) Render(
	ctx context.Context,
	packageDir string,
) (string, *RenderResult, error)

Render loads, kind-detects, and renders the package at packageDir.

Kind detection rides on the loader's shape gate: Kernel.AcquireInstanceFromDir gates to the #ModuleInstance kind, so any other kind fails with oerrors.ErrWrongKind — the library's documented signal for frontends to branch on the failure class via errors.Is. That resolves kind detection in the acquisition itself without a separate peek.

For a ModuleInstance package it acquires the instance, gates on platform readiness (returning ErrPlatformNotReady before any build when no platform module is recorded, so nothing is applied), and renders against the leased platform. Every kernel call shares nothing (library ADR-005, ADR-007): acquisition and build each evaluate in a context of their own, with no gate.

type ModuleRenderer

type ModuleRenderer interface {
	RenderModule(
		ctx context.Context,
		name, namespace, modulePath, moduleVersion string,
		values *releasesv1alpha1.RawValues,
	) (*RenderResult, error)
}

ModuleRenderer is the injection boundary for module rendering in the reconcile loop. Production wires KernelModuleRenderer; tests wire a stub that returns a pre-built RenderResult without requiring an OCI registry.

type PackageRenderer

type PackageRenderer interface {
	Render(ctx context.Context, packageDir string) (kind string, result *RenderResult, err error)
}

PackageRenderer loads a CUE package from a local directory (already extracted from a Flux artifact) and returns its kind plus render output. Production wires KernelPackageRenderer; tests inject a stub.

type RenderResult

type RenderResult struct {
	// Resources is the ordered list of rendered Kubernetes resources.
	Resources []*core.Resource

	// InventoryEntries are the CRD-typed inventory entries built from Resources.
	InventoryEntries []releasesv1alpha1.InventoryEntry

	// Warnings are the render's advisory findings, worded by the operator
	// (renderWarnings) from the diagnostics' rows: effectively-optional unhandled
	// traits and, under the Warn skew policy, catalog version skew. Unresolved
	// demands (undemandable resources, unhandled load-bearing traits) refuse the
	// render instead of landing here (0010:D28). The reconciler emits them as
	// RenderWarning events on transition, keyed on the rows below rather than on
	// these strings.
	Warnings []string

	// UnhandledTraits maps a component to the effectively-optional traits no
	// matched transformer handles, as the build reported it. Plain data: the
	// facts behind the trait warnings, the reconciler's transition key.
	UnhandledTraits map[string][]string

	// ResolvedVersions are the per-path version rows the build reports
	// (0019:D18): for every OPM-namespace path the instance module requires,
	// the build it asked for and the build the platform carries. Plain data;
	// the reconciler logs them at debug level, and a row marked Newer is the
	// fact behind a skew warning.
	ResolvedVersions []kernel.ResolvedVersion

	// RequiredContracts is every contract FQN the instance's components
	// declare, sorted and deduplicated (0015:D3, D16): the
	// instance's demand, in the keyspace TransformerRegistration.spec.provides
	// carries. The reconciler persists it on status.requiredContracts, where
	// the claim reconciler's removal guard intersects it with a claim's
	// provides to count that claim's dependents.
	//
	// Read off the synthesized instance, never off the platform, so it is a
	// property of the instance alone and does not move when the platform does.
	RequiredContracts []string

	// PlatformIdentity is the identity of the generated platform package this
	// render built against, in its string form (0015:D13, D17):
	// the Platform CR generation plus a digest of the active claims' catalog
	// coordinates. A render holds its package under a lease for its whole
	// duration, so this is the exact registry state the render consumed, even
	// when a newer package was generated while it ran.
	PlatformIdentity string
}

RenderResult holds the output of a successful RenderModule call. Contains both the rendered resources and their inventory entries, giving the caller everything needed for apply + inventory in one call.

Jump to

Keyboard shortcuts

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