Constructor and Descriptor
OCM uses two YAML formats that look alike but have different purposes. A component constructor is the file you write and
edit to say what a component version should contain. A component descriptor is the final record of a component
version, which OCM stores, signs, and transfers. Construction (ocm add cv) turns the first into the second.
Why OCM Needs Two Formats
- The author knows files and URLs. When you build a component, you point to a local file, a directory, a Helm chart, or an image that already exists in a registry. You do not know where OCM will store the content, and you should not have to compute digests by hand.
- The consumer needs exact locations and digests. Whoever downloads, verifies, or deploys a component version needs to know where each resource lives and which content to expect. A file path on the author’s machine means nothing to them.
- A signature needs content that does not change. A signature covers the normalised form of the descriptor,
which leaves out the
accessof each resource. Changing the signed content of a stored descriptor breaks the signature, but a transfer can still rewrite eachaccessto point to the new location. The constructor, in contrast, you can edit as often as you like.
How Construction Works
flowchart LR
C["Component Constructor"] --> R{"Each resource"}
R -->|input| I["Read content,<br/>store as local blob"]
R -->|access| A["Take access as given"]
I --> D["Compute or check digest"]
A --> D
D --> CD["Component Descriptor"]
CD --> Repo[("Component Version Repository")]
Construction processes every resource of a component and writes the result into a descriptor. OCM then stores the descriptor in the target component version repository, for example an OCI registry or a CTF archive.
A constructor resource carries either input or access. An input is content that construction adds to the
component version, such as a file (File/v1), a directory, a Helm chart, or a download from a URL (Wget/v1). An
access is a reference to an artifact that already exists, such as an OCI image or an HTTP URL. A descriptor resource
carries only access. After construction, every resource is a reference, either to a local blob or to an external
artifact.
For an input, OCM reads the content and stores it as a local blob next to the component version. The descriptor
records a LocalBlob/v1 access and the digest of the content. The relation defaults to local, and the resource
version defaults to the component version.
For an access, OCM keeps the access as given. The relation defaults to external, and the resource version has
no default. OCM computes the digest when it has a digest processor for the access type.
A digest in the constructor is optional. When you set it and OCM can compute the digest of the content, it works as
a pin. Construction compares the two and fails on a mismatch. When OCM cannot compute the digest, it records the one
you set without checking it.
Some fields steer how construction handles a resource but do not reach the descriptor, for example the per-resource
options, such as the ownership policy.
Component references get the digest of the referenced component descriptor. This binds the referenced component version to the referencing one, so a signature over the parent also covers its children.
Here is one resource as you write it in the constructor:
resources:
- name: mylocalfile
type: blob
input:
type: File/v1
path: ./my-local-resource.txtAnd here is the same resource in the descriptor after construction:
resources:
- name: mylocalfile
type: blob
relation: local
version: 1.0.0
access:
type: LocalBlob/v1
localReference: sha256:70a2577d7b649574cbbba99a2f2ebdf27904a4abf80c9729923ee67ea8d2d9d8
mediaType: text/plain; charset=utf-8
digest:
hashAlgorithm: SHA-256
normalisationAlgorithm: genericBlobDigest/v1
value: 70a2577d7b649574cbbba99a2f2ebdf27904a4abf80c9729923ee67ea8d2d9d8The file path is gone. In its place are a storage location, a media type, a relation, a version, and a digest.
Relationship to Other Concepts
- Component Identity: the name and version you set in the constructor become the identity of the component version in the descriptor.
- Resource Repositories: an
accessin the descriptor points into a resource repository, where the resource content lives. - Signing and Verification: signatures cover the descriptor, never the constructor. The digests construction records are what a signature binds.
- Transfer: transfer moves descriptors and, if configured, their resources between repositories. The constructor plays no part.
- Ownership: the ownership policy is a constructor option that construction applies to a resource; it is not written to the descriptor.