Help us shape the future of Go! Take the 2026 Go Developer Survey

registry

package
v8.149.2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package registry mocks an OCI distribution registry the way a release's artifacts are probed: HEAD and GET of /v2/<name>/manifests/<reference> for images and for charts (names under charts/). The harness runs one instance as the public registry and one as the private registry, so a scenario can give them different states.

Manifest routes have defaults a fixture rarely needs to spell out: a 200 without a body is a minimal manifest with its Docker-Content-Digest, a 404 without a body is the registry's MANIFEST_UNKNOWN error, and a manifest no route scripts is MANIFEST_UNKNOWN too. With the stale-login flag set every request that carries credentials is answered 401 UNAUTHORIZED with a bearer challenge, the answer a registry gives a client whose stored login has expired; an anonymous request is answered by the routes, as a public registry answers a client that sends nothing.

Index

Constants

View Source
const (
	ManifestMediaType    = "application/vnd.oci.image.manifest.v1+json"
	ImageConfigMediaType = "application/vnd.oci.image.config.v1+json"
	ChartConfigMediaType = "application/vnd.cncf.helm.config.v1+json"
)

Media types of the default manifest.

Variables

This section is empty.

Functions

func Digest

func Digest(body string) string

Digest is the sha256 digest of a body in the form a registry reports it.

func Manifest

func Manifest(name string) string

Manifest is the default manifest body of an available artifact: an OCI image manifest without layers, its config a chart's for a name under charts/.

Types

type Server

type Server struct {
	*httptest.Server
	// contains filtered or unexported fields
}

Server is a running mock.

func Start

func Start(routes sequence.Routes, staleLogin bool) (*Server, error)

Start serves the routes on a loopback port until Close. With staleLogin every request carrying an Authorization header is refused with 401 UNAUTHORIZED; anonymous requests are served.

func (*Server) Host

func (s *Server) Host() string

Host is host:port, the value of DEVCTL_REGISTRY_PUBLIC or DEVCTL_REGISTRY_PRIVATE; the registry speaks plain HTTP, hence DEVCTL_REGISTRY_INSECURE=1.

func (*Server) Requests

func (s *Server) Requests() []sequence.Request

Requests are the requests received so far.

Jump to

Keyboard shortcuts

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