Documentation
¶
Overview ¶
Package spec defines the mirror store's on-disk contract: the repo-root mirror.yaml (global defaults), the per-entry manifest.yaml files (intent), the lock files (facts), the generated images.extra.yaml sidecar, and the CVE allowlists. The tree itself is the registry of entries — discovery globs charts/*/manifest.yaml and artifacts/*/manifest.yaml; mirror.yaml never lists them.
Manifests decode strictly (unknown fields are errors), so a typo'd key fails loudly instead of silently reverting to a default. Lock files are written through a fixed-shape emitter rather than a generic YAML encoder, keeping the bytes stable across regenerations — the validate gate byte-compares them.
Index ¶
- Constants
- Variables
- func FindRoot(dir string) (string, error)
- type Allowlist
- type AllowlistEntry
- type AllowlistPolicy
- type ArtifactLock
- type ArtifactManifest
- type ArtifactPublish
- type ArtifactScan
- type ArtifactSpec
- type ChartManifest
- type ChartPublish
- type ChartSpec
- type Config
- type Discovery
- type DistributionManifests
- type Entry
- type ExcludePattern
- type ExtraImage
- type ImageVerifyRule
- type Images
- type ImagesLock
- type KMSSigning
- type KeylessSigning
- type KubescapeScanner
- type LockArtifact
- type LockChart
- type LockImage
- type OCIRefAllow
- type OCIRefs
- type Registry
- type Scan
- type ScanOverride
- type ScanPolicy
- type ScannerToggle
- type Scanners
- type Sidecar
- type Signing
- type Track
- type Update
- type VerifyRule
Constants ¶
const ( KindMirrorConfig = "MirrorConfig" KindChart = "Chart" KindArtifact = "Artifact" )
The kinds the schema defines.
const APIVersion = "mirror.patchy.bitwisemedia.uk/v1alpha1"
APIVersion is the schema identity every mirror file declares.
const AllowlistFile = "security/allowlist.yaml"
AllowlistFile is an entry's allowlist path relative to its directory.
const ConfigFile = "mirror.yaml"
ConfigFile is the name of the root configuration file; its directory is the mirror root.
const SidecarFile = "images.extra.yaml"
SidecarFile is the generated extra-images sidecar, relative to an entry directory. Machine-derived extras (distribution manifests) land here and are merged during discovery, so manifest.yaml stays a pure intent file that no machine ever rewrites.
Variables ¶
var ErrNoRoot = errors.New("no " + ConfigFile + " found")
ErrNoRoot reports that no mirror.yaml exists in the directory or any parent — the one FindRoot failure "scaffold a fresh store" may answer.
Functions ¶
Types ¶
type Allowlist ¶
type Allowlist struct {
Vulnerabilities []AllowlistEntry `yaml:"vulnerabilities"`
}
Allowlist is an entry's security/allowlist.yaml: accepted scan findings, each with a statement and a lint-enforced expiry.
func LoadAllowlist ¶
LoadAllowlist reads an entry's allowlist. A missing file is an empty allowlist, not an error.
type AllowlistEntry ¶
type AllowlistEntry struct {
// ID is the finding identifier (CVE, GHSA, GO-...); matching also
// covers the finding's aliases, so an entry keeps working across
// scanners reporting under different id families.
ID string `yaml:"id"`
// Statement records the machine facts: package, installed version,
// fixed-in version.
Statement string `yaml:"statement"`
// ExpiredAt (YYYY-MM-DD) forces re-review; entries never outlive it.
ExpiredAt string `yaml:"expired_at"`
// Notes preserves human analysis (reachability, exposure) verbatim
// across regenerations.
Notes string `yaml:"notes,omitempty"`
}
AllowlistEntry accepts one finding until it expires.
type AllowlistPolicy ¶
type AllowlistPolicy struct {
// Generate regenerates security/allowlist.yaml from the scan during
// upgrade; the PR review is where the risk is actually accepted.
Generate bool `yaml:"generate"`
// Preamble is whole-file context rendered as comments atop the
// generated allowlist.
Preamble string `yaml:"preamble"`
}
AllowlistPolicy opts an entry into allowlist derivation.
type ArtifactLock ¶
type ArtifactLock struct {
Artifact LockArtifact `yaml:"artifact"`
}
ArtifactLock is an artifact entry's lock.yaml.
func LoadArtifactLock ¶
func LoadArtifactLock(path string) (*ArtifactLock, error)
LoadArtifactLock reads an artifact lock file.
func (*ArtifactLock) Encode ¶
func (l *ArtifactLock) Encode() []byte
Encode renders the lock in its canonical byte form.
type ArtifactManifest ¶
type ArtifactManifest struct {
APIVersion string `yaml:"apiVersion"`
Kind string `yaml:"kind"`
// Name must match the entry's directory name.
Name string `yaml:"name"`
Artifact ArtifactSpec `yaml:"artifact"`
Scan ArtifactScan `yaml:"scan"`
Publish ArtifactPublish `yaml:"publish"`
}
ArtifactManifest is an artifacts/<name>/manifest.yaml: one mirrored OCI artifact that is not a helm chart (a manifests bundle, a policy bundle, a standalone image).
func LoadArtifactManifest ¶
func LoadArtifactManifest(path string) (*ArtifactManifest, error)
LoadArtifactManifest reads and validates an artifact manifest.
type ArtifactPublish ¶
type ArtifactPublish struct {
// Repo is the repository path applied under every registry URL
// (default <artifactNamespace>/<canonical source path>).
Repo string `yaml:"repo"`
}
ArtifactPublish names the publish destination.
type ArtifactScan ¶
type ArtifactScan struct {
// Enabled is auto (scan iff the artifact is a runnable image), true
// or false.
Enabled string `yaml:"enabled"`
}
ArtifactScan opts the artifact into image scanning.
func (ArtifactScan) EffectiveEnabled ¶
func (s ArtifactScan) EffectiveEnabled() string
EffectiveEnabled resolves the enabled default (auto).
type ArtifactSpec ¶
type ArtifactSpec struct {
// Ref is the upstream repository (no tag): e.g. ghcr.io/acme/bundles.
Ref string `yaml:"ref"`
// Version is the pinned tag; upgrade splices it.
Version string `yaml:"version"`
// VersionConstraint bounds what upgrade may pick.
VersionConstraint string `yaml:"versionConstraint"`
// CooldownDays applies the tracked-tag soak to version picks
// (default: the global cooldown).
CooldownDays *int `yaml:"cooldownDays"`
// Lockstep names an update group, as for charts.
Lockstep string `yaml:"lockstep"`
// VerifyUpstream declares the artifact's upstream provenance.
VerifyUpstream VerifyRule `yaml:"verifyUpstream"`
}
ArtifactSpec pins the upstream artifact.
type ChartManifest ¶
type ChartManifest struct {
APIVersion string `yaml:"apiVersion"`
Kind string `yaml:"kind"`
// Name must match the entry's directory name.
Name string `yaml:"name"`
Chart ChartSpec `yaml:"chart"`
Discovery Discovery `yaml:"discovery"`
Images Images `yaml:"images"`
OCIRefs OCIRefs `yaml:"ociRefs"`
Scan *ScanOverride `yaml:"scan"`
Publish ChartPublish `yaml:"publish"`
}
ChartManifest is a charts/<name>/manifest.yaml: the reviewed intent for one mirrored helm chart. Everything derived from it (the vendored tree, the rendered manifests, the images lock) is fact, regenerated by machine.
func LoadChartManifest ¶
func LoadChartManifest(path string) (*ChartManifest, error)
LoadChartManifest reads and validates a chart manifest.
type ChartPublish ¶
type ChartPublish struct {
// ChartRepo is the repository path applied under every registry URL
// (default <chartNamespace>/<name>).
ChartRepo string `yaml:"chartRepo"`
}
ChartPublish names the publish destination.
type ChartSpec ¶
type ChartSpec struct {
// Repo is the upstream chart location: an oci:// registry path or an
// https:// helm repository (index.yaml).
Repo string `yaml:"repo"`
Name string `yaml:"name"`
// Lockstep names an update group: entries sharing a lockstep value
// ride one upstream version stream and must bump together in one PR
// (a half-merged pair publishes an operator referencing images the
// mirror doesn't carry yet). The group target is the LOWEST of the
// members' newest satisfying versions, holding the bump until every
// member carries the tag.
Lockstep string `yaml:"lockstep"`
// Version is the pinned upstream version; upgrade splices it.
Version string `yaml:"version"`
// VersionConstraint bounds what upgrade may pick (default: none).
VersionConstraint string `yaml:"versionConstraint"`
// VerifyUpstream declares the chart's upstream provenance
// (provider none documents a gap).
VerifyUpstream VerifyRule `yaml:"verifyUpstream"`
}
ChartSpec pins the upstream chart.
type Config ¶
type Config struct {
APIVersion string `yaml:"apiVersion"`
Kind string `yaml:"kind"`
Registries []Registry `yaml:"registries"`
Signing Signing `yaml:"signing"`
Update Update `yaml:"update"`
Scan Scan `yaml:"scan"`
// SourceRegistryRewrites reroutes pulls from an upstream registry host
// (e.g. a pull-through cache in front of docker.io). Recorded sources
// and publish targets keep the canonical path.
SourceRegistryRewrites map[string]string `yaml:"sourceRegistryRewrites"`
}
Config is mirror.yaml: pipeline-wide defaults. Per-entry intent lives in each entry's manifest.yaml, never here.
func LoadConfig ¶
LoadConfig reads and validates the mirror.yaml at path.
type Discovery ¶
type Discovery struct {
// Namespace to render into (default: the entry name).
Namespace string `yaml:"namespace"`
// ValuesFiles are paths relative to the entry directory.
ValuesFiles []string `yaml:"valuesFiles"`
// KubeVersion is the Kubernetes version to render for (default 1.34.0).
KubeVersion string `yaml:"kubeVersion"`
// APIVersions are extra .Capabilities.APIVersions entries.
APIVersions []string `yaml:"apiVersions"`
}
Discovery configures the render that image discovery runs against.
func (Discovery) EffectiveKubeVersion ¶
EffectiveKubeVersion resolves the kube-version default.
func (Discovery) EffectiveNamespace ¶
EffectiveNamespace resolves the namespace default (the entry name).
type DistributionManifests ¶
type DistributionManifests struct {
// Artifact is the manifests artifact ref; {appVersion} expands from
// the vendored Chart.yaml.
Artifact string `yaml:"artifact"`
// Components name the manifest files whose Deployment images are
// derived.
Components []string `yaml:"components"`
// Registry prefixes registry-less image references found in the
// manifests (default ghcr.io) — the deploying operator prefixes its
// configured registry the same way.
Registry string `yaml:"registry"`
}
DistributionManifests configures sidecar derivation for charts whose workload images are deployed by an operator from manifests helm never renders (so discovery cannot see them).
type Entry ¶
type Entry struct {
// Name is the entry's directory name, its identity everywhere.
Name string
// Kind is KindChart or KindArtifact.
Kind string
// Dir is the absolute path of the entry directory.
Dir string
Chart *ChartManifest
Artifact *ArtifactManifest
}
Entry is one discovered mirror entry: a chart or an artifact. Exactly one of Chart and Artifact is set, matching Kind.
func Discover ¶
Discover globs charts/*/manifest.yaml and artifacts/*/manifest.yaml under root and loads every entry, sorted by name. The tree is the registry: nothing else lists entries.
func (Entry) LockPath ¶
LockPath is the entry's lock file path: images.lock.yaml for charts, lock.yaml for artifacts.
func (Entry) ManifestPath ¶
ManifestPath is the entry's manifest.yaml path.
func (Entry) VersionConstraint ¶
VersionConstraint returns the entry's update constraint.
type ExcludePattern ¶
type ExcludePattern struct {
Pattern string `yaml:"pattern"`
}
ExcludePattern drops discovered references matching a glob.
type ExtraImage ¶
ExtraImage adds one image with the reason it is invisible to discovery.
type ImageVerifyRule ¶
type ImageVerifyRule struct {
// Match is a glob over canonical source references.
Match string `yaml:"match"`
VerifyRule `yaml:",inline"`
}
ImageVerifyRule is a VerifyRule scoped to images matching a glob.
type Images ¶
type Images struct {
// Track re-picks tags for images on a release train of their own,
// writing the pick into a values file. Wall-clock dependent: only
// upgrade re-picks; every other stage uses the committed pin.
Track []Track `yaml:"track"`
// DistributionManifests derives extra images from a distribution
// manifests artifact into the generated images.extra.yaml sidecar.
DistributionManifests *DistributionManifests `yaml:"distributionManifests"`
// Extra adds images helm rendering cannot see. {appVersion} expands
// from the vendored Chart.yaml.
Extra []ExtraImage `yaml:"extra"`
// Exclude drops discovered references matching a glob pattern.
Exclude []ExcludePattern `yaml:"exclude"`
// AllowEmpty accepts a chart that renders no images (CRD-only charts).
AllowEmpty bool `yaml:"allowEmpty"`
// VerifyUpstream rules gate every locked image: first match wins, and
// every image must match one (provider none documents a gap).
VerifyUpstream []ImageVerifyRule `yaml:"verifyUpstream"`
}
Images configures image discovery, tracking and upstream verification.
type ImagesLock ¶
ImagesLock is a chart entry's images.lock.yaml: the pinned facts derived from the manifest — the upstream tgz digest and every referenced image resolved to a digest. Regenerated by machine; validate byte-compares it.
func LoadImagesLock ¶
func LoadImagesLock(path string) (*ImagesLock, error)
LoadImagesLock reads a chart lock file.
func (*ImagesLock) Encode ¶
func (l *ImagesLock) Encode() []byte
Encode renders the lock in its canonical byte form. The shape is fixed, so the emitter is hand-rolled: a generic YAML encoder would not reproduce the committed files byte-for-byte, and the validate gate compares bytes.
type KMSSigning ¶
type KMSSigning struct {
// Key is a KMS URI: gcpkms://, awskms:// or azurekms://.
Key string `yaml:"key"`
}
KMSSigning signs with a cloud KMS key.
type KeylessSigning ¶
type KeylessSigning struct {
CertificateIdentity string `yaml:"certificateIdentity"`
CertificateOidcIssuer string `yaml:"certificateOidcIssuer"`
// TlogUpload records signatures in the public transparency log
// (default true; public repos want the log).
TlogUpload *bool `yaml:"tlogUpload"`
}
KeylessSigning pins the certificate identity the mirror's own signatures carry — used both to sign and to self-verify for publish idempotency.
func (*KeylessSigning) TlogUploadEnabled ¶
func (k *KeylessSigning) TlogUploadEnabled() bool
TlogUploadEnabled resolves the TlogUpload default.
type KubescapeScanner ¶
type KubescapeScanner struct {
Enabled bool `yaml:"enabled"`
// Mode is "warn" (findings inform review) or "fail" (findings block).
Mode string `yaml:"mode"`
}
KubescapeScanner configures the configuration scan.
type LockArtifact ¶
type LockArtifact struct {
// Ref is the canonical upstream repository (no tag).
Ref string `yaml:"ref"`
// Version is the pinned tag.
Version string `yaml:"version"`
// Digest is the manifest digest Ref:Version resolved to.
Digest string `yaml:"digest"`
// Targets maps each configured registry's name to the mirror reference
// the artifact publishes to there.
Targets map[string]string `yaml:"targets"`
// Platforms lists os/arch pairs of a manifest list.
Platforms []string `yaml:"platforms"`
}
LockArtifact pins one mirrored OCI artifact by digest.
type LockChart ¶
type LockChart struct {
Name string `yaml:"name"`
Version string `yaml:"version"`
UpstreamTgzSha256 string `yaml:"upstreamTgzSha256"`
}
LockChart records the vendored chart identity and its upstream tgz digest (the publish-time mutation tripwire).
type LockImage ¶
type LockImage struct {
// Source is the canonical upstream reference (normalized, tagged).
Source string `yaml:"source"`
// Digest is the manifest digest Source resolved to.
Digest string `yaml:"digest"`
// Targets maps each configured registry's name to the mirror reference
// the image publishes to there.
Targets map[string]string `yaml:"targets"`
// Platforms lists os/arch pairs of a manifest list (empty for
// single-platform images).
Platforms []string `yaml:"platforms"`
}
LockImage is one image pinned by digest, with its mirror targets.
type OCIRefAllow ¶
OCIRefAllow permits one non-mirror oci:// reference pattern, with the reason it may bypass the mirror.
type OCIRefs ¶
type OCIRefs struct {
Allow []OCIRefAllow `yaml:"allow"`
}
OCIRefs governs oci:// references surviving in rendered output: anything outside the mirror bypasses the review gate and needs a reasoned allowance.
type Registry ¶
type Registry struct {
// Name is the registry's identity: the lock files' targets key and
// the value `sync --registry` selects by. Lowercase alphanumerics and
// hyphens.
Name string `yaml:"name"`
URL string `yaml:"url"`
// ChartNamespace prefixes published charts (default "charts").
ChartNamespace string `yaml:"chartNamespace"`
// ImageNamespace prefixes mirrored images by their canonical source
// path (default "images"): <url>/<imageNamespace>/<source path>:<tag>.
ImageNamespace string `yaml:"imageNamespace"`
// ArtifactNamespace prefixes mirrored OCI artifacts (default "artifacts").
ArtifactNamespace string `yaml:"artifactNamespace"`
// Signing, when set, replaces the global signing block wholesale for
// pushes to this registry (never merged field-by-field).
Signing *Signing `yaml:"signing"`
}
Registry locates one mirror destination: a registry URL with path namespaces for charts, images and artifacts beneath it. Every entry publishes to every configured registry.
func (Registry) EffectiveSigning ¶ added in v0.11.0
EffectiveSigning resolves the signing config for pushes to this registry: its own block when set, else the global default.
type Scan ¶
type Scan struct {
// Enabled turns image scanning off entirely when false (default
// true). With scanning enabled, at least one image scanner must be
// enabled in Scanners.
Enabled *bool `yaml:"enabled"`
Scanners Scanners `yaml:"scanners"`
// FailOn lists blocking severities (default CRITICAL, HIGH).
FailOn []string `yaml:"failOn"`
// IgnoreUnfixed skips findings with no fixed version (default true).
IgnoreUnfixed *bool `yaml:"ignoreUnfixed"`
// AllowlistMaxDays bounds every allowlist entry's expired_at horizon
// (default 90) — expiry forces re-review instead of accepted-forever CVEs.
AllowlistMaxDays int `yaml:"allowlistMaxDays"`
// AllowlistNewDays is the expiry stamped on new derived entries
// (default 90). Surviving entries keep the date they were first
// accepted with, so regeneration never rolls the clock forward.
AllowlistNewDays int `yaml:"allowlistNewDays"`
}
Scan is the global vulnerability-scan policy. FailOn and IgnoreUnfixed can be overridden per entry; the scanner roster is global.
func (Scan) EffectiveAllowlistMaxDays ¶
EffectiveAllowlistMaxDays resolves the horizon default.
func (Scan) EffectiveAllowlistNewDays ¶
EffectiveAllowlistNewDays resolves the new-entry default.
func (Scan) EffectiveEnabled ¶ added in v0.11.0
EffectiveEnabled resolves the scanning-enabled default (on).
func (Scan) EffectiveFailOn ¶
EffectiveFailOn resolves the FailOn default.
func (Scan) EffectiveIgnoreUnfixed ¶
EffectiveIgnoreUnfixed resolves the IgnoreUnfixed default.
type ScanOverride ¶
type ScanOverride struct {
FailOn []string `yaml:"failOn"`
IgnoreUnfixed *bool `yaml:"ignoreUnfixed"`
Allowlist AllowlistPolicy `yaml:"allowlist"`
}
ScanOverride adjusts the global scan policy for one entry.
type ScanPolicy ¶
ScanPolicy is the resolved (entry over global) blocking policy.
func EffectiveScanPolicy ¶
func EffectiveScanPolicy(global Scan, override *ScanOverride) ScanPolicy
EffectiveScanPolicy resolves an entry's scan override against the global scan config.
type ScannerToggle ¶
type ScannerToggle struct {
Enabled bool `yaml:"enabled"`
}
ScannerToggle enables or disables one scanner.
type Scanners ¶
type Scanners struct {
// OSV shells out to osv-scanner, which must be on PATH when enabled
// (default disabled).
OSV *ScannerToggle `yaml:"osv"`
// Grype shells out to grype, which must be on PATH when enabled
// (default disabled).
Grype *ScannerToggle `yaml:"grype"`
// Kubescape scans rendered manifests for misconfigurations (default
// enabled, warn-only; skipped with a warning when the binary is absent).
Kubescape *KubescapeScanner `yaml:"kubescape"`
}
Scanners toggles the pluggable scanners independently; none is forced, but an image scan with neither osv nor grype enabled is an error.
func (Scanners) GrypeEnabled ¶
GrypeEnabled resolves the grype default (off).
func (Scanners) KubescapeEnabled ¶
KubescapeEnabled resolves the kubescape default (on).
func (Scanners) KubescapeMode ¶
KubescapeMode resolves the kubescape mode default ("warn").
func (Scanners) OSVEnabled ¶
OSVEnabled resolves the osv default (off).
type Sidecar ¶
type Sidecar struct {
Extra []ExtraImage `yaml:"extra"`
}
Sidecar is a generated images.extra.yaml.
func LoadSidecar ¶
LoadSidecar reads an entry's generated sidecar. A missing file is an empty sidecar, not an error.
type Signing ¶
type Signing struct {
// Provider is "keyless" or "kms".
Provider string `yaml:"provider"`
Keyless *KeylessSigning `yaml:"keyless"`
KMS *KMSSigning `yaml:"kms"`
}
Signing configures how published OCI artifacts are signed: keyless (ambient OIDC, Fulcio certificate, transparency log) or a KMS key. The top-level block is the default; a per-registry signing block replaces it wholesale — the two are never merged field-by-field.
type Track ¶
type Track struct {
Image string `yaml:"image"`
// VersionConstraint bounds the pick; empty derives the pinned tag's
// own release train (">=<pin> <<major+1>.0.0"), so picks follow the
// current major and never hop one on their own.
VersionConstraint string `yaml:"versionConstraint"`
// CooldownDays overrides the global soak for this image; 0 disables
// the soak for an image that should track head.
CooldownDays *int `yaml:"cooldownDays"`
// ValuesFile defaults to the first discovery.valuesFiles entry.
ValuesFile string `yaml:"valuesFile"`
ValuesPath string `yaml:"valuesPath"`
}
Track is one tracked image: the tag is machine-picked into a values file, so the rule names both an image and a path that must already resolve there — the pick replaces a value, it never invents one. The value there is either a full image reference (the pick replaces image:tag) or a bare tag for charts that split image.repository from image.tag (the pick replaces just the tag).
type Update ¶
type Update struct {
// CooldownDays is how long a tag must have been published before a
// tracked-image pick may adopt it (default 3): a tag published this
// recently can still be yanked or hot-fixed, and the mirror should
// not be what discovers that. Kept short on purpose — every day here
// is a day the platform knowingly runs behind on security patches.
CooldownDays *int `yaml:"cooldownDays"`
}
Update tunes the tracked-tag soak window.
func (Update) EffectiveCooldownDays ¶
EffectiveCooldownDays resolves the default.
type VerifyRule ¶
type VerifyRule struct {
// Provider is none (documented gap), cosign-keyless or cosign-key.
Provider string `yaml:"provider"`
// CertificateIdentityRegexp is required for cosign-keyless.
CertificateIdentityRegexp string `yaml:"certificateIdentityRegexp"`
// CertificateOidcIssuer defaults to the GitHub Actions issuer.
CertificateOidcIssuer string `yaml:"certificateOidcIssuer"`
// Key is required for cosign-key: a URL or path to the public key.
Key string `yaml:"key"`
// SignatureDigestAlgorithm overrides the payload digest for
// cosign-key publishers signing with a non-default one (sha512).
SignatureDigestAlgorithm string `yaml:"signatureDigestAlgorithm"`
// SignatureRepository is where signatures live when the publisher
// stores them in a dedicated repository instead of alongside the
// artifact.
SignatureRepository string `yaml:"signatureRepository"`
}
VerifyRule declares upstream provenance for a chart, artifact or image.
func (VerifyRule) EffectiveOidcIssuer ¶
func (r VerifyRule) EffectiveOidcIssuer() string
EffectiveOidcIssuer resolves the issuer default.
func (VerifyRule) EffectiveProvider ¶
func (r VerifyRule) EffectiveProvider() string
EffectiveProvider resolves the provider default (none).