reg

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2022 License: Apache-2.0 Imports: 26 Imported by: 2

Documentation

Overview

Package reg implements the OCI registry scheme used by most images (host:port/repo:tag)

Index

Constants

View Source
const (
	// DefaultBlobChunk 1M chunks, this is allocated in a memory buffer
	DefaultBlobChunk = 1024 * 1024
	// DefaultBlobMax is disabled to support registries without chunked upload support
	DefaultBlobMax = -1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Opts

type Opts func(*Reg)

Opts provides options to access registries

func WithBlobSize

func WithBlobSize(chunk, max int64) Opts

WithBlobSize overrides default blob sizes

func WithCertDirs

func WithCertDirs(dirs []string) Opts

WithCertDirs adds certificate directories for host specific certs

func WithCertFiles

func WithCertFiles(files []string) Opts

WithCertFiles adds certificates by filename

func WithCerts

func WithCerts(certs [][]byte) Opts

WithCerts adds certificates

func WithConfigHosts

func WithConfigHosts(configHosts []*config.Host) Opts

WithConfigHosts adds host configs for credentials

func WithDelay

func WithDelay(delayInit time.Duration, delayMax time.Duration) Opts

WithDelay initial time to wait between retries (increased with exponential backoff)

func WithHTTPClient

func WithHTTPClient(hc *http.Client) Opts

WithHTTPClient uses a specific http client with retryable requests

func WithLog

func WithLog(log *logrus.Logger) Opts

WithLog injects a logrus Logger configuration

func WithRetryLimit

func WithRetryLimit(l int) Opts

WithRetryLimit restricts the number of retries (defaults to 5)

func WithTransport

func WithTransport(t *http.Transport) Opts

WithTransport uses a specific http transport with retryable requests

func WithUserAgent

func WithUserAgent(ua string) Opts

WithUserAgent sets a user agent header

type Reg

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

Reg is used for interacting with remote registry servers

func New

func New(opts ...Opts) *Reg

New returns a Reg pointer with any provided options

func (*Reg) BlobDelete

func (reg *Reg) BlobDelete(ctx context.Context, r ref.Ref, d digest.Digest) error

BlobDelete removes a blob from the repository

func (*Reg) BlobGet

func (reg *Reg) BlobGet(ctx context.Context, r ref.Ref, d digest.Digest) (blob.Reader, error)

BlobGet retrieves a blob from the repository, returning a blob reader

func (*Reg) BlobHead

func (reg *Reg) BlobHead(ctx context.Context, r ref.Ref, d digest.Digest) (blob.Reader, error)

BlobHead is used to verify if a blob exists and is accessible

func (*Reg) BlobMount

func (reg *Reg) BlobMount(ctx context.Context, rSrc ref.Ref, rTgt ref.Ref, d digest.Digest) error

BlobMount attempts to perform a server side copy/mount of the blob between repositories

func (*Reg) BlobPut

func (reg *Reg) BlobPut(ctx context.Context, r ref.Ref, d digest.Digest, rdr io.Reader, cl int64) (digest.Digest, int64, error)

BlobPut uploads a blob to a repository. This will attempt an anonymous blob mount first which some registries may support. It will then try doing a full put of the blob without chunking (most widely supported). If the full put fails, it will fall back to a chunked upload (useful for flaky networks).

func (*Reg) Info

func (reg *Reg) Info() scheme.Info

Info is experimental and may be removed in the future

func (*Reg) ManifestDelete

func (reg *Reg) ManifestDelete(ctx context.Context, r ref.Ref) error

ManifestDelete removes a manifest by reference (digest) from a registry. This will implicitly delete all tags pointing to that manifest.

func (*Reg) ManifestGet

func (reg *Reg) ManifestGet(ctx context.Context, r ref.Ref) (manifest.Manifest, error)

ManifestGet retrieves a manifest from the registry

func (*Reg) ManifestHead

func (reg *Reg) ManifestHead(ctx context.Context, r ref.Ref) (manifest.Manifest, error)

ManifestHead returns metadata on the manifest from the registry

func (*Reg) ManifestPut

func (reg *Reg) ManifestPut(ctx context.Context, r ref.Ref, m manifest.Manifest, opts ...scheme.ManifestOpts) error

ManifestPut uploads a manifest to a registry

func (*Reg) RepoList

func (reg *Reg) RepoList(ctx context.Context, hostname string, opts ...scheme.RepoOpts) (*repo.RepoList, error)

RepoList returns a list of repositories on a registry Note the underlying "_catalog" API is not supported on many cloud registries

func (*Reg) TagDelete

func (reg *Reg) TagDelete(ctx context.Context, r ref.Ref) error

TagDelete removes a tag from a repository. It first attempts the newer OCI API to delete by tag name (not widely supported). If the OCI API fails, it falls back to pushing a unique empty manifest and deleting that.

func (*Reg) TagList

func (reg *Reg) TagList(ctx context.Context, r ref.Ref, opts ...scheme.TagOpts) (*tag.List, error)

TagList returns a listing to tags from the repository

Jump to

Keyboard shortcuts

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