spec

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package spec defines the mirror store's on-disk contract: the per-entry manifest.yaml files (intent), the lock files (facts), the generated images.extra.yaml sidecar, and the CVE allowlists — plus the typed blocks the layered patchy config shares between mirror and build (registries, signing, and the one scan block every entry overrides field by field). The tree itself is the registry of entries — discovery globs charts/*/manifest.yaml and artifacts/*/manifest.yaml; the config never lists them, and this package never discovers or reads the config: the CLI assembles a Config and hands it in.

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

View Source
const (
	KindChart    = "Chart"
	KindArtifact = "Artifact"
)

The manifest kinds the schema defines.

View Source
const (
	// SourceChart is an upstream helm chart, identified by ChartSource.
	SourceChart = "chart"
	// SourceImage is a container image: a mirrored chart's image, or a
	// build's base image (FROM, COPY --from, RUN --mount from, the
	// # syntax= frontend).
	SourceImage = "image"
	// SourceArtifact is an upstream OCI artifact: an artifact entry's ref
	// or a chart's distribution-manifests artifact.
	SourceArtifact = "artifact"
)

The source kinds a policy restricts.

View Source
const APIVersion = "mirror.patchy.bitwisemedia.uk/v1alpha1"

APIVersion is the schema identity every mirror manifest declares.

View Source
const AllowlistFile = "security/allowlist.yaml"

AllowlistFile is an entry's allowlist path relative to its directory.

View Source
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

This section is empty.

Functions

func CanonicalSource added in v0.13.0

func CanonicalSource(kind, ref string) string

CanonicalSource is the string policy patterns match for a reference: images and artifacts lose their tag and digest and gain the implicit docker.io/library/ host; charts (already ChartSource form) pass through.

func ChartSource added in v0.13.0

func ChartSource(repo, name string) string

ChartSource is a chart's policy identity: the repo with the chart name appended, the scheme kept (oci://host/path/name, https://host/path/name).

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

func LoadAllowlist(entryDir string) (*Allowlist, error)

LoadAllowlist reads an entry's allowlist. A missing file is an empty allowlist, not an error.

func LoadAllowlistFile added in v0.12.0

func LoadAllowlistFile(path string) (*Allowlist, error)

LoadAllowlistFile reads an allowlist by path (a build entry's security/allowlists/<name>.yaml). 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 {
	// MaxDays bounds every allowlist entry's expired_at horizon (default
	// 90) — expiry forces re-review instead of accepted-forever CVEs.
	MaxDays *int `yaml:"maxDays"`
	// NewDays is the expiry stamped on new derived entries (default 90).
	// Surviving entries keep the date they were first accepted with, so
	// regeneration never rolls a live acceptance forward — except one
	// whose date has already lapsed (on or before today), which is renewed
	// to this horizon as a fresh acceptance, reviewed as a date change in
	// the diff.
	NewDays *int `yaml:"newDays"`
	// Generate regenerates the entry's allowlist from a fresh scan (mirror
	// upgrade, build --update-allowlists); the PR review is where the
	// risk is actually accepted (default false).
	Generate *bool `yaml:"generate"`
	// Preamble is whole-file context rendered as comments atop the
	// generated allowlist (default none).
	Preamble *string `yaml:"preamble"`
}

AllowlistPolicy is the accepted-risk block, in the config (defaults) and on every entry (overrides). Pointers keep "unset — inherit" distinct from an explicit false, 0 or "".

func (AllowlistPolicy) IsSet added in v0.12.0

func (p AllowlistPolicy) IsSet() bool

IsSet reports whether any field is set.

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 overrides the config's scan block for this artifact; under
	// enabled: auto it scans only when the artifact is a runnable image.
	Scan    ScanOverride    `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 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 BuildPolicy added in v0.13.0

type BuildPolicy struct {
	// Mode is fail (default) or warn.
	Mode PolicyMode `yaml:"mode"`
	// Enforced pins this layer's policy, as for MirrorPolicy.
	Enforced bool `yaml:"enforced"`
	// Images match every image a Dockerfile pulls — FROM, COPY --from,
	// RUN --mount from=, and the # syntax= frontend — as the canonical
	// repository (normalized, no tag or digest).
	Images PolicyRules `yaml:"images"`
}

BuildPolicy is the patchy config's build.policy block: which registries patchy build may pull base images from.

func (*BuildPolicy) Layer added in v0.13.0

func (p *BuildPolicy) Layer(source string) PolicyLayer

Layer converts the block into one evaluated policy layer.

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 overrides the config's scan block for this chart.
	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 {
	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"`
	// Policy is the resolved source policy the command enforces (the
	// mirror: or build: block's, plus every enforced layer's). The CLI
	// assembles it from the layered config; it has no YAML form here.
	Policy SourcePolicy `yaml:"-"`
}

Config is the mirror's view of the patchy configuration: the shared registries, signing and scan blocks plus the mirror: block's update and sourceRegistryRewrites. The CLI assembles it from the layered patchy config; the engine never discovers or reads config files itself, so a Config is always handed in. Per-entry intent lives in each entry's manifest.yaml, never here.

func (*Config) Resolve added in v0.12.0

func (c *Config) Resolve() error

Resolve validates the config and fills its defaults in place: at least one registry, each with a well-formed unique name and a url, namespace defaults per registry, the signing default (keyless) and every signing block's shape, and the scan block's allowlist horizon. Callers that only need part of the config (the dev commands) never call it.

func (*Config) ResolveWithoutRegistries added in v0.12.1

func (c *Config) ResolveWithoutRegistries() error

ResolveWithoutRegistries is Resolve for callers that never contact a registry (`patchy build --dry-run`): the same validation and defaults, but an empty registries list is allowed, so a plan needs no registry config.

func (*Config) SelectRegistries added in v0.11.0

func (c *Config) SelectRegistries(names []string) ([]Registry, error)

SelectRegistries resolves a set of registry names against the config, in declaration order. A nil or empty selection means every registry; an unknown name is an error.

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

func (d Discovery) EffectiveKubeVersion() string

EffectiveKubeVersion resolves the kube-version default.

func (Discovery) EffectiveNamespace

func (d Discovery) EffectiveNamespace(entryName string) string

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

func Discover(root string) ([]Entry, error)

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 LoadEntry

func LoadEntry(root, name string) (Entry, error)

LoadEntry loads one entry by name, wherever it lives.

func (Entry) LockPath

func (e Entry) LockPath() string

LockPath is the entry's lock file path: images.lock.yaml for charts, lock.yaml for artifacts.

func (Entry) Lockstep

func (e Entry) Lockstep() string

Lockstep returns the entry's update group, empty when it rides alone.

func (Entry) ManifestPath

func (e Entry) ManifestPath() string

ManifestPath is the entry's manifest.yaml path.

func (Entry) Version

func (e Entry) Version() string

Version returns the entry's pinned upstream version.

func (Entry) VersionConstraint

func (e Entry) VersionConstraint() string

VersionConstraint returns the entry's update constraint.

type ExcludePattern

type ExcludePattern struct {
	Pattern string `yaml:"pattern"`
}

ExcludePattern drops discovered references matching a path glob: '*' matches within one '/'-separated segment, '**' across segments (so "ghcr.io/acme/**" drops everything under ghcr.io/acme). Patterns match the normalized, tagged reference.

type ExtraImage

type ExtraImage struct {
	Image  string `yaml:"image"`
	Reason string `yaml:"reason"`
}

ExtraImage adds one image with the reason it is invisible to discovery.

type ImageVerifyRule

type ImageVerifyRule struct {
	// Match is a path glob over canonical source references ('*' within
	// one '/'-separated segment, '**' across segments; "**" is the
	// catch-all).
	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 path 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

type ImagesLock struct {
	Chart  LockChart   `yaml:"chart"`
	Images []LockImage `yaml:"images"`
}

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 MirrorPolicy added in v0.13.0

type MirrorPolicy struct {
	// Mode is fail (default) or warn.
	Mode PolicyMode `yaml:"mode"`
	// Enforced pins this layer's policy: it is evaluated as written in the
	// file that declares it, alongside the merged policy, so a more
	// preferred config layer can tighten it but never loosen, downgrade or
	// delete it. Without it the block merges like any other key.
	Enforced bool `yaml:"enforced"`
	// Charts match "<chart.repo>/<chart.name>" with the scheme kept:
	// oci://ghcr.io/acme/charts/app, https://charts.example.com/app.
	Charts PolicyRules `yaml:"charts"`
	// Images match the canonical source repository (normalized, no tag
	// or digest): docker.io/library/nginx, registry.k8s.io/pause.
	Images PolicyRules `yaml:"images"`
	// Artifacts match the canonical artifact repository (no tag).
	Artifacts PolicyRules `yaml:"artifacts"`
}

MirrorPolicy is the patchy config's mirror.policy block: which upstream sources patchy mirror may pull charts, images and artifacts from.

func (*MirrorPolicy) Layer added in v0.13.0

func (p *MirrorPolicy) Layer(source string) PolicyLayer

Layer converts the block into one evaluated policy layer.

type OCIRefAllow

type OCIRefAllow struct {
	Pattern string `yaml:"pattern"`
	Reason  string `yaml:"reason"`
}

OCIRefAllow permits one non-mirror oci:// reference pattern, with the reason it may bypass the mirror. Pattern is a path glob over the whole reference, scheme and tag included ('*' matches within one '/'-separated segment, '**' across segments): oci://ghcr.io/acme/policies/* or oci://ghcr.io/acme/**.

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 PolicyLayer added in v0.13.0

type PolicyLayer struct {
	// Source names where the layer came from, for messages.
	Source string
	Mode   PolicyMode
	// Enforced marks a layer pinned by `enforced: true`.
	Enforced bool
	// Rules are keyed by source kind (SourceChart, SourceImage,
	// SourceArtifact); a kind with no rules is unrestricted.
	Rules map[string]PolicyRules
}

PolicyLayer is one policy evaluated on its own: the merged config's, or an enforced layer's as written in its file.

type PolicyMode added in v0.13.0

type PolicyMode string

PolicyMode is what a source-policy violation does: fail blocks, warn narrates and lets the run continue.

const (
	PolicyFail PolicyMode = "fail"
	PolicyWarn PolicyMode = "warn"
)

The policy modes. An unset mode means fail.

type PolicyRules added in v0.13.0

type PolicyRules struct {
	Allow []string `yaml:"allow"`
	Deny  []string `yaml:"deny"`
}

PolicyRules is one source kind's allow and deny lists of path globs (imageref.PathMatch: '*' stays within a '/'-separated segment, '**' crosses segments). A deny match always rejects; a non-empty allow list rejects everything none of its patterns match. Both empty restrict nothing.

type PolicyViolation added in v0.13.0

type PolicyViolation struct {
	Kind string `json:"kind"`
	// Ref is the reference as given (before canonicalization).
	Ref string `json:"ref"`
	// Value is what the patterns were matched against.
	Value string `json:"value"`
	// Source names the rejecting layer.
	Source string     `json:"source"`
	Mode   PolicyMode `json:"mode"`
	Reason string     `json:"reason"`
}

PolicyViolation is one source a policy rejected.

func (PolicyViolation) Blocking added in v0.13.0

func (v PolicyViolation) Blocking() bool

Blocking reports whether the violation fails the run.

func (PolicyViolation) String added in v0.13.0

func (v PolicyViolation) String() string

String renders the violation for messages.

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

func (r Registry) EffectiveSigning(global *Signing) *Signing

EffectiveSigning resolves the signing config for pushes to this registry: its own block when set, else the global default.

type ResolvedAllowlist added in v0.12.0

type ResolvedAllowlist struct {
	MaxDays  int
	NewDays  int
	Generate bool
	Preamble string
}

ResolvedAllowlist is the resolved allowlist policy.

func (ResolvedAllowlist) Validate added in v0.12.0

func (a ResolvedAllowlist) Validate() error

Validate checks the resolved horizon: both day counts positive, and new entries never stamped past what lint accepts.

type Scan

type Scan struct {
	// Enabled is the master default (default true): false turns scanning
	// off for every entry that does not say otherwise. 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"`
	// Allowlist holds the accepted-risk defaults.
	Allowlist AllowlistPolicy `yaml:"allowlist"`
}

Scan is the config's scan block: the scanner roster plus the defaults every entry inherits. Entries override individual fields with the same shape (ScanOverride); EffectiveScanPolicy resolves the two.

func (Scan) EffectiveEnabled added in v0.11.0

func (s Scan) EffectiveEnabled() bool

EffectiveEnabled resolves the master scanning default (on).

type ScanEnabled added in v0.12.0

type ScanEnabled string

ScanEnabled is an entry's tri-state scan switch: auto, true or false. It decodes from a YAML bool as well as a string; any other spelling decodes as-is and is rejected by Valid, so lint can name it.

const (
	ScanAuto ScanEnabled = "auto"
	ScanOn   ScanEnabled = "true"
	ScanOff  ScanEnabled = "false"
)

The ScanEnabled values. The zero value means auto.

func ParseScanEnabled added in v0.12.0

func ParseScanEnabled(v any) (ScanEnabled, error)

ParseScanEnabled converts a decoded bool or string into a ScanEnabled. Strings pass through unvalidated (Valid checks them); other types fail.

func (ScanEnabled) Effective added in v0.12.0

func (e ScanEnabled) Effective() ScanEnabled

Effective resolves the default (auto).

func (*ScanEnabled) UnmarshalYAML added in v0.12.0

func (e *ScanEnabled) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML accepts a bool (enabled: true) or a string (enabled: auto).

func (ScanEnabled) Valid added in v0.12.0

func (e ScanEnabled) Valid() bool

Valid reports whether e is auto, true, false or unset.

type ScanOverride

type ScanOverride struct {
	// Enabled is auto (default), true or false. auto defers to the
	// config's scan.enabled, then to the kind's own rule; true and false
	// override scan.enabled for this entry.
	Enabled       ScanEnabled     `yaml:"enabled"`
	FailOn        []string        `yaml:"failOn"`
	IgnoreUnfixed *bool           `yaml:"ignoreUnfixed"`
	Allowlist     AllowlistPolicy `yaml:"allowlist"`
}

ScanOverride is an entry's scan block — a chart or artifact manifest's, or a build entry's. Every field is optional; unset fields inherit the config's scan block, then the built-in defaults.

func (ScanOverride) HasImageFields added in v0.12.0

func (o ScanOverride) HasImageFields() bool

HasImageFields reports whether the override sets a field that only an image scan consumes (failOn, ignoreUnfixed, allowlist) — meaningless on an entry with no images to scan.

type ScanPolicy

type ScanPolicy struct {
	// Enabled is false when scanning is off for the entry: an explicit
	// enabled: false, or auto under a config-level scan.enabled: false.
	Enabled bool
	// Auto reports that Enabled came from auto, so the kind's own rule
	// applies on top (an artifact scans only when it is a runnable image).
	Auto          bool
	FailOn        []string
	IgnoreUnfixed bool
	Allowlist     ResolvedAllowlist
}

ScanPolicy is the resolved (entry over config over built-in) policy.

func EffectiveScanPolicy

func EffectiveScanPolicy(global Scan, o ScanOverride) ScanPolicy

EffectiveScanPolicy resolves an entry's scan block against the config's: each field from the entry when set, else from the config, else the built-in default.

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

func (s Scanners) GrypeEnabled() bool

GrypeEnabled resolves the grype default (off).

func (Scanners) KubescapeEnabled

func (s Scanners) KubescapeEnabled() bool

KubescapeEnabled resolves the kubescape default (on).

func (Scanners) KubescapeMode

func (s Scanners) KubescapeMode() string

KubescapeMode resolves the kubescape mode default ("warn").

func (Scanners) OSVEnabled

func (s Scanners) OSVEnabled() bool

OSVEnabled resolves the osv default (off).

type Sidecar

type Sidecar struct {
	Extra []ExtraImage `yaml:"extra"`
}

Sidecar is a generated images.extra.yaml.

func LoadSidecar

func LoadSidecar(entryDir string) (*Sidecar, error)

LoadSidecar reads an entry's generated sidecar. A missing file is an empty sidecar, not an error.

func (*Sidecar) Encode

func (s *Sidecar) Encode() []byte

Encode renders the sidecar in its canonical byte form, GENERATED header included.

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 SourcePolicy added in v0.13.0

type SourcePolicy struct {
	Layers []PolicyLayer
}

SourcePolicy is the resolved source policy one command enforces: every layer must permit a source. Zero value restricts nothing.

func (SourcePolicy) Check added in v0.13.0

func (p SourcePolicy) Check(kind, ref string) *PolicyViolation

Check evaluates one source against every layer. It returns nil when all layers permit it; otherwise the most severe rejection (a fail layer over a warn one, earlier layers first — enforced layers lead), so a source rejected by several layers is reported once.

func (SourcePolicy) Reject added in v0.13.0

func (p SourcePolicy) Reject(kind, ref, reason string) *PolicyViolation

Reject reports a source that cannot be evaluated at all (a reference that does not resolve) as a violation of the strictest layer restricting kind: it cannot be proven permitted. Nil when no layer restricts kind.

func (SourcePolicy) Restricts added in v0.13.0

func (p SourcePolicy) Restricts(kind string) bool

Restricts reports whether any layer restricts kind.

func (SourcePolicy) Validate added in v0.13.0

func (p SourcePolicy) Validate() error

Validate checks every layer: a known mode and well-formed patterns, so a pattern that could never match (a tag, a missing registry host, a schemeless chart) fails at load instead of silently restricting nothing.

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

func (u Update) EffectiveCooldownDays() int

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).

Jump to

Keyboard shortcuts

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