render

package
v1.0.0-alpha.12 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: Apache-2.0 Imports: 12 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 materialized platform")

ErrPlatformNotReady is returned by KernelModuleRenderer.RenderModule when the platform store holds no materialized platform. It is a typed sentinel so the reconciler-side mapping to a custom-resource condition (a later slice) 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 materialized 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 reads the materialized platform from the store, acquires the target module from the registry, synthesizes the instance, and compiles it against the platform.

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 reads the materialized 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, compiles it against the platform, and adapts the compiled output to operator resources plus inventory entries.

The platform comes from the injected store.

type KernelPackageRenderer

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

	// Store holds the materialized 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 loads the instance in the kernel's *cue.Context, reads the materialized platform from the store, compiles the instance against it, 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.LoadInstancePackage 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 or re-coupling to the fork loader.

For a ModuleInstance package it builds the instance, gates on platform readiness (returning ErrPlatformNotReady before Compile when no platform is materialized so nothing is applied), compiles against the materialized platform, and adapts the output. The platform comes from the injected store.

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 non-fatal render warnings. Since the core-v2 library
	// line, only effectively-optional unhandled traits degrade to warnings;
	// unresolved demands (undemandable resources, unhandled load-bearing
	// traits) fail Compile instead of landing here (0010 D28).
	Warnings []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