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

ocitest

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package ocitest drives a Docker Registry v2 endpoint with the push, pull, delete and listing calls a registry client makes, so each registry emulator proves the same conformance behaviour.

Index

Constants

View Source
const ManifestMediaType = "application/vnd.docker.distribution.manifest.v2+json"

ManifestMediaType is the Docker schema 2 manifest type the helpers push.

Variables

This section is empty.

Functions

func Digest

func Digest(data []byte) string

Digest returns the sha256 digest of data.

func Run

func Run(t *testing.T, c Client, prefix, catalog, listedPrefix string)

Run executes the conformance checks against c. Repositories are named prefix+"<case>", so a registry that scopes repositories (for example project/repo/) passes its scope as prefix. catalog is the repository listing path, empty when there is none; names in that listing carry listedPrefix instead of prefix.

Types

type Client

type Client struct {
	T *testing.T
	// HTTP performs the calls; nil uses a client without keep-alives.
	HTTP *http.Client
	// Prepare adds credentials (and anything else) to each request.
	Prepare func(*http.Request)
	// Base is the scheme and host:port requests are sent to.
	Base string
	// Host overrides the Host header, for host-routed registries.
	Host string
}

Client talks to one registry endpoint.

func (Client) Do

func (c Client) Do(method, path string, body []byte, headers map[string]string) Response

Do sends one request and reads its body.

func (Client) Names

func (c Client) Names(path, field string, n int) []string

Names pages through a listing URL with n per page, following Link headers, and returns every name.

func (Client) PushBlob

func (c Client) PushBlob(repo string, data []byte, chunks int) string

PushBlob uploads data to repo in the given number of PATCH chunks (0 means one monolithic PUT) and returns its digest.

func (Client) PushImage

func (c Client) PushImage(repo, tag string) Image

PushImage uploads a one-layer image to repo and tags it.

type Image

type Image struct {
	Digest string
	Body   []byte
	Layer  []byte
}

Image is a pushed manifest.

type Response

type Response struct {
	Header http.Header
	Body   []byte
	Status int
}

Response is a completed call.

Jump to

Keyboard shortcuts

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