registrytest

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Overview

Package registrytest runs an in-memory OCI registry for tests and builds images that look like the official php image and images derived from it. Images carry a real (small) layer so tests can check that layers are never downloaded.

Index

Constants

View Source
const Attestation = "attestation"

Attestation is an index entry that is a BuildKit attestation manifest.

Variables

This section is empty.

Functions

func PHPEnv

func PHPEnv(v string) []string

PHPEnv is the environment the official php image sets for version v.

Types

type Server

type Server struct {
	Host string

	// Fail, when set, may answer a request itself with a status code (and
	// Retry-After seconds when >= 0): return 0 to pass the request through.
	Fail func(r *http.Request) (status int, retryAfter int)
	// contains filtered or unexported fields
}

Server is an in-memory registry.

func New

func New(t testing.TB) *Server

New starts a registry; it stops when the test ends.

func (*Server) EmptyIndex

func (s *Server) EmptyIndex(repo, tag string) v1.Hash

EmptyIndex pushes an index with no manifests ({"manifests":[]}).

func (*Server) Image

func (s *Server) Image(sp Spec) v1.Image

Image builds an image for spec with one random layer.

func (*Server) Index

func (s *Server) Index(specs ...Spec) v1.ImageIndex

Index builds an OCI index of one image per spec; a spec with OS Attestation adds an attestation manifest (platform unknown/unknown).

func (*Server) LayerFetched

func (s *Server) LayerFetched(reqs []string) bool

LayerFetched reports whether any request fetched a pushed layer blob.

func (*Server) Mirrors

func (s *Server) Mirrors() map[string]string

Mirrors maps Docker Hub to this registry (registry.Options.Mirrors).

func (*Server) PHPIndex

func (s *Server) PHPIndex(v string, tags ...string) v1.Hash

PHPIndex pushes an official-style multi-platform php index for version v at each tag, with an attestation manifest, and returns its digest. Platforms default to linux/amd64 and linux/arm64/v8.

func (*Server) PHPIndexOn

func (s *Server) PHPIndexOn(v, base string, platforms []string, tags ...string) (v1.Hash, []v1.Hash)

PHPIndexOn pushes an official-style php index for version v built on base (an org.opencontainers.image.base.name value such as "debian:bookworm-slim" or "alpine:3.21") for each platform (default linux/amd64 and linux/arm64/v8), with an attestation manifest, at each tag. The first tag is the image version annotation.

func (*Server) Push

func (s *Server) Push(repo, tag string, img v1.Image) v1.Hash

Push pushes a single-platform image to repo:tag (repo like "library/php").

func (*Server) PushIndex

func (s *Server) PushIndex(repo, tag string, idx v1.ImageIndex) v1.Hash

PushIndex pushes an index to repo:tag.

func (*Server) Requests

func (s *Server) Requests() []string

Requests returns the requests seen so far and forgets them.

type Spec

type Spec struct {
	OS, Arch, Variant string
	Env               []string
	Created           time.Time
	// Base and Version set the org.opencontainers.image.base.name and
	// org.opencontainers.image.version annotations (on the image manifest
	// and its index entry), as Docker Hub's official images carry them.
	Base, Version string
	// History, when set, is the config's first history entry (created_by).
	History string
}

Spec describes one platform image.

Jump to

Keyboard shortcuts

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