Skip to main content

Policy defaults and capability system

The implementation, history and tests of the sections below are on the contributor page.

Policy defaults & enforcement

Policy is a typed accessor interface (no type assertions in handlers) that carries per-environment enforced limits (MaxReplicas, MaxCPU, MaxMemory, MaxStorageSize, AllowedRegistries), defaults (DefaultReplicas, the CPU/memory request/limit defaults, and the workload-shape defaults DefaultStorageSize, DefaultScalerMinReplicas, DefaultScalerMaxReplicas), security flags, and two distinct capability-constraint families: AllowedCapabilities/ForbiddenCapabilities/RequiredCapabilities gate OAM trait-type strings (e.g. “ingress”, “autoscaling”). They judge the trait types an author wrote and the traits a component-position lowering rule wrote onto a part it emitted, so an emitted trait is refused when forbidden or outside the allowed list, and it counts toward RequiredCapabilities because the policy judges the output. Launcher’s own component rules are exempt: the traits they write (topology-spread, pvc, configmap, secret) are launcher’s opinions, so a policy sees the same outcome for them as before. A rule registered with RegisterBuiltinComponentLowering is exempt, and one registered with RegisterComponentLowering (an embedder’s or a model’s) is judged. A trait-position rule’s output is not judged: the authored type is, so a rule that renames expose to ingress leaves the policy reading expose. AllowedContainerCapabilities/ ForbiddenContainerCapabilities gate Linux capabilities on a container’s securityContext.capabilities.add (e.g. “NET_ADMIN”). Both families share the same nil/empty constraint-list convention under NoopPolicy — no Allowed/Forbidden/Required entries means unconstrained — but only the boolean security flags (AllowPrivileged, AllowHostPathVolumes, etc.) are default-deny; a container capability appearing in both an explicit Allowed list and the Forbidden list is rejected, since forbidden always wins, and a nil/empty Allowed/Forbidden list means no restriction/no forbids respectively. Handlers that implement Enforceable receive it via ApplyPolicy; NoopPolicy supplies zero values when no policy is set (so ApplyPolicy is always called with a non-nil value at runtime). A trait’s sub-application runs its ApplyPolicy after the trait’s Apply and is held to the same rule as the TraitHandler: it must not replace, remove or rename a component’s application in the bundle, nor rename a sibling group member’s. The transform fails, naming the trait, its component and the sub-application.

Optional policy interfaces. A check that not every consumer needs is asked through an interface a Policy may also implement, so adding one breaks no implementation. ExplicitSecretPolicy (AllowExplicitSecrets() bool) says whether a document may carry secret values itself: the secret trait, the secret kind component, the helm component’s secretValues and the helmtemplate kind’s, and a core Secret the passthrough or manifests component carries. ExplicitSecretsAllowed(policy) is how a handler asks. A policy that does not implement it allows them, as does no policy at all: this is the permissive side, so a consumer that must keep secrets out of documents has to implement the interface and answer false. A refusal is a ViolationError naming the component, of class RefusalExplicitSecret (below).

ImageReferencePolicy (ImageReferenceLevel() ImageReferenceLevel) says how exact the image references a build emits must be, one of four levels that are not nested:

LevelAcceptsRefuses
anyevery reference that parses, an untagged one and :latest includedone that does not parse
taggeda tag or a digestno tag, :latest, and repo:latest@sha256:...
versiona version tag such as v1.2 or 1.2.3-alpinea digest alone, :latest, any other tag
digestname@sha256:... (latest@sha256:... too)any reference without a digest

ImageReferenceLevelOf(policy) is how it is read. A policy that does not implement it, or answers an empty level, holds tagged, as does no policy at all, which is the rule as it was before the interface: no document changes until a consumer asks. A level that is none of the four is refused, never read as tagged. The level reaches every image a built-in component names: a container’s, an init container’s, a sidecar’s, an image volume’s reference, the images of the CloudNativePG, monitoring and postgresql kinds, and the workloads a chart renders. An Endpoints query checks the syntax of an image only, since an endpoint does not depend on which image runs; the build holds the image to the level where it emits it.

A handler reads the level from Component.ImageLevel(), which the Transformer sets on its working copy of the component before it calls ToApplicationConfig, and a lowering rule reads it from LoweringContext.ImageLevel(). Both read tagged where nothing set them. A handler that builds a fresh Component instead of copying the one it was given loses the level and reads tagged: that fails closed under any, and a config that implements oam.ImageReferenced (ImageReferences() []oam.ImageReference) is held to the stricter levels version and digest by the Transformer’s own reading of the config after the handler returns. A custom handler that parses images calls components.ValidateImageRefAt(image, level); ValidateImageRef stays the tagged form.

SourceReferencePolicy (SourceReferenceLevel() ImageReferenceLevel) is the level of an oci component’s version, a tag or sha256:<digest> that no image rule reads. It defaults to any, since the component checked nothing before: tagged requires a non-empty value that is not latest, as it does for an image, version a version tag or a digest, digest a sha256: value (oam.CheckSourceVersion).

ContentSourcePolicy (ContentSource() oam.ContentSource) hands the build a caller’s source of bytes for the url of a crd or manifests component (go-kure/launcher#1669). It is a dependency, not a constraint: it rides the policy because the policy is the one per-request input a component receives. The source is asked Lookup once the url’s scheme and host pass the policy, before any request, with an oam.ContentKey of kind url that holds the url exactly as the document gave it. A copy is served only if it is within the 5 MiB cap, it records at least one host, every host the caller recorded for it (Content.Hosts) passes AllowedRegistries() (a fetch checks every redirect hop, so a hit checks every recorded host; a fetch always records the first host, so a copy with none is a miss), and its body parses as manifests; any other answer, an error included, is a miss, and the url is fetched. After a fetch that succeeded, Store receives the body and every host the request went to, the first and each redirect hop, in order. A Store error is ignored. A source’s own errors never fail a build and never change its output. A copy it serves is the caller’s word for what the url holds: it can differ from the url’s current body, and a copy that parses as manifests but that the component then refuses (for a crd component, a document that is not a CRD) fails the build as the fetched body would. Storing, expiry and which copies to trust stay with the caller. The same source serves the chart of a helmtemplate component (key kind chart), where a stored chart is checked as a fetched one is: once, on the host of source.url, and no host of Content.Hosts is compared with AllowedRegistries(); a copy that records none is a miss here too. ContentKey and Content carry the fields kure’s chart content source has, so one source can serve both. A policy that does not implement it, and NoopPolicy, fetch every url and every chart.

ObjectKindPolicy says which kinds of object a build may emit and whether it may emit cluster-scoped ones: AllowedObjectKinds() (empty allows every kind), ForbiddenObjectKinds() (a kind on both lists is forbidden) and AllowClusterScopedObjects(). A kind is a schema.GroupKind, matched in any version; a Kind of * matches every kind of its group, the core group is "", and an entry with no Kind fails the transform. One check holds every producer to it: the ownership wrapper the transform’s last step puts on every application reads each object generation emits (a kind component’s, a trait’s, what passthrough and manifests carry, every object a chart renders at build time) as Flux applies it, a list envelope (in any Go representation, read as it is written) by its members and not as an object of its own (a kind ending in List through every List it holds, less one whose items is null, as Kustomize drops it; any other envelope one level, as Flux expands it), each object a layout augmenter adds or edits among those its Generate returned, and the ConfigMap of each configMapGenerator entry it adds under a new name. The scope is kure’s manifest.Scope, given the scope the CRD of a component definition pins for the kind it emits (a component handler declares it through KindScopeDeclarer; definition.Handler does), for an object of that kind whatever component or trait emits it. A declaration counts only from a definition launcher ships (shipped.Load marks what it registers, through Transformer.MarkScopeTrusted) or for a kind the policy names in the optional TrustedScopePolicy, whose TrustedScopeKinds() is matched like AllowedObjectKinds() (a schema.GroupKind in any version, * for a whole group, an entry with no Kind fails the transform). A definition a package author supplies is not trusted by default: it cannot relax a policy the author does not own, and its declaration is ignored whole. An opted-in kind whose CRD says cluster-scoped is still refused where the policy does not allow cluster-scoped objects: the entry trusts the declaration and allows no object. A policy that implements TrustedScopePolicy without ObjectKindPolicy changes nothing. A library caller that held author definitions to an object kind policy and relied on their scope since go-kure/launcher#1750 adds the kinds to TrustedScopeKinds(). A kind of unknown scope (neither built in, registered with kure, nor described by a definition that counts, such as a custom resource whose CRD is installed apart from the build) counts as cluster-scoped whatever namespace the object states. This applies to a caller that passes an object kind policy and loads the definitions, a library caller: kurel build passes no object kind policy and runs no such check. The refusal comes at generation (GenerateApplications, or kure’s layout walk), a ViolationError naming the owning component, of class RefusalObjectKind. A policy that does not implement it allows every kind and cluster-scoped objects, as does NoopPolicy, and the check does not run. Not covered: what a chart Flux installs renders on the cluster, objects a controller creates, and what an RBAC object grants (the API server’s escalate and bind checks hold that to the identity that applies it).

Handlers apply values with the precedence authored > policy default > handler default, then enforce the limits on the resulting effective value — for cpu/memory this explicitly includes the pkg/oam/builtin/components intrinsic handler-default tier (100m CPU / 128Mi memory request, applied by buildResourceRequirements at Generate() time, after ApplyPolicy runs), not just the authored/policy-defaulted value ApplyPolicy sees; see that package’s README, “Policy defaults & enforcement ordering”. An author can opt a container out of its default cpu or memory limit with the string unlimited under limits.cpu/limits.memory; that is tier-1 authored, so a policy default limit does not apply over it, and it is refused with the resource-maximum class where the policy sets MaxCPU()/MaxMemory() for that resource.

For example the scaler trait fills minReplicas/maxReplicas from the scaler defaults when omitted (erroring if neither the trait nor a policy default supplies them), and the pvc/postgresql handlers default the storage size from DefaultStorageSize. See the Policy Interface design note under the Concepts section for the full accessor list and rationale.

Refusal classes

Whatever an ApplyPolicy returns reaches the caller as a *ViolationError naming the component, and so does a trait-type constraint of the policy (ForbiddenCapabilities, AllowedCapabilities, RequiredCapabilities). Its Class says what the refusal is about, so a consumer that reports a security refusal differently from a resource limit does not match error text:

var v *oam.ViolationError
if errors.As(err, &v) {
	switch v.Class {
	case oam.RefusalHostNamespace, oam.RefusalPrivileged, oam.RefusalHostPath:
		// a security refusal of v.Component
	case oam.RefusalUnclassified:
		// not a refusal by the policy, or one that carries no class
	}
}

The classes the library gives are a closed set, the constants below and RefusalClasses(). A RefusalClass is a string, and the value is what a consumer may log or store.

ConstantValueA refusal of
RefusalHostNamespacehost-namespacehostNetwork, hostPID or hostIPC on a pod, under a policy that does not allow that namespace.
RefusalPrivilegedprivilegedA privileged container, and a Windows HostProcess container or pod, under a policy that does not allow privileged workloads.
RefusalHostPathhost-pathA pod’s hostPath volume, and a PersistentVolume’s hostPath or local source, under a policy that does not allow hostPath volumes.
RefusalContainerCapabilitycontainer-capabilityA Linux capability a container adds that the policy forbids or does not list as allowed.
RefusalRegistryregistryA host outside AllowedRegistries, or one that cannot be held to that list: the registry of a container image or of an image volume’s reference; an image an operator chooses because the document names none (cnpg-cluster, cnpg-pooler); the host a chart, a manifests url source or a Flux source is fetched from; an oci:// url that does not name its registry; an Amazon S3 bucket endpoint, whose host Flux picks at runtime.
RefusalResourceMaximumresource-maximumA cpu or memory request or limit over MaxCPU or MaxMemory: on a container, on the pod, or on the pod template of an ACME HTTP01 solver of an issuer or clusterissuer.
RefusalResourceDefaultLimitresource-default-limitA cpu or memory request the document authors above the limit the policy defaults for that resource (DefaultCPULimit, DefaultMemoryLimit), on a container that authors no such limit: the main container, an init container or a sidecar of a workload kind. The author writes a limit or lowers the request.
RefusalStorageMaximumstorage-maximumA storage request, or the capacity of a PersistentVolume, over MaxStorageSize.
RefusalReplicaMaximumreplica-maximumA replica count, an autoscaler’s maxReplicas or a database cluster’s instance count over MaxReplicas.
RefusalExplicitSecretexplicit-secretSecret material the document carries itself, under a policy that forbids explicit secrets (ExplicitSecretPolicy): a secret component or trait, a Secret that passthrough or a manifests source carries, secretValues, a certificate’s keystore password, a fluxcd-provider address that is the credential, and a credential or the fake provider’s data written into a secretstore or clustersecretstore; and the same credential in an object of such a kind that passthrough or a manifests source carries (go-kure/launcher#1830).
RefusalTraitCapabilitytrait-capabilityA trait type the policy forbids or does not list as allowed, and one it requires that the application does not use.
RefusalUnreadableObjectunreadable-objectAn object written elsewhere (rendered by a chart, carried by passthrough or by a manifests source) that the build cannot read, so that it cannot be held to the policy and is refused instead of passed.
RefusalObjectKindobject-kindAn object of a kind the policy forbids or does not list as allowed, or a cluster-scoped one (or one of unknown scope, whatever namespace it states) under a policy that does not allow cluster-scoped objects (ObjectKindPolicy), whatever component or trait emits it; and an object whose kind cannot be told. Refused at generation.
RefusalMarkerClassUnstatedmarker-class-unstatedA component definition (pkg/oam/definition) that does not state, in spec.markerClasses, a marker class the policy bounds (go-kure/launcher#1818): the build cannot tell whether the kind holds a field of that class, so it refuses instead of passing. NoopPolicy bounds image and hostPath, so a definition with no markerClasses is refused under NoopPolicy, which a build with no policy uses. A policy that bounds none of the classes (image level any, no registry list, hostPath allowed, no secret ban, no replica, storage, cpu or memory maximum) refuses no definition. The classes resources and claimSpec (go-kure/launcher#1833) are bounded by a cpu or memory maximum and a storage maximum, so a definition written before them is refused under such a policy until it states both.

The class is the same on every path a refusal comes from: a component’s ApplyPolicy, a post-policy step a lowering rule attached (the 1Gi storage fallback of postgresql over MaxStorageSize), a trait sub-application’s, the check on the objects a chart renders under template delivery, the passthrough and manifests checks, at the transform and again at generation, and the object kind check, at generation only. Of a manifests url source the transform checks the host of the url; the objects it yields are first known at generation, so a violation about one of them comes from Generate, not from the transform. The text of no refusal changed with the class: it is the PolicyRefusal at the end of the cause chain, whose Error() is the text the refusal had.

Unclassified. RefusalUnclassified, the empty string, is the class of a violation whose cause is not a refusal by the policy. No class is guessed from text. It covers:

  • an ApplyPolicy error of another kind: a chart that does not render, a policy default or maximum that does not parse, a policy whose default request is above its own default limit (a defect of the policy: the document authors neither value), a request above a limit the policy did not fill (only a config built in code can hold one: the parser refuses it in a document), and the library’s own rules on an object, which hold with or without a policy (no ephemeral containers, an image with no tag or digest, an undeclared field on a workload or a claim a chart renders);
  • a refusal a consumer’s own Enforceable returns as a plain error;
  • a ViolationError literal that leaves Class out.

Not violations, and so without a class: ErrPlatformReserved and ErrReservedMetadataKey, which stay the sentinels they were, ErrComponentLabelValue, which is a sentinel of the same kind, and a manifests url source that cannot be fetched. One fetch failure is a refusal by the policy all the same, a redirect to a host outside the allowed registries: its error holds a PolicyRefusal of class RefusalRegistry, which errors.As reaches, under no ViolationError.

A refusal in a target.manifest. An externalsecret or a clusterexternalsecret may name the object the operator would write, and that object is held to the policy as passthrough holds one. A Secret there is refused with the class RefusalExplicitSecret, the same as a Secret a document carries as an object. The refusal is a *TargetManifestRefusal around the PolicyRefusal: its At is empty for an externalsecret and externalSecretSpec. for a clusterexternalsecret, and its Error() is At, then target.manifest: , then the refusal’s text, which is the text the refusal had before the type existed. A consumer that gives other advice for this Secret than for one the document carries finds it with errors.As, never by reading the message. The other refusal of a target.manifest, an object of a kind the policy reads, keeps its class RefusalUnreadableObject and is not this type.

A consumer’s own Enforceable returns NewPolicyRefusal(class, message), bare or wrapped with %w, for its violation to carry the class: one of the constants above or a value of its own, which the library passes on as given. The class of a violation is that of the first PolicyRefusal in its cause chain. NewViolationError(component, cause) builds a violation the same way, for a config that reports one itself at generation, as passthrough and manifests do.

Breaking for an unkeyed ViolationError literal, which no longer compiles; a keyed one is unaffected. And for a caller that matched *TransformError on a refusal by the policy raised in a post-policy step: it is a *ViolationError now, with the same text.

Declared bounds

A property schema can name the classes an authored value at that property can cause, in boundedBy (see Property schemas). These built-in types declare them. Each entry is held by a test that shows the refusal; a property with no entry is not shown to be free of a bound.

ClassDeclared on
host-namespacehostNetwork, hostPID, hostIPC; inline and url of manifests and object of passthrough, for a pod in the document (object is an open node); values and secretValues of helmtemplate, open nodes, for a pod the chart renders.
privilegedsecurityContext.privileged and securityContext.windowsOptions.hostProcess of a container; podSecurityContext.windowsOptions.hostProcess; securityContext and podSecurityContext of cnpg-cluster, open nodes; inline and url of manifests and object of passthrough; values and secretValues of helmtemplate, open nodes, for a pod the chart renders.
host-pathvolumes[].type: the refusal is of a volume whose type is hostPath; hostPath and local of persistentvolume; inline and url of manifests and object of passthrough, for a pod volume or a PersistentVolume source; values and secretValues of helmtemplate, open nodes, for the same in an object the chart renders.
container-capabilitysecurityContext.capabilities.add of a container; securityContext of cnpg-cluster, an open node; inline and url of manifests and object of passthrough; values and secretValues of helmtemplate, open nodes, for a container the chart renders.
registryimage of a container; volumes[].image, an open node; url of gitrepository, helmrepository, ocirepository, resourcesetinputprovider, manifests and crd; inline of manifests and object of passthrough, for the image of a pod in the document; source.url of helmtemplate, and its values and secretValues, open nodes, for the image of an object the chart renders; source.url, source.endpoint and source.provider of helm; source.url of oci; endpoint and provider of bucket; image of imagerepository; chart of helmrelease, an open node; imageName of postgresql and cnpg-cluster; pooler of postgresql, postgresql of cnpg-cluster (the image of an extension) and pgbouncer of cnpg-pooler, open nodes; images and componentImages of cnpg-imagecatalog and cnpg-clusterimagecatalog, open lists.
resource-maximumresources.requests and resources.limits, cpu and memory, of a container and of postgresql; the same four under podResources; resources of cnpg-cluster and instanceSidecarConfiguration of cnpg-objectstore, open nodes; acme of issuer and clusterissuer, an open node, for the cpu and memory of an HTTP01 solver’s pod; inline and url of manifests and object of passthrough; values and secretValues of helmtemplate, open nodes, for an object the chart renders.
resource-default-limitresources.requests.cpu and resources.requests.memory of a container.
storage-maximumvolumes[].ephemeral, an open node; volumes[] of webservice and worker, an open node, for the size of a pvc volume that generates its claim; volumeClaimTemplates of statefulset, an open node, for the storage request of each claim template; size of the pvc trait and of persistentvolumeclaim; capacity of persistentvolume, an open node, for its storage key; storageSize of postgresql; storage, walStorage, tablespaces and ephemeralVolumeSource of cnpg-cluster, open nodes; inline and url of manifests and object of passthrough, for a claim, a PersistentVolume or a pod’s ephemeral volume; values and secretValues of helmtemplate, open nodes, for the same in an object the chart renders.
replica-maximumreplicas of deployment, webservice, worker, statefulset, replicaset, replicationcontroller and postgresql; instances of cnpg-cluster; maxReplicas of the scaler trait and of horizontalpodautoscaler; inline and url of manifests and object of passthrough, for a controller or an autoscaler in the document; values and secretValues of helmtemplate, open nodes, for the same in an object the chart renders.
explicit-secretprobes.readiness, probes.liveness, probes.startup, lifecycle.postStart and lifecycle.preStop of a container, open nodes, for an Authorization or Proxy-Authorization header in the handler’s httpGet; containers and initContainers of pod, prometheus, alertmanager, thanosruler, vm-agent, vm-alert and vm-single, and the template node of the pod template kinds and cnpg-pooler (jobTemplate of cronjob), for the same header in a container’s probe or hook; livenessProbe, readinessProbe and startupProbe of vm-agent, vm-alert and vm-single, open nodes, for the same; inline and url of manifests and object of passthrough: a core Secret the document carries, or that header in a pod’s container; secretValues of helmtemplate; address of fluxcd-provider, where the address is itself a credential; password of metallb-bgppeer; keystores of certificate, an open node, for a keystore password; provider of secretstore and clustersecretstore, an open node, for a credential written as a value and for the data of the fake provider; target of externalsecret and externalSecretSpec of clusterexternalsecret, open nodes, for a core Secret written as target.manifest. secretValues of helm declares it under both deliveries. A Secret a chart renders, and a credential header in a pod a chart renders, are refused under no policy, so values of helmtemplate does not.
unreadable-objectinline and url of manifests and object of passthrough: an object the policy check cannot read; values and secretValues of helmtemplate, open nodes, for the same in an object the chart renders; target of externalsecret and externalSecretSpec of clusterexternalsecret, open nodes: a workload, a claim, a PersistentVolume or an autoscaler written as target.manifest, which the build cannot read because the operator renders it, refused under any applied policy; no limit lifts it.

The container properties are those of the main container, at the top of the component, and the same ones under initContainers[] and sidecars[]. Where an entry names no type, it holds for the workload types that keep the reshaped form: webservice and worker.

The kinds that take a pod as the API type leave most of it open, so their bounds sit on the open nodes, with no path below them. pod declares host-namespace on hostNetwork, hostPID and hostIPC; privileged, container-capability, registry, resource-maximum and explicit-secret (a credential header in a probe or lifecycle hook) on containers and on initContainers; privileged on securityContext; resource-maximum on resources; and host-path, registry and storage-maximum on volumes. podtemplate, deployment, statefulset, daemonset, job, replicaset and replicationcontroller declare those eight classes on their one template node, and cronjob on its jobTemplate node.

gitrepository declares registry on url, and helm on source.url: the source the component generates (a HelmRepository, an OCIRepository or a GitRepository, or the helmtemplate under template delivery) is held to the allowed registries. The rest of the Flux sources are held the same way and declare registry on the property that names where they are fetched from: url of helmrepository, ocirepository and resourcesetinputprovider, source.url of oci, image of imagerepository, and chart of helmrelease, an open node of which only a chart template of kind OCIRepository names a host, in its spec.url. A bucket declares it on endpoint and on provider: the gcp provider fetches from storage.googleapis.com and ignores the endpoint, so a refusal of that host sits on provider, and helm declares both as source.endpoint and source.provider for an inline Bucket source. The refusal of an oci:// url that does not name its registry, and of an Amazon S3 endpoint, is the same class on the same property. fluxcd-provider declares explicit-secret on address, for a type whose address is the credential it posts with, and for an azureeventhub address that holds a shared access key. manifests declares registry on url, a redirect to another host included. A document the handler reads object by object declares the classes of the refusals of those objects: the document is the value of inline and is what url names, and the object of a passthrough is one object, an open node. Each of the three lists ten classes: a core Secret is refused under a policy that forbids explicit secrets (explicit-secret), and so is a credential in an object of a kind whose typed component refuses one (SecretStore, ClusterSecretStore, ExternalSecret, ClusterExternalSecret, Certificate, BGPPeer, Provider, Prometheus, ThanosRuler, VMAgent, VMAlert, VMSingle), by that component’s own check (go-kure/launcher#1830); an object the check cannot read is refused (unreadable-object: a workload in an API version the build does not know, an autoscaler whose maxReplicas is not an integer, and, under a policy that forbids explicit secrets, an object of one of those kinds in another version than its typed component reads or whose spec that component’s decode refuses), and every other object is held to what a chart’s rendered objects are held to: the registry, privileged, host namespace, host path, capability and resource rules of a pod, the storage a claim asks for and a PersistentVolume’s capacity and hostPath source, and the replica maximum. The image reference level (an untagged image, :latest) and the refusal of ephemeral containers are plain errors and no class.

An object of a kind kure registers is decoded into that kind’s Go type, the VictoriaMetrics and MariaDB operators’ kinds among them. So a value the type cannot hold, or an unknown key in a VictoriaMetrics relabel rule, fails the parse under any policy, one that allows explicit secrets included, and the parse error can quote a number. Their scope is kure’s too (namespaced), so an object kind policy that allows no cluster-scoped object does not take them as of unknown scope, whichever handler is registered. A raw VMAgent or VMSingle for which the operator creates a ClusterRole is not refused there: only the vm-agent and vm-single components refuse it.

helmtemplate declares registry on source.url and explicit-secret on secretValues, the two refusals that sit on one property; helm under template delivery raises the first through it, and its source.url row holds for that delivery. The classes of the objects a chart renders are declared on its two open nodes, where a value alone can cause them: values lists the ten classes above except explicit-secret, so nine, and secretValues lists all ten, since it is also refused itself. A Secret a chart renders is not refused. source.url, chart and version name the chart and declare none of them, so a form reads those classes from values. helm declares explicit-secret on secretValues under both deliveries (a secret trait on the HelmRelease refuses it under flux, the helmtemplate under template) and nothing on values: under template delivery helm is bounded as helmtemplate is.

Four kinds declare what their own check refuses; three project one object each, and a crd source may carry several CustomResourceDefinitions. crd declares registry on url, a redirect to another host included; its inline source declares nothing, since a CustomResourceDefinition passes the check on the objects of a document and any other object is refused as no CRD, a plain error. horizontalpodautoscaler declares replica-maximum on maxReplicas. persistentvolume declares host-path on hostPath and on local, each a path on the node, and storage-maximum on capacity: an open object of which only the storage key is held to the maximum. A csi or flexVolume source is not checked and declares nothing. persistentvolumeclaim declares storage-maximum on size, which is also the property that decides the outcome when size is unauthored and the policy’s storage default is over the maximum.

Eight more kinds hold one decoded spec to the policy and declare the property each refusal sits on. metallb-bgppeer declares explicit-secret on password; its other five MetalLB kinds raise no policy refusal. certificate declares explicit-secret on its open keystores node, for the password of a JKS or PKCS12 keystore written into the object. issuer and clusterissuer declare resource-maximum on their open acme node, for the cpu and memory limits and requests of the pod template of an HTTP01 solver, under ingress and under gatewayHTTPRoute. secretstore and clustersecretstore declare explicit-secret on their open provider node, for the value of a credential union (seven of them) and for the data of the fake provider. externalsecret and clusterexternalsecret declare explicit-secret and unreadable-object on the open node that holds target.manifest, target and externalSecretSpec: a core Secret is refused under a policy that forbids explicit secrets, and a workload, a claim, a PersistentVolume or an autoscaler is refused under any applied policy, because the operator renders the object and the build cannot read it; no limit lifts that refusal, and the row that holds it asserts it under a policy that limits nothing.

prometheus, alertmanager and thanosruler declare what the pods the operator runs would be held to. replica-maximum sits on replicas, and on shards of a prometheus, whose pods are replicas times shards; registry on image, refused unset under an allowlist because the operator then chooses the image; storage-maximum on storage; resource-maximum on resources. The open volumes, containers and initContainers nodes list the classes of every value below them, and the patch of a reloader container the operator generates is held to the allowlist, since unpatched it runs the operator’s own image. A prometheus also declares registry and resource-maximum on thanos (the sidecar) and explicit-secret on remoteWrite, remoteRead and apiserverConfig; a thanosruler declares explicit-secret on remoteWrite. A prometheus and an alertmanager declare host-namespace on hostNetwork and privileged on securityContext; a thanosruler declares nothing on securityContext, since its HostProcess switch needs a host network it has no field for and is refused as invalid before the policy. The memory request the operator fills where resources names none (200Mi, for an alertmanager and a thanosruler) is held to the memory maximum and sits on resources. podmonitor, prometheus-probe, prometheusrule and servicemonitor raise no policy refusal and declare nothing.

replicationsource and replicationdestination declare the classes on each of their movers, which are open nodes. storage-maximum sits on a mover for the capacity of the volume it provisions (capacity, restic’s cacheCapacity, and the configCapacity of a source’s syncthing), and resource-maximum for the cpu and memory of moverResources. The rsync mover, over SSH, is run as root with seven added Linux capabilities whenever it is authored, so it declares container-capability and has no security context; rsyncTLS, rclone, restic and, on a source, syncthing declare privileged for moverSecurityContext.windowsOptions.hostProcess.

postgresql lowers onto a cnpg-cluster and, with a pooler, a cnpg-pooler, so it declares what their policy check raises for the values it writes: replica-maximum on replicas, registry on imageName and on the open pooler node, resource-maximum on the four cpu and memory entries of resources, and storage-maximum on storageSize. When the document names no image, the default composed from version is refused as an authored one is, and a pooler that names no image is refused under an allowlist; both sit on the property that changes the outcome. The 1Gi storage default under a smaller maximum sits on storageSize. cnpg-cluster declares replica-maximum on instances, resource-maximum on resources, storage-maximum on storage, walStorage, tablespaces and ephemeralVolumeSource, registry on imageName and on postgresql, for the image of an extension, and privileged and container-capability on securityContext and privileged on podSecurityContext; a Cluster that names neither imageName nor imageCatalogRef is refused under an allowlist, on imageName. cnpg-pooler declares registry on pgbouncer, and on its one template node the seven classes of a pod, as the kinds that take a pod do; its instance count is not policed. cnpg-objectstore declares resource-maximum on instanceSidecarConfiguration, and the two image catalogs registry on images (an image and the image volume of an extension) and on componentImages. The other CloudNativePG kinds raise no policy refusal.

trait-capability, object-kind and marker-class-unstated are declared on no property: they are about a type as a whole, the second is the transform’s check on every application, whatever component emitted the object, and the third is about a component definition as a whole. A definition’s own properties declare the classes of its markers and podSpecs on the top-level property that holds the path. unreadable-object is declared only on manifests, passthrough, externalsecret and clusterexternalsecret, and explicit-secret only on manifests, passthrough, helmtemplate, fluxcd-provider, metallb-bgppeer, certificate, secretstore, clustersecretstore, externalsecret, clusterexternalsecret, prometheus and thanosruler. Other built-in types do raise them, some from one property (the secretValues of helm, for one) and some for the type as a whole (a secret component or trait, whatever its properties hold). Those types, like every built-in type not named above, declare no bound yet: that says nothing about whether the policy holds them.

Capability system

Capability-aware traits (e.g. expose, certificate, external-secret) declare required platform inputs; the ClusterProfile provides them, and CapabilityDefinition rendering schemas validate the bindings of custom capabilities (--strict-capabilities turns warnings into errors).

Transformer.CapabilityValidated(typeName) reports whether EvaluateProfile validates a capability rendering of that type. It returns true when a registered trait handler or trait lowering rule implements ValidateAndApplyDefaults, or when a non-built-in type has a CapabilityDefinition whose schema is applied. With none of those validators, EvaluateProfile passes the binding through unchecked.

Pre-GA behavior change: EvaluateProfile now also checks a binding whose type has a CapabilityDefinition but no trait handler and no trait lowering rule. The schema applies its defaults and refuses a rendering that breaks it. Before, such a binding passed through unchecked. Built-in types stay exempt.

The key of a refused capability. A refusal that names a capability in its text is wrapped in an *oam.CapabilityError, which errors.As finds in the error that Transform, TransformWithPolicy, EvaluateProfile and ValidateAuthoredPropertiesWithCapabilities return. Its Capability field is the key the text names, so a caller that adds context reads the field and never the message. The key is a ClusterProfile key, <type> or <type>.<scope>. Four refusals carry the trait type instead, because they cannot see which binding matched: the three by the policy’s ForbiddenCapabilities, AllowedCapabilities and RequiredCapabilities lists (class RefusalTraitCapability), and the expose rule’s “ext-auth is not offered on this platform” refusal, whose key is expose even when the binding that matched is expose.<scope>. The error’s Error() is the text the refusal had, and errors.Is and errors.As still reach what it wraps: a *PropertyError, a *PolicyRefusal under its *ViolationError, a *TransformError and ErrMissingCapability. Breaking only for a caller that compared the returned error with == or by type assertion.

Capability rendering: types and nulls

A CapabilityDefinition rendering property uses the flat vocabulary — string, integer, boolean, or no type at all, which accepts any value. LoadCapabilityDefinitions rejects anything else at load time, and the value check rejects it too, so a definition built in Go and installed with Transformer.SetCapabilityDefs — which bypasses the loader — cannot silently accept every value for a property by declaring a type outside that set.

An explicit null on this surface is absence, matching the contract the handler surface follows, rather than failing as a type error; the null key does not survive into the validated rendering. What happens next depends on required and default, checked in that order — required always wins, even over a declared default:

  • required — reported as required-and-missing. A declared default does not rescue it; requiredness is checked first.
  • optional, with a non-null default — the declared default is substituted.
  • optional, with no default (or default: with no value, which likewise declares no default, not a null one) — the key stays absent.

This holds for a typed nil as well as an authored one, which matters precisely because SetCapabilityDefs takes Go-built definitions.

A declared default is type-checked against its own declared type, on the same footing as a value the document supplies. Without that, a property was validated when the document supplied the value and unvalidated when the schema did — so a Go-built definition declaring integer with a "three" default injected that string into the rendering, past the check that exists to keep it out. Files were never exposed to this (LoadCapabilityDefinitions checks defaults at load); SetCapabilityDefs was, being the same bypass the type check above guards. A property declaring no type still accepts any default, unchanged.

Rendering merge: authored values and nulls

A trait’s matched capability rendering is merged under its properties: an authored value replaces the rendered one at that key, and keys the trait does not author keep the platform value. Where both hold an object, the merge recurses: authoring resources: {limits: {cpu: 2}} over a rendered resources: {limits: {cpu: 1, memory: 1Gi}} gives {cpu: 2, memory: 1Gi}, and an authored {} keeps the rendered object. A list, a value of another kind, and a rendered object built in Go with another type (map[string]string) are replaced whole. An authored null is absence here too, at any depth, so a null over a key the rendering supplies takes the platform value. A null under a key the rendering lacks is left as authored. Pre-GA output changes: the authored null used to replace the rendered value, so the handler saw the key unset; an authored object used to replace the rendered object whole, dropping its sibling keys. This holds for every unsealed trait with a rendering, on both the dispatch path and an unsealed trait lowering rule’s input.

Authored validation checks nested Required on the merged properties too (ValidateAuthoredPropertiesWithCapabilities), so a partial override that omits a required nested key the rendering supplies is accepted. The profile-less ValidateAuthoredProperties still refuses it.

A component handler that implements ComponentCapabilityDefaults (see Transform & extension) gets the same precedence for the properties it lists, and only those. Each value it fills is then validated against the component’s own PropertySchema: a value the trait handler’s schema accepted can still be refused here, with an error naming the component, the capability and the property (component "data": capability "pvc" defaults: properties.storageClassName: expected string, got int). A component with no schema relies on the trait side, and its fill is refused when the component has no schema and no trait handler or trait lowering rule for the capability’s type validates the rendering, meaning it implements ValidateAndApplyDefaults, or the type is not built in and has a CapabilityDefinition applied. A type with no handler, no rule and no applicable CapabilityDefinition, whose binding EvaluateProfile never checks, is refused there too. The error names the component, the capability and the rendering keys. Pre-GA input change: a fill that used to reach a component unvalidated is now refused when nothing validates it, and a value the component’s schema does not accept is refused. No built-in component is affected: persistentvolumeclaim, the only built-in ComponentCapabilityDefaults implementation, declares a schema.

Both merges copy the rendering value they hand out, keeping its Go type: a 3 the profile decoded as int reaches the handler as int, and an int64 above 2^53 keeps its exact value. The copy used to be a JSON round trip, which turned every number into float64. A ComponentCapabilityDefaults fill is then normalized by the component’s schema check like any validated property: a map[string]string under an object property reaches the handler as map[string]any, and a uint32 or named integer under an integer property as int. The profile’s own value is left as it was. A rendering value therefore obeys the same rule as a value a lowering rule writes with RenderReserved: a string, boolean, finite number, list or string-keyed object, nested to any depth. TransformWithPolicy checks every binding in TransformContext.Capabilities before building anything, whether or not a document uses it, and refuses the transform with an error naming the capability key and the top-level rendering key (capability "pvc" rendering key "limits": …). A null top-level value is not refused: it reads as absent. Pre-GA input change: these renderings built before and are now refused:

  • a null below the top level (limits: {cpu: null}), which the round trip kept;
  • NaN or ±Inf (YAML .nan, .inf, -.inf), on which the round trip failed and the trait merge then handed out the profile’s own value;
  • in a Go-built TransformContext.Capabilities, any other Go type (a struct, a pointer, a channel, a function, a map whose keys are not strings): the round trip converted a struct or pointer to its JSON form, and failed on a channel or function, which the trait merge then handed out uncopied.

This is a large internal builder surface; the tables on this page and in Transform, extension and lowering cover the entry points. See pkg.go.dev for the full type reference, the design notes under the Concepts section, and examples/ for runnable applications.