registry

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 21 Imported by: 18

README

pkg/registry

This package implements a Docker v2 registry and the OCI distribution specification.

It is designed to be used anywhere a low dependency container registry is needed, with an initial focus on tests.

Its goal is to be standards compliant and its strictness will increase over time.

This is currently a low flightmiles system. It's likely quite safe to use in tests; If you're using it in production, please let us know how and send us PRs for integration tests.

Before sending a PR, understand that the expectation of this package is that it remain free of extraneous dependencies. This means that we expect pkg/registry to only have dependencies on Go's standard library, and other packages in go-containerregistry.

You may be asked to change your code to reduce dependencies, and your PR might be rejected if this is deemed impossible.

Documentation

Overview

Package registry implements a docker V2 registry and the OCI distribution specification.

It is designed to be used anywhere a low dependency container registry is needed, with an initial focus on tests.

Its goal is to be standards compliant and its strictness will increase over time.

This is currently a low flightmiles system. It's likely quite safe to use in tests; If you're using it in production, please let us know how and send us CL's for integration tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts ...Option) http.Handler

New returns a handler which implements the docker registry protocol. It should be registered at the site root.

func TLS

func TLS(domain string) (*httptest.Server, error)

TLS returns an httptest server, with an http client that has been configured to send all requests to the returned server. The TLS certs are generated for the given domain which should correspond to the domain the image is stored in. If you need a transport, Client().Transport is correctly configured.

Types

type BlobDeleteHandler added in v0.16.0

type BlobDeleteHandler interface {
	// Delete the blob contents.
	Delete(ctx context.Context, repo string, h v1.Hash) error
}

BlobDeleteHandler is an extension interface representing a blob storage backend that can delete blob contents.

type BlobHandler added in v0.16.0

type BlobHandler interface {
	// Get gets the blob contents, or errNotFound if the blob wasn't found.
	Get(ctx context.Context, repo string, h v1.Hash) (io.ReadCloser, error)
}

BlobHandler represents a minimal blob storage backend, capable of serving blob contents.

func NewDiskBlobHandler added in v0.16.0

func NewDiskBlobHandler(dir string) BlobHandler

func NewInMemoryBlobHandler added in v0.16.0

func NewInMemoryBlobHandler() BlobHandler

type BlobPutHandler added in v0.16.0

type BlobPutHandler interface {
	// Put puts the blob contents.
	//
	// The contents will be verified against the expected size and digest
	// as the contents are read, and an error will be returned if these
	// don't match. Implementations should return that error, or a wrapper
	// around that error, to return the correct error when these don't match.
	Put(ctx context.Context, repo string, h v1.Hash, rc io.ReadCloser) error
}

BlobPutHandler is an extension interface representing a blob storage backend that can write blob contents.

type BlobStatHandler added in v0.16.0

type BlobStatHandler interface {
	// Stat returns the size of the blob, or errNotFound if the blob wasn't
	// found, or redirectError if the blob can be found elsewhere.
	Stat(ctx context.Context, repo string, h v1.Hash) (int64, error)
}

BlobStatHandler is an extension interface representing a blob storage backend that can serve metadata about blobs.

type Option

type Option func(r *registry)

Option describes the available options for creating the registry.

func Logger

func Logger(l *log.Logger) Option

Logger overrides the logger used to record requests to the registry.

func WithBlobHandler added in v0.16.0

func WithBlobHandler(h BlobHandler) Option

func WithReferrersSupport added in v0.14.0

func WithReferrersSupport(enabled bool) Option

WithReferrersSupport enables the referrers API endpoint (OCI 1.1+)

func WithWarning added in v0.15.0

func WithWarning(prob float64, msg string) Option

Jump to

Keyboard shortcuts

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