registry

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MediaTypeImageManifest specifies the media type for an image manifest.
	MediaTypeImageManifest = "application/vnd.oci.image.manifest.v1+json"
	// MediaTypeImageIndex specifies the media type for an image index.
	MediaTypeImageIndex = "application/vnd.oci.image.index.v1+json"
)

Opt to define these constants here instead of importing github.com/opencontainers/image-spec/specs-go/v1 to ensure we use the docker/distribution library for unmarshalling purposes.

Variables

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

Functions

func Log

func Log(format string, args ...interface{})

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

func ParseValueAndParams

func ParseValueAndParams(header string) (value string, params map[string]string)

ParseValueAndParams takes in a header string and parses the token out of it

func Quiet

func Quiet(format string, args ...interface{})

* Discard log messages silently.

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
	URL      string
	Username string
	Password string
}

func (*BasicTransport) RoundTrip

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

type ClientError

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

func NewClientError

func NewClientError(code int, err error) *ClientError

func (*ClientError) Code

func (c *ClientError) Code() int

func (*ClientError) Error

func (c *ClientError) Error() string

func (*ClientError) OrigErr

func (c *ClientError) OrigErr() error

type ErrorTransport

type ErrorTransport struct {
	Transport
}

func (*ErrorTransport) RoundTrip

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

type HttpStatusError

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

func (*HttpStatusError) Error

func (err *HttpStatusError) Error() string

type LogfCallback

type LogfCallback func(format string, args ...interface{})

type Registry

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

func New

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

* 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 NewFromTransport

func NewFromTransport(registryUrl string, transport Transport, logf LogfCallback) (*Registry, error)

func NewInsecure

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

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

func (*Registry) DeleteManifest

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

func (*Registry) DownloadLayer

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

func (*Registry) HasLayer

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

func (*Registry) ImageIndex

func (registry *Registry) ImageIndex(repository, reference string) (*manifestlist.DeserializedManifestList, error)

func (*Registry) LayerMetadata

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

func (*Registry) Manifest

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

func (*Registry) ManifestDigest

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

func (*Registry) ManifestList

func (registry *Registry) ManifestList(repository, reference string) (*manifestlist.DeserializedManifestList, error)

func (*Registry) ManifestOCI

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

func (*Registry) ManifestOCIWithDigest added in v0.2.0

func (registry *Registry) ManifestOCIWithDigest(repository, reference string) (*ocischema.DeserializedManifest, digest.Digest, error)

ManifestOCIWithDigest extends ManifestOCI to return the digest found in the Docker-Content-Digest header. If the header does not exist or is invalid an empty digest is returned (an error is not returned so that existing clients are not affected by new, potentially unrelated, errors).

func (*Registry) ManifestV2

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

func (*Registry) ManifestV2WithDigest added in v0.2.0

func (registry *Registry) ManifestV2WithDigest(repository, reference string) (*schema2.DeserializedManifest, digest.Digest, error)

ManifestV2WithDigest extends ManifestV2 to return the digest found in the Docker-Content-Digest header. If the header does not exist or is invalid an empty digest is returned (an error is not returned so that existing clients are not affected by new, potentially unrelated, errors).

func (*Registry) Ping

func (registry *Registry) Ping() error

func (*Registry) PutManifest

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

func (*Registry) Repositories

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

func (*Registry) SignedManifest

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

func (*Registry) Tags

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

func (*Registry) UploadLayer

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

type TokenTransport

type TokenTransport struct {
	Transport http.RoundTripper
	Username  string
	Password  string
	// contains filtered or unexported fields
}

func (*TokenTransport) GetToken

func (t *TokenTransport) GetToken() string

GetToken returns the current token used to access the registry

func (*TokenTransport) RoundTrip

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

type Transport

type Transport interface {
	http.RoundTripper
	GetToken() string
}

Transport is the interface that all transports must implement so that a token can be retrieved from the registry

func WrapTransport

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

* 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.

Jump to

Keyboard shortcuts

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