manifest

package
v0.1.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package manifest parses OCI v1 / Docker v2 schema-2 image manifests just enough to extract the layer and config digests they reference.

This is a deliberately narrow parser. We do NOT validate the full OCI schema, do NOT cross-check media types, and do NOT verify signatures. The bytes have already been digest-verified by the cache pipeline before they reach this code, and containerd is the authoritative consumer that performs full validation. The only consumer here is the mirror's speculative layer-prefetch path (the design doc detailed-design.md L332 / architecture.md L180).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChildDigests

func ChildDigests(body []byte) ([]digest.Digest, error)

ChildDigests parses body as an OCI / Docker schema-2 image manifest and returns the digests of every content blob the manifest references - its config blob plus every layer descriptor. The returned slice preserves source order: config first, then layers top-to-bottom (which is also the order containerd will request them).

When body is an image index (manifest list) the function returns (nil, nil): no prefetch can happen until containerd requests the architecture-specific manifest.

Foreign-layer descriptors (those with a non-empty `urls` array) are skipped: they point at non-OCI hosts (Microsoft base layers) and MUST NOT be fetched through Gantry.

The function does not error on individual malformed digest strings inside the manifest; those entries are silently skipped. A parse failure on the manifest envelope itself is returned as an error.

Prefer TypedChildren over ChildDigests for new callers that need the per-digest kind (image-config blob vs layer blob) - e.g. so the per-kind metric label survives end-to-end through the prefetch fan-out into please_pull and StartLocalPull batches.

func IsImageIndex

func IsImageIndex(body []byte) bool

IsImageIndex reports whether body parses as an OCI / Docker schema-2 image index (manifest list). Provided for callers that want to short-circuit before walking child digests.

Types

type TypedChild

type TypedChild struct {
	Digest digest.Digest
	Kind   ifaces.OriginRefKind
}

TypedChild pairs a child digest with the OCI URL-family kind the puller MUST target. Kind is one of ifaces.KindConfig (the manifest's image-config blob, served from /v2/<repo>/blobs/<digest> per the OCI Distribution Spec) or ifaces.KindBlob (every layer descriptor, also served from /v2/<repo>/blobs/<digest>). The two kinds are bytes-equivalent at the registry level but carried separately so observability counters can keep

p2p_origin_pull_total{kind="manifest|config|layer"}

honest end-to-end through the prefetch fan-out and the please_pull wire boundary. Without the split every child digest of a manifest would label as "blob" and the "config" bucket would always be empty in practice - the design intent the observability recommendation calls out.

func TypedChildren

func TypedChildren(body []byte) ([]TypedChild, error)

TypedChildren is the kind-preserving cousin of ChildDigests. Source order is the same: config first, then layers top-to-bottom. Foreign-layer descriptors (non-empty `urls`) and image indexes (.manifests with no .layers) are handled exactly as in ChildDigests; only the return type changes. The config digest is tagged KindConfig; every layer is tagged KindBlob (KindLayer is intentionally NOT introduced - the OCI URL family is /blobs/ for both and downstream pullers do not need to distinguish, only the metric label needs to).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL