Documentation
¶
Index ¶
- Variables
- func BuildInstanceOverlayAt(ctx *cue.Context, moduleRoot, pkg string, overlay map[string]load.Source, ...) (cue.Value, error)
- func LoadInstancePackage(ctx *cue.Context, dirPath string, opts LoadOptions) (cue.Value, error)
- func LoadModulePackage(ctx *cue.Context, dirPath string, opts LoadOptions) (cue.Value, error)
- func LoadPlatformPackage(ctx *cue.Context, dirPath string, opts LoadOptions) (cue.Value, error)
- type LoadOptions
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidPackage marks a structurally invalid package: the built root // is not a struct, or load.Instances did not resolve exactly one instance. ErrInvalidPackage = shape.ErrInvalidPackage // ErrWrongKind marks a package whose concrete kind does not match the // artifact the loader was asked for. ErrWrongKind = shape.ErrWrongKind // ErrMissingRequiredField marks a package missing a required identity // field, or carrying it in non-concrete form. ErrMissingRequiredField = shape.ErrMissingRequiredField )
The module shape gate is single-sourced in opm/helper/loader/internal/shape so that loader/file and loader/registry validate artifacts identically. The sentinels are re-exported here with unchanged identity: existing errors.Is(err, file.ErrWrongKind) callers keep working because these are the same error values the shared gate wraps. See shape for the gate itself.
Functions ¶
func BuildInstanceOverlayAt ¶
func BuildInstanceOverlayAt(ctx *cue.Context, moduleRoot, pkg string, overlay map[string]load.Source, opts LoadOptions) (cue.Value, error)
BuildInstanceOverlayAt evaluates an in-memory #ModuleInstance package that lives in a SUBDIRECTORY (pkg, e.g. "./opm-synth-instance") of a module rooted at moduleRoot, supplied as a load.Source overlay. moduleRoot is the load.Config.ModuleRoot, so the overlay's cue.mod/module.cue at that root — typically a registry-staged module's own already-tidied module file — drives transitive dependency resolution, while the instance package itself is loaded from the subdirectory. Pass pkg "." to load the package at the module root.
This is the entry point synth.Instance uses to construct an instance INSIDE the acquired module's own staged source tree (so the module import resolves locally and the module's tidied closure is reused), rather than fabricating a standalone module. It runs the same build-and-shape-gate step (shape.InstanceSpec) as the on-disk LoadInstancePackage. opts.Registry, when non-empty, overrides CUE_REGISTRY via load.Config.Env (never os.Setenv), so it is safe under concurrency.
Was: BuildInstanceOverlay / BuildReleaseOverlay
func LoadInstancePackage ¶
LoadInstancePackage loads a #ModuleInstance CUE package from a directory and returns the raw cue.Value. Mirrors LoadModulePackage: every .cue file in dirPath that shares the package is unified into a single instance, so authors can split an instance across instance.cue, values.cue, and overlay files within one CUE package.
LoadOptions.Registry, when non-empty, is applied via load.Config.Env so the instance's module imports resolve from the override registry without mutating process state.
The recommended entry point is Kernel.LoadInstancePackage, which owns its *cue.Context and threads cross-cutting dependencies through every operation. Call this function directly only if you are not using a Kernel.
Was: LoadReleasePackage
func LoadModulePackage ¶
LoadModulePackage loads a module CUE package from a directory and returns the raw cue.Value. Used by callers (e.g. opm module vet) to load a module for validation or rendering.
LoadOptions.Registry, when non-empty, is applied via load.Config.Env so the module's transitive imports (transformers, traits, sub-modules) resolve from the override registry without mutating process state.
The recommended entry point is Kernel.LoadModulePackage, which owns its *cue.Context and threads cross-cutting dependencies through every operation. Call this function directly only if you are not using a Kernel.
func LoadPlatformPackage ¶
LoadPlatformPackage loads a #Platform CUE package from a directory and returns the raw cue.Value. Mirrors LoadModulePackage and LoadInstancePackage: every .cue file in dirPath that shares the package is unified into a single instance, so the platform is identified by its CUE package clause rather than a platform.cue filename.
LoadOptions.Registry, when non-empty, is applied via load.Config.Env so the platform's transitive imports resolve from the override registry without mutating process state.
The recommended entry point is Kernel.LoadPlatformPackage, which owns its *cue.Context and threads cross-cutting dependencies through every operation. Call this function directly only if you are not using a Kernel.
Types ¶
type LoadOptions ¶
type LoadOptions struct {
// Registry overrides the CUE_REGISTRY value used while loading. Empty
// means use the current process environment.
//
// The override is applied via load.Config.Env, NOT os.Setenv, so the
// loader is safe to call concurrently from a long-running service
// (Crossplane function, REST API, embedded SDK).
Registry string
}
LoadOptions configures package-loader behavior shared by LoadModulePackage, LoadInstancePackage, and LoadPlatformPackage.