testreg

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 18 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 testreg runs an in-memory OCI registry seeded with a small, realistic image graph, for crawler, CLI and API tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Registry

type Registry struct {
	Host   string
	Server *httptest.Server
	// Images maps a short name (debian, go-amd64, api, ...) to the image.
	Images map[string]v1.Image
	// GoIndex is the multi-platform index pushed as base/go:1.22.
	GoIndex v1.ImageIndex
	// contains filtered or unexported fields
}

Registry is a running test registry and the images pushed to it.

func Start

func Start(t testing.TB) *Registry

Start runs a registry with referrers support and pushes:

base/debian:12                   one layer
base/go:1.22                     index: amd64 = debian + 1 layer, arm64 = unrelated
payments/api:1.0, :latest        go amd64 + 1 layer, labels, env, history
payments/worker:v1               go amd64 + 1 layer, OCI base annotations
payments/api:sha256-<api>.sig    a cosign signature
an SBOM referrer for api, through the referrers API

func (*Registry) Delete

func (r *Registry) Delete(ref string)

Delete removes a tag or manifest.

func (*Registry) Digest

func (r *Registry) Digest(short string) string

Digest returns a named image's digest.

func (*Registry) Layered

func (r *Registry) Layered(base, short string, created time.Time, cfg *v1.Config, cmds ...string) v1.Image

Layered builds a new image on top of a named one, for tests that push more images after Start.

func (*Registry) Push

func (r *Registry) Push(ref string, img v1.Image)

Push writes an image to repo:tag or repo@digest.

func (*Registry) PushIndex

func (r *Registry) PushIndex(ref string, idx v1.ImageIndex)

PushIndex writes an index to repo:tag.

func (*Registry) Ref

func (r *Registry) Ref(s string) name.Reference

Ref parses a ref relative to the registry, such as payments/api:1.0.

func (*Registry) WithProvenance added in v0.3.1

func (r *Registry) WithProvenance(img v1.Image, materials map[string]string) v1.ImageIndex

WithProvenance returns an index holding img and, as BuildKit pushes it, an attestation manifest whose SLSA provenance lists materials: purl to digest, such as pkg:docker/node@20 to sha256:….

type Shape added in v0.2.0

type Shape struct {
	// Repos is the number of application repos, split across teams.
	Repos int
	// Tags is the number of images per repo; each gets its own tag.
	Tags int
	// MultiArchEvery makes every Nth repo push amd64 and arm64 indexes
	// instead of single images. Zero means none.
	MultiArchEvery int
	// Bases is the number of base images applications build on.
	Bases int
}

Shape sizes a synthetic registry.

type Synthetic added in v0.2.0

type Synthetic struct {
	*Registry
	// RepoNames lists every repo, bases first.
	RepoNames []string
	// Tags counts every tag pushed; Manifests counts every platform
	// image, which is what a full crawl indexes; Indexes counts the
	// multi-platform indexes among the tags.
	Tags, Manifests, Indexes int
}

Synthetic holds a generated registry and what it contains.

func StartSynthetic added in v0.2.0

func StartSynthetic(t testing.TB, s Shape) *Synthetic

StartSynthetic runs a registry without referrers support and fills it with a generated organization: base images, then repos of applications built on them, one small layer per image. It is sized for benchmarks, so it pushes concurrently.

Jump to

Keyboard shortcuts

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