ociserver

package
v0.0.0-...-eedc705 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 18 Imported by: 3

Documentation

Overview

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

It is designed to be used anywhere a low dependency container registry is needed.

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(backend ociregistry.Interface, opts *Options) http.Handler

New returns a handler which implements the docker registry protocol by making calls to the underlying registry backend r.

If opts is nil, it's equivalent to passing new(Options).

The returned handler should be registered at the site root.

Errors

All HTTP responses will be JSON, formatted according to the OCI spec. If an error returned from backend conforms to ociregistry.Error, the associated code and detail will be used.

The HTTP response code will be determined from the error code when possible. If it can't be determined and the error implements ociregistry.HTTPError, the code returned by StatusCode will be used as the HTTP response code.

Types

type Options

type Options struct {
	// WriteError is used to write error responses. It is passed the
	// writer to write the error response to, the request that
	// the error is in response to, and the error itself.
	//
	// If WriteError is nil, [ociregistry.WriteError] will
	// be used and any error discarded.
	WriteError func(w http.ResponseWriter, req *http.Request, err error)

	// DisableReferrersAPI, when true, causes the registry to behave as if
	// it does not understand the referrers API.
	DisableReferrersAPI bool

	// DisableSinglePostUpload, when true, causes the registry
	// to reject uploads with a single POST request.
	// This is useful in combination with LocationsForDescriptor
	// to cause uploaded blob content to flow through
	// another server.
	DisableSinglePostUpload bool

	// MaxListPageSize, if > 0, causes the list endpoints to return an
	// error if the page size is greater than that. This emulates
	// a quirk of AWS ECR where it refuses request for any
	// page size > 1000.
	MaxListPageSize int

	// OmitDigestFromTagGetResponse causes the registry
	// to omit the Docker-Content-Digest header from a tag
	// GET response, mimicking the behavior of registries that
	// do the same (for example AWS ECR).
	OmitDigestFromTagGetResponse bool

	// OmitLinkHeaderFromResponses causes the server
	// to leave out the Link header from list responses.
	OmitLinkHeaderFromResponses bool

	// LocationForUploadID transforms an upload ID as returned by
	// ocirequest.BlobWriter.ID to the absolute URL location
	// as returned by the upload endpoints.
	//
	// By default, when this function is nil, or it returns an empty
	// string, upload IDs are treated as opaque identifiers and the
	// returned locations are always host-relative URLs into the
	// server itself.
	//
	// This can be used to allow clients to fetch and push content
	// directly from some upstream server rather than passing
	// through this server. Clients doing that will need access
	// rights to that remote location.
	LocationForUploadID func(string) (string, error)

	// LocationsForDescriptor returns a set of possible download
	// URLs for the given descriptor.
	// If it's nil, then all locations returned by the server
	// will refer to the server itself.
	//
	// If not, then the Location header of responses will be
	// set accordingly (to an arbitrary value from the
	// returned slice if there are multiple).
	//
	// Returning a location from this function will also
	// cause GET requests to return a redirect response
	// to that location.
	//
	// TODO perhaps the redirect behavior described above
	// isn't always what is wanted?
	LocationsForDescriptor func(isManifest bool, desc ociregistry.Descriptor) ([]string, error)

	DebugID string
}

Options holds options for the server.

type ParseError

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

ParseError represents an error that can happen when parsing. The Err field holds one of the possible error values below.

Jump to

Keyboard shortcuts

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