OAM Model
Package oam is launcher’s core: the OAM data model, YAML parser, semantic
validator, and the transform pipeline that turns an Application + ClusterProfile
into Kubernetes manifests. Every document this package parses uses
apiVersion: launcher.gokure.dev/v1alpha1 (SupportedAPIVersion); the one exception is
the raw-document lowering seam, where a RawDocumentLoweringRule may claim a kind under a
consumer-owned group via RawDocumentAPIVersioner (see Lowering).
Document kinds
| Kind | Type | Purpose |
|---|---|---|
Application | Application | The app: components[] (each with type + properties) and traits[]. |
Package | Package | A package’s kurel.yaml descriptor: the declarations of its build-time parameters (ParameterDecl). The application is the separate app.yaml. |
ClusterProfile | ClusterProfile | Platform choices (trait implementations, capabilities) supplied at build time, and the cluster’s Kubernetes release and per-gate feature-gate overrides (spec.kubernetesVersion, spec.featureGates; a library caller passes the overrides to ValidateAuthoredPropertiesForTargetWithGates and TransformContext.FeatureGates, see Property schemas and contract metadata). |
CapabilityDefinition | CapabilityDefinition | Declares the schema of a capability’s rendering: the keys a ClusterProfile binding for it may hold. |
Parts
The rest of this page is split into parts. Each part holds the full text of its sections.
- Pipeline: How a document goes from YAML to manifests.
- Component label and ownership: The label that marks what a component owns, and the metadata keys launcher reserves.
- Names and overrides: How object names, labels and annotations are chosen and overridden.
- Parsing and type identity: The parser, the component type allowlist and how a type name resolves.
- Transform, extension and lowering: The transform step, how to register builtins and the lowering rules.
- Property schemas and contract metadata: Property schemas, what an explicit null means and the contract metadata.
- Policy defaults and capability system: Policy defaults, refusal classes and how a capability renders.
- Fill report: Where a consumer reads who supplies a value the author leaves out, and which policy refusal an authored value can cause.
The headings below stay so that a link to an old section still lands here. Each one links to the part that holds the text. Some also keep the opening lines of the section.
Pipeline
See Pipeline.
Component label and ownership
Every application of a transformed document belongs to one authored component, or to the document as a whole (go-kure/launcher#788). The transform records that as its last step, and two things follow from it: each application reports its owner, and each object it generates carries the owner’s component label.
A component config whose objects can repeat a sensitive value implements SensitiveRenderer:
a check of the ownership wrapper that refuses one of them withholds the object’s name and the
cause unless the render without those values is refused in the same words, and so do
CheckInDocumentCollisions and WarnForcedVolumes over a GenerateApplications inventory.
A trait decorator’s refusal is withheld without that comparison (go-kure/launcher#1784).
Full text: Component label and ownership.
Reserved metadata keys
A consumer that keeps label and annotation keys to itself names them in
TransformContext.ReservedMetadataKeys (go-kure/launcher#790). One rule holds every
application the transform returns to the list, whatever wrote the key: a kind component, a
passthrough or manifests object, a chart rendered at build time, a trait’s annotations,
a postgresql or cnpg-cluster component’s inheritedMetadata, and the metadata a
mariadb or mariadb-backup component hands on (inheritMetadata, podMetadata, the
templates of its Services, Secrets, claims and Jobs; go-kure/launcher#1819). It also holds
the Helm values of a chart Flux renders: any map key in a HelmRelease’s spec.values, and in
the helm component’s values and secretValues before they move into a ConfigMap or a
Secret (LoweringContext.CheckHelmValues, go-kure/launcher#1857), but the keys of a map right
under nodeSelector or matchLabels. A values tree has no schema, so a chart value that only
shares its name with a reserved key is refused too. Values an authored valuesFrom entry
reads, whatever object it names (a ConfigMap an authored configmap trait generates
included), labels a Flux-rendered chart’s own templates set, and a HelmRelease’s
spec.postRenderers stay unread.
Full text: Component label and ownership.
Names and overrides
See Names and overrides.
Name roles and the Naming hook
See Names and overrides.
Outputs: the names a component’s objects get
A consumer that wants to refer to an object a component generates (a Secret an operator
reads, a Service a route points at) needs the object’s name before the document is built.
A component type answers with the optional OutputProvider interface, which the
ComponentLoweringRule claiming the type implements, or the handler when no rule claims it,
as for EndpointProvider. Transformer.ComponentOutputs(comp) returns one Output per
declaration, in the provider’s order: a Key, the object’s Kind (a schema.GroupKind) and
its Name. A key is one identifier (a letter or underscore, then letters, digits and
underscores), so a document can address it as the record parts.<part>.<key> and read its
name as parts.<part>.<key>.name (the part’s own object, key object, is parts.<part>.name);
name and kind are reserved. A model publishes the records it names in spec.outputs as
forwarded outputs, and the build holds each against the component the part emitted. A handler that declares its one object (ComponentObjectProvider) and no outputs of
its own publishes that object as the output object (ObjectOutputKey). A type that provides
no outputs and declares no object answers (nil, nil). The query parses nothing for that
default, so it answers for a configmap or secret whose properties the build refuses; the
build still refuses them. role-deployment is lowering-only: a document that names it is
refused by the build, so the query’s answer for it is never backed by a build.
Full text: Names and overrides.
Endpoints: what a connection can reach
A component type declares the in-cluster endpoints of its pods (a pod selector, ports and an
optional name) with the optional EndpointProvider or NamedEndpointProvider interface, and a
consumer reads them with Transformer.ComponentEndpoints (or ComponentEndpointsNamed, which takes
the Naming hook) to build its connection graph. A lowering rule that renders other components,
such as a component model, asks about the ones it emitted with Transformer.ComponentEndpointsWithin
(ComponentOutputsWithin for outputs): the query shares the run state and the build deadline of the
rule’s own lowering, so a chain of such rules spends from one budget. A model forwards the endpoints
of its parts, so a connection can name a model component as its target; two parts that declare an
endpoint of one name fail the query. A rule that answers the query for the kind it emits (the
derived-defaults types) prepares its member as the engine prepares a plain kind: ReadObjectMetadata
reads and checks the member’s labels and annotations as the engine does for the kind.
The platform keys TransformContext.EgressPeers and IngressPeers by the component it knows, which
for a model is the authored component and not a part’s emitted name. The NetworkPolicy synthesis
reads an entry’s egress peers under its emitted name first and under its authored component’s name
after, and each emitted entry gets its own egress policy. Endpoint ingress is read for the component
as a whole: where any entry has peers under its own emitted name, only those entries get policies and
the authored component’s list is ignored; where none has, the authored list is served by the
component’s first entry by name. A key that names an emitted entry of one component and the authored name of
another refuses the build, because it would give one component’s peers to the other’s pods.
A platform that can name a component’s pods (its component label) but not their ports supplies the
all-ports form: AllPorts on an IngressPeers endpoint or an EgressPeers peer opens every TCP port
of the selected pods, as one port entry {protocol: TCP} with no port. It excludes Ports, needs a
non-empty matchLabels-only selector (an egress peer without one fails the build; such an endpoint
emits nothing) and is TCP only; an empty Ports without it never means every port.
ComponentEndpoints refuses an endpoint provider that returns it.
Full text: Pipeline.
objectName: the object of a kind component
See Names and overrides.
labels and annotations: the metadata of a kind component’s object
See Names and overrides.
Parsing
See Parsing and type identity.
A library caller’s own component type is registered with Transformer.RegisterAuthoredComponent
instead of RegisterComponent, so that ParseWithExtraTypes with that transformer’s
LowerableTypes() accepts it (go-kure/launcher#1703). A type registered with RegisterComponent
alone stays refused. The rule is under
Parsing and type identity.
A component handler whose type is declared by a CRD the build holds can also implement
KindScopeDeclarer: it states the kind its type emits and the scope the CRD gives it, and the object
kind check (ObjectKindPolicy) reads that scope for the kind, so a kind kure does not register is not of
unknown scope where the definition is loaded (go-kure/launcher#1744). definition.Handler implements it.
The check counts a declaration only from a handler marked with Transformer.MarkScopeTrusted
(shipped.Load marks what launcher ships) or for a kind the policy names in the optional
TrustedScopePolicy.TrustedScopeKinds(), so an author’s definition cannot relax a policy it does not own
(go-kure/launcher#1758).
The rule is under Policy and capability.
A path that a document names, such as an environment binding’s profile or a component
definition’s CRD file, is read through ResolveInside(dir, rel). It resolves every symlink and
returns ErrPathOutsideDirectory for a target outside dir, which the text of a relative path
cannot show.
Component type allowlist
See Parsing and type identity.
Type identity
See Parsing and type identity.
Grammar
See Parsing and type identity.
Resolution
See Parsing and type identity.
Declaring and resolving
See Parsing and type identity.
Transform & extension
See Transform, extension and lowering.
A library caller hands properties to ComponentHandler.ToApplicationConfig, Transformer.Transform and
Transformer.TransformWithPolicy. It must not change memory it handed over, a pointee inside the properties
included, until it has used the result. The passthrough component copies the maps, slices and arrays of its
properties, and does not copy through a struct or the target of a pointer, so its Generate emits what a
pointee, or a map or slice inside a struct, holds at that call. RegisterComponent,
RegisterAuthoredComponent and RegisterComponentLowering panic when the plain name resolves to one
declared type that is registered under another key, as their other collisions do
(go-kure/launcher#1716; see
Declaring and resolving).
Registering the builtins
See Transform, extension and lowering.
Lowering
Some documents, components, traits, and policies are authored in a higher-level
vocabulary that has no direct dispatchable handler — a type a platform wants expanded
into one or more terminal types before the transform’s own component/trait dispatch
runs. Where a component lowering rule places each object it emits (a same-name
sibling member, a trait on one member, or a separately named kind component), and
how a trait builds the same object as its kind twin, is set out in
docs/oam/design-lowering-engine.md, section “Where a lowering rule places each
object”.
After each lowering round, the engine resolves the types that a rule emitted. A type
written as a declared identity becomes the registered name. A plain name that a handler or
a rule is registered under stays as written, so a rule that emits plain names changes
nothing. Where emission validation runs and the registered name declares a schema, the
properties of an emitted component, trait or policy are checked against that schema, also
when the rule wrote the type as an identity. The same holds for the platform-reserved check
and for the members of a same-name sibling group. A rule reads the Naming hook of the run
through LoweringContext.NamingHook.
A consumer sees what a configuration-defined model emits through TransformContext.EmitHook.
The model rule calls it through LoweringContext.EmitModelComponent, once for each component it
emits, in part order and only after the whole render succeeded. The call carries a ModelEmit: the
model key, the part id, the type as the model wrote it, the name the build gave, the properties and
the traits the model emitted the component with. Those are in the order of the part, each a Trait
with only its type, as the model wrote it, and its evaluated properties. A trait whose when is
false is not among them, and the capability merge and trait lowering have not run on them. Every map,
slice and array in the properties and the traits is copied. A pointer or a struct in them is not
followed: what it refers to is shared, so a hook must not change that. A hook error fails the transform and names the model and the part. A Go lowering rule
and an authored component never reach the hook, and a nil hook asks nothing. The model rule keeps the
limits of the whole build (parts, cost, emitted properties bytes and time) in LoweringContext.RunState,
so that they belong to one transform. A caller sets the time limit of a build in
TransformContext.ModelBuildTimeout (zero is the default of one second, a negative value is refused);
the model rule reads it through LoweringContext.ModelBuildTimeout.
A component lowering rule seals the traits it writes by hand: they skip the capability merge, the
missing-binding refusal and the consumption record, and, when the rule’s input counted as checked
(it declares a property schema, or its input was synthesized), the platform-reserved refusal too.
A rule that implements AuthoredTraitEmitter and returns true from EmitsAuthoredTraits() is the
exception. The model rule does, because its traits are written in the model, as an author writes a
trait in app.yaml, so its hand-written traits take every one of those steps like an authored trait
(see Component Models).
A component lowering rule whose output counts as checked marks the components it emits synthesized, and
the engine then skips the capability defaults, the capability fill and the authored property checks of the
emitted type. A rule that implements AuthoredComponentEmitter and returns true from
EmitsAuthoredComponents() is the exception: its components carry the author’s own values, with at most
the defaults the rule fills itself (the derived-defaults types of
pkg/oam/builtin/components), so they stay authored and the
type’s own handler does for them what it does for the plain kind.
Transformer.CheckComponentTypes is a dry run of DeclareComponentTypes. It checks that
the declaration is valid and declares nothing. It does not need the handler or rule to be
registered yet, and DeclareComponentTypes does. A component model registers its rule
only after this check passes (see Component Models).
Both validate only the identities they are given: what is already declared was validated when it
was declared, and is copied as it is.
Full text: Transform, extension and lowering.
Property schemas
Handlers may implement PropertySchemaProvider (PropertySchema() map[string]PropertySchema)
to declare a constrained schema for their user-facing properties. PropertySchema is launcher’s
single schema vocabulary — the same type also backs kurel.yaml parameters (ParameterDecl) and
CapabilityDefinition rendering properties. It has Type (string/integer/boolean/number/array/object),
Types, Description, Required, Default, Enum, nested Properties, Items, AdditionalProperties
(default false; escape-hatch fields set it true), AdditionalPropertiesSchema, Exclusive (at most or
exactly one of a group of keys), AtLeastOne (at least one of a group of keys, an empty array not
counted) and RequiredWhen
(a property required while a sibling key is set, or set to a value; see “Property schemas” in the API
reference). The rich fields
(Types, Enum, Properties, Items, AdditionalProperties, AdditionalPropertiesSchema, Exclusive, AtLeastOne, RequiredWhen) are
meaningful only for handler properties: the two flat call sites (kurel
parameters, capability rendering) reject them at decode time, so unifying the type does not widen
their accepted behavior.
AdditionalPropertiesSchema (published as additionalPropertiesSchema) types the values of the keys an
object leaves open, for a map from a free key to a typed value such as {"<group>": ["name", ...]}.
Authored values are checked against it as an array’s elements are checked against Items, and a null
under such a key is stripped as a declared optional key’s null is. A non-nil value schema opens the
object and wins over the boolean AdditionalProperties, which stays the shorthand for “any value”. It
may sit beside Properties (declared keys keep their own schema), and only an object may carry it.
BoundedBy (published as boundedBy) names the refusal classes an authored value at a property
can cause under the environment policy, and never the limit. Nothing reads it to accept or refuse
a value. A handler states its bounds with DeclareBounds, over fragments it may share with other
schemas. A property declares a class when a value at it alone can cause it: the properties that name a
chart (source.url, chart, version of helmtemplate) declare none of the classes of the objects it
renders, which sit on its values and secretValues. The two flat call sites and a model input refuse
the key (go-kure/launcher#1580). A component definition declares the classes of the podSpecs and
markers paths it lists on the top-level property that holds each path (go-kure/launcher#1818); the
class marker-class-unstated is about a definition as a whole, so no property declares it.
Full text: Property schemas and contract metadata.
What an explicit null means on the emitted path
See Property schemas and contract metadata.
Contract metadata
See Property schemas and contract metadata.
Lowering targets and Seal
See Property schemas and contract metadata.
Lowering keys
See Property schemas and contract metadata.
Transformer.ComponentPlainOwners() publishes, beside the key maps, the member each of those
component types emits under the component’s own name in every document (PlainOwner, declared by a
rule’s PlainOwners()). Where the report names no member for an entry under that name, the entry
is read under it. See
The plain owner.
The “no handler” error
See Property schemas and contract metadata.
Policy defaults & enforcement
See Policy defaults and capability system.
A Policy can also carry the caller’s source of bytes for a manifest url and for the chart of a
helmtemplate component through the optional ContentSourcePolicy (ContentSourceOf asks for it):
ContentSource, ContentKey and Content (go-kure/launcher#1669).
A config reports the defaults it applied so the provenance report can name their source.
PolicyDefaultReporter reports what the policy filled (source policy). BuiltinDefaultReporter
reports what launcher’s own code filled, at parse or at generation (source builtin). A path has
one source, the one whose value stands, and BuiltinDefaults() is pure: the same call after
ApplyPolicy ran twice gives the same answer. The engine reads both on a component’s config and on
the config of each sub-application a trait adds, and on the config a decorating trait put in place
of its component’s, once every trait of the document has applied. The raw kinds (deployment,
daemonset, statefulset, job, cronjob) take the upstream spec as authored and fill almost
nothing: a statefulset claim template with no spec.storageClassName gets the platform’s class
from the pvc capability, reported at volumeClaimTemplates[0].spec.storageClassName. A lowering rule that fills a value the author left out marks the path on the component it emits
(Component.Filled, path to reference), and the report then shows that path as builtin with that
reference, not as rendered by the rule: the derived-defaults types of
pkg/oam/builtin/components do. The contract, the fills of each workload kind and
of the traits that report, and what is not reported are
in Transform and lowering.
Refusal classes
See Policy defaults and capability system. Which properties of the built-in types declare a class is under Declared bounds.
The refusal of a Secret in the target.manifest of an externalsecret or clusterexternalsecret
is an *oam.TargetManifestRefusal around the PolicyRefusal: the class is still
RefusalExplicitSecret, and errors.As finds the type, so a consumer never reads the message to
tell it from the same refusal elsewhere. The other refusal of a target.manifest, of a kind the
policy reads, is a bare PolicyRefusal of class RefusalUnreadableObject.
RefusalExplicitSecret also covers an Authorization or Proxy-Authorization header (in any
case) of a probe’s or a lifecycle hook’s httpGet, which the kubelet sends from the pod spec
(go-kure/launcher#1860); which containers are held is in
pkg/oam/builtin/components.
Capability system
See Policy defaults and capability system.
The AllowedCapabilities, ForbiddenCapabilities and RequiredCapabilities lists of a Policy
judge the trait types an author wrote. They also judge the traits that a component rule writes onto
the parts it emits. Launcher’s own component rules are exempt, because their traits are launcher’s
opinions. A library consumer registers those rules with RegisterBuiltinComponentLowering. Any other
rule goes through RegisterComponentLowering, and its emitted traits count.
A refusal that names a capability in its text is an *oam.CapabilityError, which errors.As
finds: its Capability field is the key the text names (a ClusterProfile key, or for the three
policy capability lists the trait type they name), so a consumer never reads the message to learn
it. Four refusals cannot see the matched binding, the three of the policy’s capability lists
and the expose rule’s “ext-auth is not offered” refusal, and they carry the trait type (expose, even
when the binding that matched is expose.<scope>). The text is unchanged, and errors.Is and errors.As still reach the *PropertyError,
*PolicyRefusal, *TransformError or ErrMissingCapability inside
(go-kure/launcher#1687; details under
Capability system).
Capability rendering: types and nulls
See Policy defaults and capability system.