Documentation
¶
Overview ¶
Package ociregistry embeds a Docker Registry v2 / OCI distribution server, shared by the ECR, Azure Container Registry and Artifact Registry emulators.
Index ¶
- Constants
- Variables
- func IsDigest(ref string) bool
- func IsIndexType(mediaType string) bool
- func Limit(next http.Handler, maxBytes int64) http.Handler
- func New(parent context.Context, opts Options) http.Handler
- func ServeObserved(app http.Handler, w http.ResponseWriter, r *http.Request, obs Observer)
- func Shutdown(h http.Handler)
- func SplitManifestPath(path string) (string, string, bool)
- type Attrs
- type Client
- func (c Client) Catalog(ctx context.Context) ([]string, error)
- func (c Client) DeleteManifest(ctx context.Context, repo, digest string) error
- func (c Client) Describe(ctx context.Context, repo string, m Manifest) Info
- func (c Client) GetBlob(ctx context.Context, repo, digest string, maxBytes int64) ([]byte, error)
- func (c Client) GetManifest(ctx context.Context, repo, ref string) (Manifest, error)
- func (c Client) PutManifest(ctx context.Context, repo, ref, mediaType string, body []byte) (string, error)
- func (c Client) Tags(ctx context.Context, repo string) ([]string, error)
- type Descriptor
- type Info
- type Ledger
- type Manifest
- type ManifestEntry
- type Observer
- type Options
- type RepoEntry
- type TagEntry
Constants ¶
const ( OpRead = "read" OpWrite = "write" OpDelete = "delete" )
Operations a ledger entry can forbid.
const DefaultMaxRequestBytes int64 = 8 << 30
DefaultMaxRequestBytes bounds a single upload request body (one monolithic PUT or one PATCH chunk).
Variables ¶
var ErrNotFound = errors.New("ociregistry: not found")
ErrNotFound is returned when a repository, manifest or blob does not exist.
var ErrNullEntry = errors.New("ociregistry: null ledger entry")
ErrNullEntry is returned by Normalize when a repository entry is null.
var ErrRegistry = errors.New("ociregistry: registry error")
ErrRegistry is returned when the registry answers with an unexpected error status.
var ErrTooLarge = errors.New("ociregistry: blob too large")
ErrTooLarge is returned when a blob exceeds the size the caller allowed.
Functions ¶
func IsIndexType ¶
IsIndexType reports whether mediaType is a manifest list or OCI index.
func Limit ¶
Limit rejects request bodies larger than maxBytes (DefaultMaxRequestBytes when zero) with a 413-style read error instead of streaming them into storage without bound.
func New ¶
New builds a registry http.Handler with deletes enabled and no authentication. The result is a *handlers.App, whose Shutdown() error releases the library's resources.
func ServeObserved ¶
ServeObserved serves r through app, reporting manifest writes and deletes to obs.
Types ¶
type Attrs ¶
type Attrs struct {
DeleteDisabled bool `json:"deleteDisabled,omitempty"`
WriteDisabled bool `json:"writeDisabled,omitempty"`
ReadDisabled bool `json:"readDisabled,omitempty"`
ListDisabled bool `json:"listDisabled,omitempty"`
}
Attrs are the changeable attributes of a repository, manifest or tag. The zero value enables everything.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client calls a registry handler in-process, bypassing any authentication in front of it.
func (Client) DeleteManifest ¶
DeleteManifest removes the manifest with the given digest (and every tag pointing at it).
func (Client) Describe ¶
Describe parses a manifest and, for an image manifest, reads its config blob for the platform.
func (Client) GetManifest ¶
GetManifest fetches the manifest at repo:ref, where ref is a tag or a digest.
type Descriptor ¶
type Descriptor struct {
Digest string `json:"digest"`
MediaType string `json:"mediaType"`
Size int64 `json:"size"`
}
Descriptor is the part of a manifest entry used for sizing and platform lookup.
type Info ¶
type Info struct {
Digest string
MediaType string
ConfigMediaType string
Architecture string
OS string
Children []Descriptor
Size int64
Index bool
}
Info summarises a manifest.
type Ledger ¶
Ledger records when manifests and tags were pushed, which the registry itself does not keep. Repositories disappear from it with their last manifest. It is not safe for concurrent use: callers hold their own lock.
func (Ledger) Allowed ¶
Allowed reports whether op may touch repo:ref. An operation on a digest also needs every tag pointing at it to allow it.
func (Ledger) RecordDelete ¶
RecordDelete forgets a deleted manifest with its tags, or just the tag when ref is one.
type ManifestEntry ¶
type ManifestEntry struct {
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
Attrs Attrs `json:"attrs"`
}
ManifestEntry is a manifest's ledger entry.
type Observer ¶
type Observer struct {
// Permit may refuse a manifest read, write or delete; it must write the error response itself.
Permit func(w http.ResponseWriter, repo, ref, op string) bool
// Put runs after a manifest is stored (201); digest is the stored manifest's digest.
Put func(repo, ref, digest string)
// Delete runs after a manifest or tag is deleted (202).
Delete func(repo, ref string)
}
Observer hooks manifest traffic passing through ServeObserved. Every field is optional.
type Options ¶
type Options struct {
// InstanceID labels the registry in the distribution library's logs.
InstanceID string
// RootDir keeps blobs and manifests on disk under this directory; empty keeps them in memory.
RootDir string
}
Options configures a registry.
Directories
¶
| Path | Synopsis |
|---|---|
|
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.
|
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. |