Documentation
¶
Overview ¶
Package kernel exposes the OPM runtime as a single struct, Kernel.
Kernel owns its *cue.Context and its *schema.Cache for its entire lifetime. Construction is New plus two options, WithSchemaLoader and WithRegistry; the kernel exposes no injection slot that no kernel operation reads. Downstream binaries (CLI, controller, Crossplane function) construct one Kernel per goroutine and call methods on it instead of importing the individual loader / module / validate packages.
Goroutine safety ¶
A single Kernel is NOT safe for concurrent use across its own method calls. The owned *cue.Context (acquisition, synthesis and validation build in it) is driven single-threaded; sharing one Kernel between goroutines can cause data races inside CUE evaluation. Callers that need concurrency MUST construct one Kernel per goroutine.
Kernel.Render shares nothing between renders (ADR-005, enhancement 0019 D8). Each render is its own CUE build in a fresh cue.Context created for that call and dropped when Render returns; the Kernel's own context is not used, no built value is retained between calls, and a caller cannot obtain one to hold. Concurrency is across renders, never within one: a consumer rendering from several goroutines gives each goroutine its own Kernel and calls Render, with no shared platform value and no mutex. There is no materialized platform to share and no serialised render path; the earlier shared-platform contract (ADR-002) is superseded, not supported.
A render is single-threaded and its working set grows with the module, so a render pool is sized by memory rather than by core count: about 61 MB plus 7.75 MB per component per concurrent render (0019 experiment 08), and throughput saturates at roughly physical cores divided by 1.6 renders in flight. Size against the largest module the pool will see.
One-Kernel-per-goroutine example ¶
func renderAll(ctx context.Context, platformDir string, instanceDirs []string) error {
var wg sync.WaitGroup
errs := make(chan error, len(instanceDirs))
for _, dir := range instanceDirs {
wg.Add(1)
go func(dir string) {
defer wg.Done()
k := kernel.New() // one Kernel per goroutine
plat, err := k.AcquirePlatformFromDir(ctx, platformDir, loaderfile.LoadOptions{})
if err != nil {
errs <- err
return
}
inst, err := k.AcquireInstanceFromDir(ctx, dir, loaderfile.LoadOptions{})
if err != nil {
errs <- err
return
}
if _, err := k.Render(ctx, kernel.RenderInput{Instance: inst, Platform: plat, RuntimeName: "opm-cli"}); err != nil {
errs <- err
}
}(dir)
}
wg.Wait()
close(errs)
for err := range errs {
if err != nil {
return err
}
}
return nil
}
Rendering ¶
Kernel.Render is the kernel's single render verb. It takes a source-carrying instance (Kernel.AcquireInstanceFromDir or Kernel.SynthesizeInstance) and a source-carrying platform (Kernel.AcquirePlatformFromDir: a platform is a CUE module on disk that imports its catalogs), stages one generated render module that imports both, builds it once, and decodes the matching verdicts (RenderDiagnostics) and the rendered output (RenderResult.Compiled, one entry per rendered object with instance, component and transformer provenance). Matching and transformer execution are CUE inside the build, not Go; the build reports its verdicts as data and the kernel's fail-closed gate turns an unresolved demand, an unmatched component or an over-subscribed provider-fulfilled contract into a *RenderError that carries the full diagnostics, with the typed causes reachable through errors.As. Catalog version skew (the instance module requiring a newer OPM-namespace build than the platform carries) is warned by default (SkewWarn) or refused before evaluation (SkewRefuse).
A dry run is Render with the output discarded: the build evaluates every matched pair regardless, and RenderDiagnostics carries the pairing diagnosis (Pairs, Unmatched, Unresolved, Unify, UnhandledTraits, OverSubscribed, ResolvedVersions). There is no separate match verb.
Render consumes the instance as processed: Kernel.ProcessModuleInstance is the validated entry point (it validates user values against the module's `#config` schema via Kernel.ValidateConfig and fills them before the instance is rendered; AcquireInstanceFromDir and SynthesizeInstance both go through it), and Render performs no validation pass of its own.
Configuration validation ¶
Three primitives form the validation surface:
- Kernel.ValidateConfig — concrete check on a single, pre-merged cue.Value. Returns the unified value and a CUE-native error.
- Kernel.ValidateConfigPartial — same, without the concreteness requirement. Used by lint subcommands, IDE/LSP, admission webhooks, and other callsites that intentionally validate a draft.
- Kernel.ValidateConfigDetailed — accepts an ordered slice of Source, unifies in stack order, then validates the merged value. Per-source attribution flows through token.Pos.Filename populated from cue.Filename(Origin) at compile time. Use Kernel.LoadSourceFromFile, Kernel.LoadSourceFromBytes, or Kernel.LoadSourceFromString to construct sources whose Value satisfies the filename contract automatically.
All three return CUE-native errors. Walk them via cuelang.org/go/cue/errors.Errors / cuelang.org/go/cue/errors.Positions, or print via cuelang.org/go/cue/errors.Print. Presentation belongs to the frontend — the kernel does not ship a formatter.
A caller holding a *module.Module or *module.Instance composes its ConfigSchema() accessor with the primitive it wants, e.g. k.ValidateConfig(m.ConfigSchema(), values).
Advanced: CueContext accessor ¶
Kernel.CueContext returns the underlying *cue.Context for callers that need to build [cue.Value]s outside the kernel (typically tests). Values built with this context are safe to pass back into Kernel methods. Most callers should not need this. Render never uses it: the render build has its own context.
Index ¶
- type Kernel
- func (k *Kernel) AcquireInstanceFromDir(ctx context.Context, dirPath string, opts loaderfile.LoadOptions) (*module.Instance, error)
- func (k *Kernel) AcquireModuleFromRegistry(ctx context.Context, modPath, version string) (*module.Module, error)
- func (k *Kernel) AcquirePlatformFromDir(ctx context.Context, dirPath string, opts loaderfile.LoadOptions) (*platform.Platform, error)
- func (k *Kernel) CueContext() *cue.Context
- func (k *Kernel) LoadInstancePackage(_ context.Context, dirPath string, opts loaderfile.LoadOptions) (cue.Value, error)
- func (k *Kernel) LoadModulePackage(_ context.Context, dirPath string, opts loaderfile.LoadOptions) (cue.Value, error)
- func (k *Kernel) LoadPlatformPackage(_ context.Context, dirPath string, opts loaderfile.LoadOptions) (cue.Value, error)
- func (k *Kernel) LoadSourceFromBytes(origin, name string, b []byte) (Source, error)
- func (k *Kernel) LoadSourceFromFile(path string) (Source, error)
- func (k *Kernel) LoadSourceFromString(origin, name, s string) (Source, error)
- func (k *Kernel) NewInstanceFromValue(v cue.Value) (*module.Instance, error)
- func (k *Kernel) NewModuleFromValue(v cue.Value) (*module.Module, error)
- func (k *Kernel) NewPlatformFromValue(v cue.Value) (*platform.Platform, error)
- func (k *Kernel) ProcessModuleInstance(_ context.Context, spec cue.Value, mod module.Module, values cue.Value) (*module.Instance, error)
- func (k *Kernel) Render(ctx context.Context, in RenderInput) (*RenderResult, error)
- func (k *Kernel) SchemaCache() *schema.Cache
- func (k *Kernel) SynthesizeInstance(ctx context.Context, in synth.InstanceInput) (*module.Instance, error)
- func (k *Kernel) ValidateConfig(schema cue.Value, values cue.Value) (cue.Value, error)
- func (k *Kernel) ValidateConfigDetailed(schema cue.Value, sources []Source, opts ...ValidateOption) (cue.Value, error)
- func (k *Kernel) ValidateConfigPartial(schema cue.Value, values cue.Value) (cue.Value, error)
- type Option
- type RenderDiagnostics
- type RenderError
- type RenderInput
- type RenderPair
- type RenderResult
- type ResolvedVersion
- type SkewPolicy
- type Source
- type ValidateOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Kernel ¶
type Kernel struct {
// contains filtered or unexported fields
}
Kernel is the public anchor type for the OPM runtime. It owns a *cue.Context and a *schema.Cache for its lifetime.
Kernel is NOT safe for concurrent use across method calls — see the package documentation for the one-Kernel-per-goroutine pattern.
The Kernel owns exactly one *schema.Cache for its lifetime. Long- running consumers (operator, server) MUST keep the Kernel alive across operations to reuse the in-process schema cache; constructing a fresh Kernel per request pays the schema-fetch cost on every cold disk cache. The CUE module cache on disk is shared across Kernels.
func New ¶
New constructs a Kernel with default dependencies and applies the supplied options. Defaults are:
- cue.Context: a fresh cuecontext.New
- SchemaCache: a fresh *schema.Cache backed by zero-value schema.OCILoader; resolves schema.DefaultSchemaModule (the pinned core release) against CUE_REGISTRY / CUE_CACHE_DIR from the process environment
New never returns nil. The returned Kernel is NOT safe for concurrent use across method calls.
New does NOT trigger a schema load. The first Kernel method that needs the schema invokes [Cache.Get] internally, which performs the fetch lazily.
func (*Kernel) AcquireInstanceFromDir ¶
func (k *Kernel) AcquireInstanceFromDir(ctx context.Context, dirPath string, opts loaderfile.LoadOptions) (*module.Instance, error)
AcquireInstanceFromDir loads a #ModuleInstance CUE package from a directory and returns it as a validated, source-carrying *module.Instance. It composes Kernel.LoadInstancePackage (evaluation and the instance shape gate) with Kernel.ProcessModuleInstance — the validated entry point, called with no extra values, so the package must already be fully concrete, as an authored instance package is — then stamps module.Instance.Source in on-disk mode: Overlay is nil, Root is the enclosing module root (the nearest ancestor holding cue.mod/module.cue, the directory itself when it is the root) and Pkg the package directory relative to it, so a package in a subdirectory of its module imports correctly from a follow-on build.
This is the same bar Kernel.SynthesizeInstance output meets, and the recommended entry point when the instance will be imported as a package by a follow-on build. Draft flows that need an unvalidated value keep using Kernel.LoadInstancePackage. opts.Registry is applied as the loader applies it (load configuration environment, never os.Setenv).
Loader failures propagate unchanged (missing directory, no package, or a shape-gate sentinel); a non-concrete package surfaces the validation error Kernel.ProcessModuleInstance produces. No partial instance is returned.
func (*Kernel) AcquireModuleFromRegistry ¶
func (k *Kernel) AcquireModuleFromRegistry(ctx context.Context, modPath, version string) (*module.Module, error)
AcquireModuleFromRegistry loads a #Module published in an OCI registry by its major-qualified path (e.g. "example.com/modules/hello@v0") and version (e.g. "v0.0.2"), using the kernel's *cue.Context and configured registry (set via WithRegistry, inheriting CUE_REGISTRY from the process environment when unset). It returns a decoded *module.Module whose staged source (module.Source) is populated, so the module can be reused as the main module of a follow-on build — notably by Kernel.SynthesizeInstance, which stages the instance inside the module's own root so the module's already-tidied cue.mod/module.cue drives transitive dependency resolution. A caller that wants only the raw module value reads Module.Package. See loaderregistry.LoadModulePackageWithSource.
func (*Kernel) AcquirePlatformFromDir ¶
func (k *Kernel) AcquirePlatformFromDir(ctx context.Context, dirPath string, opts loaderfile.LoadOptions) (*platform.Platform, error)
AcquirePlatformFromDir loads a #Platform CUE package from a directory and returns it as a typed, source-carrying *platform.Platform. It composes Kernel.LoadPlatformPackage (evaluation and the platform shape gate, identical to a direct call) with platform.NewPlatformFromValue, then stamps platform.Platform.Source in on-disk mode: Root is the enclosing module root (the nearest ancestor holding cue.mod/module.cue, the directory itself when it is the root), Pkg the package directory relative to it, and Overlay nil.
It is the directory peer of Kernel.AcquireModuleFromRegistry ("Acquire" returns a typed artifact that knows where its source lives) and the recommended entry point when the platform will be imported as a package by a follow-on build. A caller that wants only the raw value keeps using Kernel.LoadPlatformPackage. opts.Registry, when non-empty, is applied via the load configuration's environment, never os.Setenv, exactly as the loader applies it.
Loader failures propagate unchanged (missing directory, no package, or a shape-gate sentinel such as loaderfile.ErrWrongKind); no partial platform is returned.
func (*Kernel) CueContext ¶
CueContext returns the *cue.Context owned by this Kernel.
Advanced: most callers do not need this. Use it only when building [cue.Value]s outside the kernel (typically tests or programmatic CUE construction). Values built with this context are safe to pass back into Kernel methods. The same *cue.Context is returned for the lifetime of the Kernel.
func (*Kernel) LoadInstancePackage ¶
func (k *Kernel) LoadInstancePackage(_ context.Context, dirPath string, opts loaderfile.LoadOptions) (cue.Value, error)
LoadInstancePackage loads a #ModuleInstance CUE package from a directory using the kernel's *cue.Context. See loaderfile.LoadInstancePackage.
Was: LoadReleasePackage
func (*Kernel) LoadModulePackage ¶
func (k *Kernel) LoadModulePackage(_ context.Context, dirPath string, opts loaderfile.LoadOptions) (cue.Value, error)
LoadModulePackage loads a module CUE package from a directory using the kernel's *cue.Context. See loaderfile.LoadModulePackage.
func (*Kernel) LoadPlatformPackage ¶
func (k *Kernel) LoadPlatformPackage(_ context.Context, dirPath string, opts loaderfile.LoadOptions) (cue.Value, error)
LoadPlatformPackage loads a #Platform CUE package from a directory using the kernel's *cue.Context. See loaderfile.LoadPlatformPackage.
func (*Kernel) LoadSourceFromBytes ¶
LoadSourceFromBytes compiles b into a Source with cue.Filename(origin) baked into the resulting cue.Value, so that any subsequent validation error positions carry origin via token.Pos.Filename.
Returns an error if compilation fails (the returned Source is the zero value in that case).
func (*Kernel) LoadSourceFromFile ¶
LoadSourceFromFile reads a values file from disk, compiles it via cuelang.org/go/cue/load.Instances (which populates cue.Filename automatically with the file's absolute path), and returns a Source whose Origin matches the absolute path so per-position diagnostics remain consistent with the file the user wrote.
Auto-unwrap: if the loaded value has a top-level `values:` field that exists and reports no error, that field is returned as the Source.Value. Otherwise the whole evaluated file value is returned.
Name defaults to the basename.
func (*Kernel) LoadSourceFromString ¶
LoadSourceFromString is the [string]-input mirror of Kernel.LoadSourceFromBytes.
func (*Kernel) NewInstanceFromValue ¶
NewInstanceFromValue builds a typed *module.Instance from a raw cue.Value. See module.NewInstanceFromValue.
Was: NewReleaseFromValue
func (*Kernel) NewModuleFromValue ¶
NewModuleFromValue builds a typed *module.Module from a raw cue.Value. See module.NewModuleFromValue.
func (*Kernel) NewPlatformFromValue ¶
NewPlatformFromValue builds a typed *platform.Platform from a raw cue.Value. See platform.NewPlatformFromValue.
func (*Kernel) ProcessModuleInstance ¶
func (k *Kernel) ProcessModuleInstance(_ context.Context, spec cue.Value, mod module.Module, values cue.Value) (*module.Instance, error)
ProcessModuleInstance validates the supplied values, fills them into the instance spec, asserts the result is fully concrete, decodes instance metadata via opm/schema, and returns a constructed *module.Instance.
The instance spec carries its source #Module inside the CUE package; the schema for value validation is read from spec via schema.Module + schema.Config. mod is supplied for fallback diagnostics (instance name when metadata.name is not yet concrete) and is not retained on the returned Instance — the source module remains reachable through Instance.Package.
values is a single, pre-unified cue.Value — layering is performed by callers via Kernel.ValidateConfigDetailed before this call. The zero cue.Value is treated as "no values supplied": validation is skipped, no fill is performed, and the spec must already be concrete on every required field.
Was: ProcessModuleRelease
func (*Kernel) Render ¶
func (k *Kernel) Render(ctx context.Context, in RenderInput) (*RenderResult, error)
Render renders an instance against a platform as ONE CUE build (enhancement 0019 D9): it stages a generated render module in a per-render temporary directory (the promoted cue.mod, D13; directory replacements bringing both inputs in; the embedded matching and execution glue), verifies the promoted list covers every OPM-namespace path either input requires, applies the skew policy (D7/D18), builds the module once in a fresh cue.Context that is dropped when Render returns (D8), and decodes `diagnostics` and `rendered` off the built value.
The Kernel's own context is not used and no built value survives the call except the returned output; repeated renders share nothing. The staging directory is removed on return, success or failure. Registry resolution for the platform's catalog imports uses WithRegistry when set, else the process CUE_REGISTRY, plumbed through the load configuration only.
Refusals before evaluation (missing Source, uncovered OPM path, skew under SkewRefuse) return plain errors; refusals after evaluation return a *RenderError carrying the decoded diagnostics.
func (*Kernel) SchemaCache ¶
SchemaCache returns the *schema.Cache owned by this Kernel. The same pointer is returned for the lifetime of the Kernel; callers MAY hold it across operations to ensure cache reuse.
Calling SchemaCache does NOT trigger a schema load. Only the first schema.Cache.Get invocation contacts CUE; the load is lazy and memoized.
Typical use: pass to synth.InstanceInput.SchemaCache before calling instance synthesis, or read schema.Cache.ResolvedVersion for diagnostics after a schema-touching operation has run.
func (*Kernel) SynthesizeInstance ¶
func (k *Kernel) SynthesizeInstance(ctx context.Context, in synth.InstanceInput) (*module.Instance, error)
SynthesizeInstance builds a *module.Instance from typed in-memory inputs. This is the recommended entry point for callers that hold a Module and need a fully validated instance — it mirrors how Kernel.LoadInstancePackage is the recommended entry point for the file-driven path.
SynthesizeInstance chains synth.Instance (which unifies inputs against the version binding's #ModuleInstance schema and lets CUE derive uuid, components, auto-secrets, and standard labels) into Kernel.ProcessModuleInstance (which validates supplied values against the module's #config, fills them into the spec, enforces concreteness, and decodes instance metadata).
The Kernel's *cue.Context threads through both steps so the resulting *module.Instance.Package is reachable through cue lookups using the same runtime. Callers that explicitly want the helper-level primitive — for example, a test that wants the spec value before concreteness enforcement — should call synth.Instance directly with Kernel.CueContext and then invoke Kernel.ProcessModuleInstance themselves.
The returned instance carries module.Instance.Source: the staged tree synth.Instance built, in overlay mode, with Pkg naming the reserved instance subdirectory inside the module's staged root.
in.Values is passed through to Kernel.ProcessModuleInstance unchanged. The zero cue.Value means "no values supplied"; Kernel.ProcessModuleInstance then fails the concreteness check unless every #config field has a default. synth.Instance never falls back to Module.debugValues — frontends that want a debug-values overlay layer it on the caller side.
Was: SynthesizeRelease
func (*Kernel) ValidateConfig ¶
ValidateConfig is the kernel's primitive Tier-2 validation entry point. It unifies values with schema, runs the closed-schema disallowed-field walk, and asserts concreteness via cue.Concrete(true).
Returns the unified cue.Value on success and the zero value on failure. The returned error is the raw CUE error tree; walk it via cuelang.org/go/cue/errors.Errors / cuelang.org/go/cue/errors.Positions, or print it via cuelang.org/go/cue/errors.Print. Presentation is outside the kernel's contract — frontends own their own formatting.
values is a single, pre-merged cue.Value. Layered inputs flow through Kernel.ValidateConfigDetailed; partial-mode validation flows through Kernel.ValidateConfigPartial. Module-name framing is the caller's responsibility — wrap with fmt.Errorf if a context prefix is required.
The zero cue.Value is treated as "no values": ValidateConfig returns (zero, nil) without running any schema check.
func (*Kernel) ValidateConfigDetailed ¶
func (k *Kernel) ValidateConfigDetailed(schema cue.Value, sources []Source, opts ...ValidateOption) (cue.Value, error)
ValidateConfigDetailed unifies an ordered slice of Source values, then validates the merged value against schema. Per-source attribution flows through token.Pos.Filename, populated from cue.Filename(Origin) at the time each Source.Value was compiled — see Kernel.LoadSourceFromFile, Kernel.LoadSourceFromBytes, and Kernel.LoadSourceFromString for constructors that bake the filename for you.
Without options the merged value must be concrete (every required field set). With Partial in opts, concreteness is not enforced; the merged value is checked only for type errors, constraint violations, and disallowed fields under closed schemas.
Returns the merged cue.Value on success and the zero value on failure. The returned error is the raw CUE error tree; walk it via cuelang.org/go/cue/errors.Errors and cuelang.org/go/cue/errors.Positions, or print it via cuelang.org/go/cue/errors.Print. Presentation is outside the kernel's contract — frontends own their own formatting.
Empty sources, a zero schema, or a merged value that does not exist all short-circuit to (zero, nil) — the "no values supplied" path documented across the kernel's validation surface.
func (*Kernel) ValidateConfigPartial ¶
ValidateConfigPartial validates partial values against schema without requiring every schema field to be concrete. It catches type errors, disallowed fields, and pattern/regex violations on fields that ARE set, but does NOT flag fields that are missing entirely.
Used for CLI lint subcommands, IDE/LSP live feedback, admission webhooks, and any callsite that intentionally validates a draft slice of the full configuration.
The zero cue.Value (no values) is treated as success.
type Option ¶
type Option func(*Kernel)
Option configures a Kernel at construction time. Options compose via the functional-options pattern; new options can be added in MINOR instances without breaking existing call sites. The provided options are WithSchemaLoader and WithRegistry; the Kernel exposes no injection slot that no kernel operation reads.
func WithRegistry ¶
WithRegistry sets the OCI registry mapping (CUE_REGISTRY syntax, e.g. "opmodel.dev=ghcr.io/open-platform-model") used for catalog and module resolution: the render build's catalog imports (Kernel.Render) and registry module acquisition (Kernel.AcquireModuleFromRegistry).
Omitting this option (or passing an empty string) inherits CUE_REGISTRY from the process environment; the kernel applies no built-in default registry — the same stance as the schema loader. The mapping is never written back to the process environment; it is plumbed into the load configuration for the operation only.
func WithSchemaLoader ¶
WithSchemaLoader configures the schema.Loader used to populate the kernel's *schema.Cache. Omitting this option defaults to a zero-value schema.OCILoader that resolves schema.DefaultSchemaModule via CUE_REGISTRY / CUE_CACHE_DIR from the process environment.
The Kernel wraps the supplied Loader in a fresh Cache; callers cannot inject a pre-built Cache. This guarantees one Kernel = one Cache, so no two Kernels accidentally share memoization. Multi-Kernel cache sharing is intentionally not exposed and may be added later as a non-breaking addition.
A nil Loader is ignored (the default OCILoader applies).
type RenderDiagnostics ¶
type RenderDiagnostics struct {
// Pairs is the matched pair set in build order.
Pairs []RenderPair
// Unmatched lists components no transformer matched.
Unmatched []string
// Unresolved is every demand the platform failed to resolve (0010 D28):
// an empty bucket (Disqualified empty, Alternatives naming same-base
// keys the platform does implement) or every candidate disqualified.
Unresolved []oerrors.UnresolvedDemand
// Unify is every candidate the always-unify rung disqualified, one entry
// per conflicting FQN. Cause names the transformer and the FQN; the
// verbatim CUE cause is not recoverable from inside the build (D10).
Unify []oerrors.UnifyError
// UnhandledTraits maps a component to the effectively-optional traits
// no matched transformer handles (rendered as warnings).
UnhandledTraits map[string][]string
// FailedPairs names matched pairs whose transformer output errored.
FailedPairs []RenderPair
// OverSubscribed is every provider-fulfilled contract key that
// transformers from more than one enabled registry entry require (the
// single-provider guard, 0010 D32/D37), key-sorted. Any row refuses the
// render through the gate.
OverSubscribed []oerrors.OverSubscribedContractError
// ResolvedVersions holds the per-path version rows, in path order.
ResolvedVersions []ResolvedVersion
}
RenderDiagnostics is everything the build reports as data (0019 D10), decoded into the kernel's structured types. It is populated on success and carried by *RenderError on a refusal, so a caller can always read the full verdict set.
type RenderError ¶
type RenderError struct {
Diagnostics RenderDiagnostics
Err error
}
RenderError is a refusal after the build: the fail-closed gate (an unresolved demand, an unmatched component or an over-subscribed provider-fulfilled contract), a failed pair, or a non-concrete pair output. Diagnostics carries everything the build reported; Err carries the typed causes (*oerrors.UnresolvedDemandsError, *oerrors.UnmatchedComponentsError, oerrors.OverSubscribedContractError, *oerrors.TransformError), reachable through errors.As.
func (*RenderError) Error ¶
func (e *RenderError) Error() string
func (*RenderError) Unwrap ¶
func (e *RenderError) Unwrap() error
type RenderInput ¶
type RenderInput struct {
// Instance is the validated instance to render. It MUST carry a Source
// (Kernel.SynthesizeInstance, Kernel.AcquireInstanceFromDir): the render
// build imports the instance as a package, so an evaluated value alone
// is never sufficient.
Instance *module.Instance
// Platform is the platform to render against, in the D5 shape (registry
// entries carrying their catalog by import). It MUST carry a Source
// (Kernel.AcquirePlatformFromDir).
Platform *platform.Platform
// RuntimeName identifies the executing runtime; it enters the build as
// #context.#runtimeName and is stamped on every rendered object.
RuntimeName string
// Skew is the response to catalog version skew. Zero is [SkewWarn].
Skew SkewPolicy
}
RenderInput is the input of Kernel.Render.
type RenderPair ¶
RenderPair names one matched (component, transformer) pair.
type RenderResult ¶
type RenderResult struct {
// Compiled is the rendered output, one entry per rendered object, in
// the build's deterministic pair order, each carrying instance,
// component and transformer provenance.
Compiled []*core.Compiled
// Diagnostics are the matching verdicts and version rows decoded from
// the build.
Diagnostics RenderDiagnostics
// Warnings are advisory, human-readable messages: unhandled optional
// traits and (under [SkewWarn]) version skew. Non-empty is not failure.
Warnings []string
}
RenderResult is the output of a successful Kernel.Render.
type ResolvedVersion ¶
type ResolvedVersion struct {
// Path is the major-qualified module path.
Path string
// ModuleVersion is the build the instance module's cue.mod requires.
ModuleVersion string
// PlatformVersion is the build the platform module's cue.mod carries;
// empty when the platform does not list the path (the instance's own
// entry then resolves).
PlatformVersion string
// Newer is true when the instance requires a newer build than the
// platform carries.
Newer bool
}
ResolvedVersion is one resolved-versions row (0019 D18): for an OPM-namespace path the instance module requires, what it asked for and what the platform carries. Plain data with no severity; Newer marks the skew case the policy decided.
type SkewPolicy ¶
type SkewPolicy int
SkewPolicy is the caller's response to catalog version skew (enhancement 0019 D7/D18): the instance module's cue.mod requiring a NEWER build of an OPM-namespace path than the platform module carries. Exactly two responses exist; the zero value is the default.
const ( // SkewWarn renders against the platform's build and reports the skew on // [RenderResult.Warnings]. The default. SkewWarn SkewPolicy = iota // SkewRefuse fails the render before evaluation with an // [*oerrors.SkewError] per skewed path. SkewRefuse )
type Source ¶
type Source struct {
// Value is the raw values payload for this source.
//
// Value MUST have been compiled with [cue.Filename](Origin) for
// per-source attribution to flow into errors. Use one of
// [Kernel.LoadSourceFromFile], [Kernel.LoadSourceFromBytes], or
// [Kernel.LoadSourceFromString] to construct a Source whose Value
// satisfies this contract automatically. Hand-built Sources MUST set
// the filename themselves when compiling.
Value cue.Value
// Name is the human-friendly label shown in UI. Examples:
// "user values", "ConfigMap/foo", "instance overlay".
Name string
// Origin is the stable identifier for machine-readable correlation
// (file path, K8s object reference, composition input key). It MUST
// match the [cue.Filename] used when Value was compiled, so error
// positions report Origin via [token.Pos.Filename].
Origin string
}
Source is one labeled values input for Kernel.ValidateConfigDetailed.
A Source pairs a values payload with caller-supplied identity so that per-position diagnostics flowing out of CUE error trees carry the originating source's filename. The library does not invent a Go-typed wrapper around CUE's error attribution — instead, it relies on token.Pos.Filename, populated from cue.Filename at compile time.
type ValidateOption ¶
type ValidateOption func(*validateConfig)
ValidateOption configures Kernel.ValidateConfigDetailed. Options compose via the functional-options pattern; new options can be added in MINOR instances without breaking existing call sites.
The type is named ValidateOption (rather than the more terse Option) to avoid collision with Option, the kernel-construction option type.
func Partial ¶
func Partial() ValidateOption
Partial returns a ValidateOption that skips the concreteness check on the merged value passed to Kernel.ValidateConfigDetailed.
With Partial: type errors, constraint violations on fields that ARE set, and disallowed-field errors (under closed schemas) all still surface. Missing required fields do NOT surface — concrete validation is the only pass that flags them, and Partial disables it.
Use Partial for callers that intentionally validate incomplete drafts: CLI lint subcommands, IDE/LSP live feedback, admission webhooks that see only one of several values sources.