Documentation
¶
Overview ¶
Package core provides shared primitives for the OPM rendering pipeline. Resource is the atomic output unit. Label constants and GVK weights support downstream K8s inventory and apply ordering.
This package depends on the CUE SDK and k8s.io/apimachinery; nothing below internal/cmdutil/ should import it directly (use the Unstructured adapter there).
Index ¶
- Constants
- func IsOPMManagedBy(value string) bool
- type Resource
- func (r *Resource) APIVersion() string
- func (r *Resource) Annotations() map[string]string
- func (r *Resource) GVK() schema.GroupVersionKind
- func (r *Resource) Kind() string
- func (r *Resource) Labels() map[string]string
- func (r *Resource) MarshalJSON() ([]byte, error)
- func (r *Resource) Name() string
- func (r *Resource) Namespace() string
- func (r *Resource) String() string
- func (r *Resource) ToUnstructured() (*unstructured.Unstructured, error)
Constants ¶
const ( // LabelManagedBy is the standard Kubernetes label indicating the manager. LabelManagedBy = "app.kubernetes.io/managed-by" // LabelManagedByValue is the runtime-owned value for the CLI actor. // The controller uses LabelManagedByControllerValue instead. LabelManagedByValue = "opm-cli" // LabelManagedByControllerValue is the runtime-owned value for the controller actor. LabelManagedByControllerValue = "opm-controller" // LabelManagedByLegacyValue is the legacy value used before runtime-owned // labels were introduced. Recognized for backward compatibility during // transition but no longer stamped on new resources. LabelManagedByLegacyValue = "open-platform-model" // LabelComponent is the OPM infrastructure label that categorizes the type // of OPM-managed object (e.g., "inventory"). Distinct from component names // set by CUE transformers on application resources. LabelComponent = "opmodel.dev/component" // LabelComponentName is the label injected by the CUE catalog on all application // resources to record which component produced them. Value is the component name. // Set by module.cue in the v1alpha1 catalog: // labels: "component.opmodel.dev/name": name // Used by inventory to track provenance for component-rename safety checks. LabelComponentName = "component.opmodel.dev/name" // LabelModuleReleaseName is the release name label. LabelModuleReleaseName = "module-release.opmodel.dev/name" // LabelModuleReleaseNamespace is the release namespace label. LabelModuleReleaseNamespace = "module-release.opmodel.dev/namespace" // LabelModuleReleaseUUID is the release identity UUID label for resource discovery. LabelModuleReleaseUUID = "module-release.opmodel.dev/uuid" )
OPM Kubernetes label keys applied to all managed resources.
Variables ¶
This section is empty.
Functions ¶
func IsOPMManagedBy ¶
IsOPMManagedBy reports whether a managed-by label value identifies any OPM runtime actor. This accepts the current CLI and controller values as well as the legacy value for backward compatibility with resources applied before runtime-owned labels were introduced.
Types ¶
type Resource ¶
type Resource struct {
// Value is the CUE value of the rendered resource (e.g. a Kubernetes manifest).
// Concrete and fully evaluated — safe to encode directly to YAML or JSON.
Value cue.Value
// Release is the name of the ModuleRelease that produced this resource.
Release string
// Component is the source component name within the release.
Component string
// Transformer is the FQN of the transformer that produced this resource.
Transformer string
}
Resource is a single rendered platform resource produced by the pipeline.
Value holds the raw CUE output from a transformer, avoiding premature conversion to Go-native formats. Callers convert to their required format (YAML, JSON, *unstructured.Unstructured, etc.) only when needed via the conversion methods below.
Release, Component, and Transformer record provenance for inventory tracking and display.
func ResourceFromCompiled ¶ added in v0.7.0
func ResourceFromCompiled(c *librarycore.Compiled) *Resource
ResourceFromCompiled adapts a library *core.Compiled — the kernel's terminal per-transformer output — into the operator's *Resource. The two types carry identical fields (CUE value plus release/component/transformer provenance), so the adapter is a field copy; it exists so the kernel-backed render path can hand its compiled output to the operator's existing inventory and apply pipeline unchanged.
A nil input yields a nil result.
func (*Resource) APIVersion ¶
APIVersion returns the resource apiVersion (e.g. "apps/v1").
func (*Resource) Annotations ¶
Annotations returns the resource annotations from metadata.annotations.
func (*Resource) GVK ¶
func (r *Resource) GVK() schema.GroupVersionKind
GVK returns the GroupVersionKind parsed from apiVersion and kind.
func (*Resource) MarshalJSON ¶
MarshalJSON returns the JSON byte representation of the resource's CUE value.
func (*Resource) Namespace ¶
Namespace returns the resource namespace. Empty for cluster-scoped resources.
func (*Resource) ToUnstructured ¶
func (r *Resource) ToUnstructured() (*unstructured.Unstructured, error)
ToUnstructured converts the resource to a *unstructured.Unstructured. Uses JSON as the intermediate format.