ocm
Writes an OCM component constructor for a target, with every container image of the manifests earlier compile entries wrote as an ociImage resource, an access template for mirrors and pull-through caches, and resources from the inventory for the rest.
- Latest
- 0.1.0 ·
- License
- Apache-2.0
- Owners
- Moep90
- Source
- github.com/kadet-hub/generators · 0 repo stars, shared by 37 generators
- Thumbs up
- 👍 0 on GitHub Discussions
- Popularity
- 6 · 7 pulls
Request a feature Report a problem
Badge
Show the latest listed version in your README. shields.io draws the badge from this page's badge.json, which every catalog build updates; once no version is listed, it reads "not listed".
[](https://kadet-hub.org/generators/ocm/)
ocm Generator
Published on kadet-hub: pin a released version by digest from its catalog page.
Kapitan kadet generator that writes an Open Component Model component constructor for a target. It collects every container image from the manifests earlier compile entries wrote and turns each into an ociImage resource, so the component that ships a target into another environment, an air-gapped one for example, lists exactly the images the target runs. A chart upgrade that adds an image changes the constructor in the same compile. Spec: docs/specs/ocm.md.
The output is the input of ocm add component-version of the new OCM CLI generation (open-component-model/open-component-model). Building, signing and transferring the component stay with the CLI.
Usage
The ocm entry comes last and has output_path: .. Kapitan runs a target’s entries in order and gives a kadet entry its output directory as compile_path, which is then the target’s compile root; images.scan globs are relative to it. output_type: plain is required.
# inventory/classes/ocm.yml
parameters:
ocm:
components:
app:
name: example.org/acme/app
version: \${VERSION}
provider:
name: acme
resources:
manifests:
type: ociArtifact
version: \${VERSION}
access:
type: ociArtifact
imageReference: \${REGISTRY}/acme/app-manifests:v\${VERSION}
images:
scan:
- k8s/**/*.yml
- k8s/**/*.yaml
access: \${PROXY_%registry_id%}/%path%
label: upstream
require_digest: true
kapitan:
dependencies:
- type: oci
source: ghcr.io/kadet-hub/ocm@sha256:<digest>
output_path: lib/ocm
compile:
# ... the entries that write k8s/ ...
- input_type: kadet
input_paths:
- lib/ocm
output_path: .
output_type: plain
input_params:
file: ocm/component-constructor.yaml
components: ${ocm:components}The example is for reclass-rs, where \${VERSION} escapes the reference so the constructor keeps ${VERSION} for the CLI to fill in (ocm add cv ... VERSION=1.2.3). Kapitan’s OmegaConf backend resolves an escaped value twice, so there write ${escape:VERSION}, ${escape:PROXY_%registry_id%}/%path% and ${ocm.components}. The template tokens use % because OmegaConf rejects { and < inside ${escape:...}.
With these parameters, ghcr.io/stefanprodan/podinfo:6.15.0@sha256:<d> in a Deployment becomes:
- name: podinfo
type: ociImage
version: 6.15.0
labels:
- name: upstream
value: ghcr.io/stefanprodan/podinfo:6.15.0@sha256:<d>
access:
type: ociArtifact
imageReference: ${PROXY_ghcr_io}/stefanprodan/podinfo:6.15.0@sha256:<d>Parameters
input_params:
| Key | Meaning |
|---|---|
components |
Map of id to component. The id orders components and names them in errors. Required. |
file |
Output path relative to the compile root, default component-constructor.yaml. |
A component needs name, version and provider. labels, sources, componentReferences and any other key are copied as written. Two keys are read by the generator:
| Key | Meaning |
|---|---|
resources |
Map of resource name to resource, copied as written with name set to the key, before the image resources. A map lets classes add resources per target. |
images.scan |
Glob patterns relative to the compile root. Every string value of an image key, at any depth, in the matched YAML files is an image. A pattern matching no file fails the compile. |
images.refs |
Extra image references, for images no manifest names. |
images.access |
Template for imageReference, default %ref% (the reference as written). Tokens: %ref%, %registry%, %registry_id% (registry with non-alphanumerics as _), %path% (after the registry, tag and digest included). Nothing else is replaced. A static mirror is mirror.example.org/%registry%/%path%. |
images.label |
Label name; each image resource gets it with the upstream reference as value. |
images.require_digest |
true fails the compile on an image without digest. |
images.names |
Map of repository (ghcr.io/org/app, docker.io/library/redis) to resource name, for two images whose derived names clash. |
An image resource is named after the last path segment of its repository and versioned by its tag; a reference without registry is a Docker Hub one (redis:8 is docker.io/library/redis:8), a reference without tag and digest is latest.
Failure modes
The compile fails, naming the cause, on: an unknown key in input_params or images; a component without name, version or provider; a scan pattern that matches no file or a file outside the compile root; a scanned file that is not YAML; an image with a digest but no tag; with require_digest, an image without digest; two resources with the same name; an images.names key that matches no image.
Without output_type: plain Kapitan dumps the returned text as a YAML string. Without output_path: . the scan globs cannot reach the other entries’ output.
With kapitan compile --cache, the result is keyed on the inventory and input parameters, not on the files the generator reads: a changed image with no inventory change can reuse the old constructor.
Versions
Add a version's inventory entry, then compile with the consumer workflow, which verifies the artifact and runs Kapitan in the sandbox.
Free of charge, as is and on a best-effort basis: use at your own risk, and review the compiled output before you apply it. Terms
This catalog was built from index serial 72. Set index_serial: 72 in .kapitan-sandbox.yaml and the consumer workflow refuses any older index, so a rolled-back index cannot bring back a yanked version.
Checks find known patterns; they do not prove a generator safe. What a listing covers
| Version | Built for (schema-checked) |
|---|---|
| 0.1.0 | not recorded |
0.1.0#
Inventory
parameters:
kapitan:
dependencies:
- type: oci
source: ghcr.io/kadet-hub/ocm:0.1.0@sha256:830a1c1d3f33cd16e6ea29f4fac7262e0410edab51d900af8a57eff19f2c95a1
output_path: lib/ocm
Verify
gh attestation verify \
oci://ghcr.io/kadet-hub/ocm@sha256:830a1c1d3f33cd16e6ea29f4fac7262e0410edab51d900af8a57eff19f2c95a1 \
--owner kadet-hub \
--cert-identity https://github.com/kadet-hub/registry/.github/workflows/release.yml@refs/heads/main
Transparency log: Rekor entry 3523121924, in Sigstore's public, append-only log, so the attestation stays checkable independent of this site.
- Kapitan declared
- >=0.36.3,<0.37
- Kapitan checked
- 0.36.3
- Backends checked
- reclass-rs, omegaconf
- With --cache
- passed
- krab
- compatible
- Built for (schema-checked)
- not recorded
- Source
- ocm-v0.1.0 ·
01d9c3c0b530dfd3dd256c9e8d946983ad2c7f3a· ocm - Binaries
- none
- Output capabilities
- none
- Digest
sha256:830a1c1d3f33cd16e6ea29f4fac7262e0410edab51d900af8a57eff19f2c95a1
Checks
Checked by the release run on , gate at b0aa52b60bfd.
- Secrets gitleaks 8.30.1
No secret matched the marketplace's gitleaks rules. - Malware ClamAV 1.5.4
No file matched a ClamAV signature. - Malicious package heuristics GuardDog 3.2.0
No GuardDog threat rule matched. - Dangerous code Semgrep 1.180.0
No marketplace Semgrep rule matched, such as eval, subprocess or network calls. - Python errors Ruff 0.17.0
No syntax error or undefined name (Ruff, error rules only). - File tree tree_check.py
No symlink, executable or banned file; imports within the allowlist. - Sandboxed compile gVisor 20261005, Kapitan 0.36.3
The fixture compiled without network, with decoy credentials; no undeclared program ran, no decoy was read. - Output capabilities Conftest v0.71.1
The compiled output uses only the capabilities the manifest declares. - CI detection Kapitan 0.36.3
The output is the same with CI variables set.
Output diff
No output diff: no earlier listed version.