registry

package
v0.0.0-...-9fea1c8 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2025 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoMorePages = errors.New("no more pages")
)

Functions

func Log

func Log(format string, args ...any)

Log Pass log messages along to Go's "log" module.

func Quiet

func Quiet(_ string, _ ...any)

Quiet Discard log messages silently.

func WrapTransport

func WrapTransport(transport http.RoundTripper, url, username, password string) http.RoundTripper

WrapTransport Given an existing http.RoundTripper such as http.DefaultTransport, build the transport stack necessary to authenticate to the Docker registry API. This adds in support for OAuth bearer tokens and HTTP Basic auth, and sets up error handling this library relies on.

Types

type AuthorizationChallenge

type AuthorizationChallenge struct {
	Scheme     string
	Parameters map[string]string
}

AuthorizationChallenge carries information from a WWW-Authenticate response header.

type BasicTransport

type BasicTransport struct {
	Transport http.RoundTripper
	URL       string
	Username  string
	Password  string
}

BasicTransport is a custom HTTP transport that adds basic authentication to requests.

func (*BasicTransport) RoundTrip

func (t *BasicTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes a single HTTP transaction and adds basic authentication if the request URL matches the specified URL.

type ErrorTransport

type ErrorTransport struct {
	Transport http.RoundTripper
}

ErrorTransport is a custom HTTP transport that checks for non-successful HTTP responses.

func (*ErrorTransport) RoundTrip

func (t *ErrorTransport) RoundTrip(request *http.Request) (*http.Response, error)

RoundTrip executes a single HTTP transaction and checks for non-successful responses.

type HTTPStatusError

type HTTPStatusError struct {
	Response *http.Response
	// Copied from `Response.Body` to avoid problems with unclosed bodies later.
	// Nobody calls `err.Response.Body.Close()`, ever.
	Body []byte
}

HTTPStatusError is returned when a non-successful HTTP response is received.

func (*HTTPStatusError) Error

func (err *HTTPStatusError) Error() string

Error implements the error interface for HTTPStatusError.

type LogfCallback

type LogfCallback func(format string, args ...any)

LogfCallback is a callback function type for logging

type ManifestEntry

type ManifestEntry struct {
	MediaType string       `json:"mediaType"`
	Digest    string       `json:"digest"`
	Size      int          `json:"size"`
	Platform  PlatformSpec `json:"platform"`
}

ManifestEntry describes a single entry in a manifest list.

type ManifestList

type ManifestList struct {
	MediaType     string          `json:"mediaType"`
	SchemaVersion int             `json:"schemaVersion"`
	Manifests     []ManifestEntry `json:"manifests"`
}

ManifestList represents a list of manifests in a registry.

func (*ManifestList) Arch

func (m *ManifestList) Arch() []string

Arch returns the list of architectures for the manifests in the manifest list.

func (*ManifestList) OS

func (m *ManifestList) OS() []string

OS returns the list of OSes for the manifests in the manifest list.

type PlatformSpec

type PlatformSpec struct {
	Architecture string `json:"architecture"`
	OS           string `json:"os"`
}

PlatformSpec describes the platform of a manifest entry.

type Registry

type Registry struct {
	URL    string
	Client *http.Client
	Logf   LogfCallback
}

Registry is a structure that holds the URL of the registry and the HTTP client

func New

func New(registryURL, username, password string) (*Registry, error)

New Create a new Registry with the given URL and credentials, then Ping()s it before returning it to verify that the registry is available.

You can, alternately, construct a Registry manually by populating the fields. This passes http.DefaultTransport to WrapTransport when creating the http.Client.

func NewInsecure

func NewInsecure(registryURL, username, password string) (*Registry, error)

NewInsecure Create a new Registry, as with New, using an http.Transport that disables SSL certificate verification.

func (*Registry) BlobMetadata

func (registry *Registry) BlobMetadata(repository string, dig digest.Digest) (distribution.Descriptor, error)

BlobMetadata retrieves the metadata of a blob from the registry.

func (*Registry) DeleteManifest

func (registry *Registry) DeleteManifest(repository string, dig digest.Digest) error

DeleteManifest deletes a manifest from the registry.

func (*Registry) DownloadBlob

func (registry *Registry) DownloadBlob(repository string, dig digest.Digest) (io.ReadCloser, error)

DownloadBlob retrieves a blob from the registry.

func (*Registry) HasBlob

func (registry *Registry) HasBlob(repository string, dig digest.Digest) (bool, error)

HasBlob checks if a blob exists in the registry.

func (*Registry) Manifest

func (registry *Registry) Manifest(repository, reference string) (*schema1.SignedManifest, error)

Manifest retrieves the V1 manifest for a given repository and reference.

func (*Registry) ManifestDigest

func (registry *Registry) ManifestDigest(repository, reference string) (digest.Digest, error)

ManifestDigest retrieves the digest of a manifest for a given repository and reference.

func (*Registry) ManifestList

func (registry *Registry) ManifestList(repository, reference string) (bool, *ManifestList, error)

ManifestList retrieves the manifest list for a given repository and reference.

func (*Registry) ManifestOCI

func (registry *Registry) ManifestOCI(repository, reference string) (*schema2.DeserializedManifest, error)

ManifestOCI retrieves the OCI manifest for a given repository and reference.

func (*Registry) ManifestV2

func (registry *Registry) ManifestV2(repository, reference string) (*schema2.DeserializedManifest, error)

ManifestV2 retrieves the V2 manifest for a given repository and reference.

func (*Registry) Ping

func (r *Registry) Ping() error

Ping the registry to verify that it is available

func (*Registry) PutManifest

func (registry *Registry) PutManifest(repository, reference string, manifest distribution.Manifest) error

PutManifest uploads a manifest to the registry.

func (*Registry) Repositories

func (registry *Registry) Repositories() ([]string, error)

Repositories returns a list of repositories in the registry.

func (*Registry) Tags

func (registry *Registry) Tags(repository string) (tags []string, err error)

Tags returns a list of tags for the given repository.

func (*Registry) UploadBlob

func (registry *Registry) UploadBlob(repository string, dig digest.Digest, content io.Reader) error

UploadBlob uploads a blob to the registry.

type TokenTransport

type TokenTransport struct {
	Transport http.RoundTripper
	Username  string
	Password  string
}

func (*TokenTransport) RoundTrip

func (t *TokenTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes a single HTTP transaction

Jump to

Keyboard shortcuts

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