module

package
v1.0.0-alpha.15 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package module defines the Module type, mirroring the #Module definition in the OPM core schema. A Module represents the parsed module definition before it is built into an instance.

Debug overlays. The CUE schema includes a `debugValues` field on every `#Module` for author-supplied example values used by build/validation tooling. `debugValues` is a Module field — NOT a separate kernel artifact — and it is read off Module.Package via schema.DebugValues. Whether a frontend layers debugValues into the values stack is a policy decision that lives in the helper layer; the kernel itself never observes the distinction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CueContextOwner

type CueContextOwner interface {
	CueContext() *cue.Context
}

CueContextOwner is the minimal context-owner interface accepted by the constructor helpers. *kernel.Kernel satisfies it; tests may pass any value exposing a *cue.Context. The interface lives in opm/module to keep the constructor's import surface free of opm/kernel.

type Instance

type Instance struct {
	// Metadata is the decoded instance-level metadata cache. May be nil when
	// the metadata could not be decoded.
	Metadata *InstanceMetadata

	// Package is the loaded, concrete CUE value for the instance artifact.
	// Source of truth for every field reachable via opm/schema, including
	// the embedded #module reference at schema.Module.
	Package cue.Value
}

Instance is an OPM #ModuleInstance artifact in the unified artifact shape.

Package is the source of truth: it is the concrete, values-filled CUE value for the instance and every kernel-internal read (components subtree, source module, transformer match data) goes through Package.LookupPath with paths from opm/schema.

Metadata is an ergonomic decoded projection of the instance-level metadata stamped at construction. It is a cache, not a parallel source of truth — when Metadata and the corresponding subtree of Package disagree, Package wins.

Was: Release

func NewInstanceFromValue

func NewInstanceFromValue(_ CueContextOwner, v cue.Value) (*Instance, error)

NewInstanceFromValue builds a *Instance from a raw CUE artifact value. The supplied k is currently unused but preserved in the signature so future kernel-scoped state can be threaded without an API break.

The function decodes InstanceMetadata via schema.DecodeInstanceMetadata and stores the input cue.Value unmodified in Package. Errors return a nil *Instance.

Was: NewReleaseFromValue

func (*Instance) Annotations

func (r *Instance) Annotations() map[string]string

Annotations returns the instance-level annotations.

func (*Instance) ConfigSchema

func (r *Instance) ConfigSchema() cue.Value

ConfigSchema returns the embedded source module's #config schema reachable via schema.Module followed by schema.Config on r.Package.

All failure modes return the zero cue.Value (not an error): a nil receiver, a missing #module reference, or a missing #config definition on the embedded module.

func (*Instance) InstanceFQN

func (r *Instance) InstanceFQN() string

InstanceFQN returns the instance's OWN fully qualified name — metadata.fqn (registryPath:name:namespace, core v2), decoded into the metadata cache. Distinct from ModuleFQN, the source module's identity.

func (*Instance) InstanceName

func (r *Instance) InstanceName() string

InstanceName returns the instance's metadata.name.

Was: ReleaseName

func (*Instance) InstanceUUID

func (r *Instance) InstanceUUID() string

InstanceUUID returns the instance's metadata.uuid.

Was: ReleaseUUID

func (*Instance) Labels

func (r *Instance) Labels() map[string]string

Labels returns the instance-level labels (already merged with module labels at CUE evaluation time).

func (*Instance) MatchComponents

func (r *Instance) MatchComponents() cue.Value

MatchComponents returns the schema-preserving components value used for matching. The returned value keeps definition fields such as #resources, #traits, and #blueprints.

func (*Instance) ModuleFQN

func (r *Instance) ModuleFQN() string

ModuleFQN returns the source module's fully qualified name. The value is read from Package.LookupPath(schema.ModuleMetadataPath).fqn so that Package remains the source of truth for module identity.

func (*Instance) ModuleVersion

func (r *Instance) ModuleVersion() string

ModuleVersion returns the source module's version, read from Package via the ModuleMetadataPath path.

func (*Instance) Namespace

func (r *Instance) Namespace() string

Namespace returns the instance's metadata.namespace.

type InstanceMetadata

type InstanceMetadata = schema.InstanceMetadata

InstanceMetadata is a re-export of schema.InstanceMetadata so callers can keep working with `module.InstanceMetadata`.

Was: ReleaseMetadata

type Module

type Module struct {
	// Metadata is the decoded module-level metadata cache. Authoritative data
	// lives in Package; Metadata exists for hot-path access (logging, name
	// lookups). May be nil when the metadata could not be decoded.
	Metadata *ModuleMetadata `json:"metadata"`

	// Package is the loaded CUE value for the module artifact. Source of
	// truth for every field reachable via opm/schema's path vars.
	Package cue.Value `json:"-"`

	// Source is the module's staged registry source tree (synthetic root +
	// overlay), populated only when the module was acquired through the
	// source-carrying registry path (Kernel.AcquireModuleFromRegistry). It is
	// nil otherwise. Consumers that must build inside the module's own root
	// (e.g. synth.Instance) gate on HasSource(). See source.go.
	Source *Source `json:"-"`
}

Module represents an OPM #Module artifact in the unified artifact shape.

Package is the source of truth: it is the loaded CUE value for the module and every kernel-internal read (the #config schema, components subtree) goes through Package.LookupPath with paths from opm/schema.

Metadata is an ergonomic decoded projection of the module-level metadata stamped at construction. It is a cache, not a parallel source of truth — when Metadata and the corresponding subtree of Package disagree, Package wins.

func NewModuleFromValue

func NewModuleFromValue(_ CueContextOwner, v cue.Value) (*Module, error)

NewModuleFromValue builds a *Module from a raw CUE artifact value. The supplied k is currently unused but preserved in the signature so future kernel-scoped state (logger, tracer, clock) can be threaded without an API break.

The function decodes ModuleMetadata via schema.DecodeModuleMetadata and stores the input cue.Value unmodified in Package. Errors return a nil *Module — partial values are never returned.

func (*Module) ConfigSchema

func (m *Module) ConfigSchema() cue.Value

ConfigSchema returns the module's #config schema reachable via schema.Config on m.Package.

All failure modes return the zero cue.Value (not an error): a nil receiver or a missing #config definition on the module package. Callers detect failure via the returned value's Exists() method.

func (*Module) HasSource

func (m *Module) HasSource() bool

HasSource reports whether the module carries a staged registry source tree (non-nil Source with a populated overlay). Consumers that must build inside the module's own root — e.g. synth.Instance — gate on this and return a deterministic error when it is false, rather than silently fetching.

type ModuleMetadata

type ModuleMetadata = schema.ModuleMetadata

ModuleMetadata is the decoded module-level identity record. It is a re-export of schema.ModuleMetadata so callers can keep working with `module.ModuleMetadata` without taking a transitive dependency on opm/schema at every reference site.

type Source

type Source struct {
	// Root is the synthetic absolute module root every Overlay key sits under.
	// It is the load.Config.ModuleRoot a consumer builds against.
	Root string

	// Overlay maps absolute paths under Root to their file contents, exactly as
	// load.Config.Overlay expects. Every file of the fetched module is present,
	// including cue.mod/module.cue.
	Overlay map[string]load.Source
}

Source is the staged in-memory source tree of a module fetched from a registry: the deterministic synthetic root the module's files were keyed under, plus the load.Config.Overlay carrying those files (including the module's own cue.mod/module.cue).

It exists so a module acquired from the registry can be RE-USED as the main module of a follow-on build — notably by opm/helper/synth, which stages a #ModuleInstance package inside this tree so the module's own (already-tidied) cue.mod/module.cue drives transitive dependency resolution. Carrying the staged source on the acquired *Module avoids a second registry fetch.

Source is populated only when the module was acquired through the source-carrying registry path (Kernel.AcquireModuleFromRegistry). It is nil for modules constructed from a bare value (e.g. a unit-test CompileString or the value-returning LoadModuleFromRegistry path).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL