render

package
v1.0.0-alpha.16 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 13 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.

Was: KindModuleRelease = "ModuleRelease"

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 the CUE_REGISTRY mapping applied per module acquisition.
	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 (enhancement 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, compiles supplied values to a cue.Value (the zero value when none are supplied, letting the module's #config defaults apply), synthesizes the instance, renders it against the platform, and adapts the compiled output to operator resources plus inventory entries.

The kernel gate is held only across acquisition and synthesis, the calls that evaluate in the shared Kernel's own context; the render build shares nothing (library ADR-005) and runs outside the gate, so renders of different objects overlap under --max-concurrent-renders. 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).
	Kernel *kernel.Kernel

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

	// Registry is the CUE_REGISTRY mapping applied while loading the package.
	Registry string

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

Was: KernelReleaseRenderer 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 loaderfile.ErrWrongKind — the library's documented signal for frontends to branch on the failure class via errors.Is. That resolves kind detection in the kernel's context without a separate non-gated peek.

For a ModuleInstance package it acquires the instance under the kernel gate (the load evaluates in the shared Kernel's context), 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 outside the gate; the build shares nothing (library ADR-005).

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)
}

Was: ReleaseRenderer 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 build's advisory, human-readable messages:
	// 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.
	Warnings []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.
	ResolvedVersions []kernel.ResolvedVersion
}

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