render

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package render contains OPM render orchestration boundaries.

Index

Constants

View Source
const KindModuleRelease = "ModuleRelease"

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

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 release kind")

ErrUnsupportedKind indicates the loaded CUE value has a `kind` field that this controller cannot render. Only #ModuleRelease 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 ModuleRelease 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 release, 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 release, compiles it against the platform, and adapts the compiled output to operator resources plus inventory entries.

The platform comes from the injected store.

type KernelReleaseRenderer added in v0.7.0

type KernelReleaseRenderer 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
}

KernelReleaseRenderer renders a Flux-fetched Release package through the library kernel behind the ReleaseRenderer seam: for a kind: ModuleRelease package it loads the release in the kernel's *cue.Context, reads the materialized platform from the store, compiles the release against it, and adapts the compiled output to operator resources plus inventory entries. Any package whose kind is not #ModuleRelease is rejected with ErrUnsupportedKind.

No values are injected: a Release package is an authored #ModuleRelease that already carries its own values — there is no SynthesizeRelease step.

func (*KernelReleaseRenderer) Render added in v0.7.0

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

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

Kind detection rides on the loader's shape gate: Kernel.LoadReleasePackage gates to the #ModuleRelease 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 ModuleRelease package it builds the release, 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 ReleaseRenderer

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

ReleaseRenderer loads a CUE release package from a local directory (already extracted from a Flux artifact) and returns its kind plus render output. Production wires KernelReleaseRenderer; 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 (e.g., unhandled traits).
	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