registry

package
v0.0.0-...-0f8ce4c Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package registry contains a client and server implementation of the OCI Distribution spec. Both client and server only support pulling. The server is intended for use in tests.

Index

Constants

This section is empty.

Variables

View Source
var (
	RepositoryRegexp = regexp.MustCompile(`^` + repositoryExpr + `$`)
	TagRegexp        = regexp.MustCompile(`^` + tagExpr + `$`)
	DigestRegexp     = regexp.MustCompile(`^` + digestExpr + `$`)
)

Functions

This section is empty.

Types

type Client

type Client struct {
	// Transport will be used to make requests. For example, this allows
	// configuring TLS client and CA certificates.
	// If nil, [http.DefaultTransport] is used.
	Transport http.RoundTripper
	// GetBackOff can be set to to make the Client retry HTTP requests.
	GetBackOff func() backoff.BackOff
	// RetryNotify receives errors that trigger a retry, e.g. for logging.
	RetryNotify backoff.Notify
	// UserAgent is used as the User-Agent HTTP header.
	UserAgent string

	// Scheme must be either http or https.
	Scheme string
	// Host is the host with optional port.
	Host string
	// Repository is the name of the repository. It is part of the client because
	// bearer tokens are usually scoped to a repository.
	Repository string
	// contains filtered or unexported fields
}

Client is an OCI registry client.

func (*Client) Read

func (c *Client) Read(ctx context.Context, tag, digest string) (oci.Ref, error)

Read fetches a manifest from the registry and returns an oci.Ref.

The context is used for the manifest request and for all blob and manifest requests made through the Ref.

At least one of tag and digest must be set. If only tag is set, then you are trusting the registry to return the right content. Otherwise, the digest is used to verify the manifest. If both tag and digest are set, then the tag is used in the request, and the digest is used to verify the response. The advantage of fetching by tag is that it allows a pull through cache to display tags to a user inspecting the cache contents.

type ClientError

type ClientError struct {
	ErrorBody
	StatusCode int
	RetryAfter time.Time
	RawBody    []byte
}

ClientError is an HTTP error received from a registry or authorization service.

func (*ClientError) Error

func (e *ClientError) Error() string

type ErrorBody

type ErrorBody struct {
	Errors []ErrorInfo `json:"errors,omitempty"`
}

type ErrorInfo

type ErrorInfo struct {
	Code    string `json:"code"`
	Message string `json:"message,omitempty"`
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is an OCI registry server.

func NewServer

func NewServer() *Server

func (*Server) AddRef

func (s *Server) AddRef(repository string, tag string, ref oci.Ref) error

AddRef adds a Ref to the server in the specified repository.

If the tag is empty, the image can only be fetched by digest.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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