docker

package
v2.0.0-...-98cc131 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

README

Taken from github.com/containerd/containerd remotes/docker to add list endpoints Fix retry of requests with ResendBuffer

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ContextWithRepositoryScope           = docker.ContextWithRepositoryScope
	ContextWithAppendPullRepositoryScope = docker.ContextWithAppendPullRepositoryScope
	NewInMemoryTracker                   = docker.NewInMemoryTracker
	NewDockerAuthorizer                  = docker.NewDockerAuthorizer
	WithAuthClient                       = docker.WithAuthClient
	WithAuthHeader                       = docker.WithAuthHeader
	WithAuthCreds                        = docker.WithAuthCreds
)
View Source
var (
	// ErrInvalidAuthorization is used when credentials are passed to a server but
	// those credentials are rejected.
	ErrInvalidAuthorization = errors.New("authorization failed")

	// MaxManifestSize represents the largest size accepted from a registry
	// during resolution. Larger manifests may be accepted using a
	// resolution method other than the registry.
	//
	// NOTE: The max supported layers by some runtimes is 128 and individual
	// layers will not contribute more than 256 bytes, making a
	// reasonable limit for a large image manifests of 32K bytes.
	// 4M bytes represents a much larger upper bound for images which may
	// contain large annotations or be non-images. A proper manifest
	// design puts large metadata in subobjects, as is consistent the
	// intent of the manifest design.
	MaxManifestSize int64 = 4 * 1048 * 1048
)
View Source
var ErrObjectNotRequired = errors.New("object not required")

Functions

func AppendDistributionSourceLabel

func AppendDistributionSourceLabel(manager content.Manager, ref string) (images.HandlerFunc, error)

AppendDistributionSourceLabel updates the label of blob with distribution source.

func DefaultHost

func DefaultHost(ns string) (string, error)

DefaultHost is the default host function.

func MatchAllHosts

func MatchAllHosts(string) (bool, error)

MatchAllHosts is a host match function which is always true.

func MatchLocalhost

func MatchLocalhost(host string) (bool, error)

MatchLocalhost is a host match function which returns true for localhost.

Note: this does not handle matching of ip addresses in octal, decimal or hex form.

func NewResolver

func NewResolver(options ResolverOptions) resolve.Resolver

NewResolver returns a new resolver to a Docker registry.

Types

type Authorizer

type Authorizer interface {
	// Authorize sets the appropriate `Authorization` header on the given
	// request.
	//
	// If no authorization is found for the request, the request remains
	// unmodified. It may also add an `Authorization` header as
	//  "bearer <some bearer token>"
	//  "basic <base64 encoded credentials>"
	Authorize(context.Context, *http.Request) error

	// AddResponses adds a 401 response for the authorizer to consider when
	// authorizing requests. The last response should be unauthorized and
	// the previous requests are used to consider redirects and retries
	// that may have led to the 401.
	//
	// If response is not handled, returns `ErrNotImplemented`
	AddResponses(context.Context, []*http.Response) error
}

Authorizer is used to authorize HTTP requests based on 401 HTTP responses. An Authorizer is responsible for caching tokens or credentials used by requests.

type Errors

type Errors = docker.Errors

type HostCapabilities

type HostCapabilities uint8

HostCapabilities represent the capabilities of the registry host. This also represents the set of operations for which the registry host may be trusted to perform.

For example pushing is a capability which should only be performed on an upstream source, not a mirror. Resolving (the process of converting a name into a digest) must be considered a trusted operation and only done by a host which is trusted (or more preferably by secure process which can prove the provenance of the mapping). A public mirror should never be trusted to do a resolve action.

| Registry Type | Pull | Resolve | Push | |------------------|------|---------|------| | Public Registry | yes | yes | yes | | Private Registry | yes | yes | yes | | Public Mirror | yes | no | no | | Private Mirror | yes | yes | no |.

const (
	// HostCapabilityPull represents the capability to fetch manifests
	// and blobs by digest.
	HostCapabilityPull HostCapabilities = 1 << iota

	// HostCapabilityResolve represents the capability to fetch manifests
	// by name.
	HostCapabilityResolve

	// HostCapabilityPush represents the capability to push blobs and
	// manifests.
	HostCapabilityPush
)

func (HostCapabilities) Has

Has checks whether the capabilities list has the provide capability.

type RegistryHost

type RegistryHost struct {
	Client       *http.Client
	Authorizer   Authorizer
	Host         string
	Scheme       string
	Path         string
	Capabilities HostCapabilities
	Header       http.Header
}

RegistryHost represents a complete configuration for a registry host, representing the capabilities, authorizations, connection configuration, and location.

type RegistryHosts

type RegistryHosts func(string) ([]RegistryHost, error)

RegistryHosts fetches the registry hosts for a given namespace, provided by the host component of an distribution image reference.

func ConfigureDefaultRegistries

func ConfigureDefaultRegistries(ropts ...RegistryOpt) RegistryHosts

ConfigureDefaultRegistries is used to create a default configuration for registries. For more advanced configurations or per-domain setups, the RegistryHosts interface should be used directly. NOTE: This function will always return a non-empty value or error.

func ConvertHosts

func ConvertHosts(hosts docker.RegistryHosts) RegistryHosts

func Registries

func Registries(registries ...RegistryHosts) RegistryHosts

Registries joins multiple registry configuration functions, using the same order as provided within the arguments. When an empty registry configuration is returned with a nil error, the next function will be called. NOTE: This function will not join configurations, as soon as a non-empty configuration is returned from a configuration function, it will be returned to the caller.

type RegistryOpt

type RegistryOpt func(*registryOpts)

RegistryOpt defines a registry default option.

func WithAuthorizer

func WithAuthorizer(a Authorizer) RegistryOpt

WithAuthorizer configures the default authorizer for a registry.

func WithClient

func WithClient(c *http.Client) RegistryOpt

WithClient configures the default http client for a registry.

func WithHostTranslator

func WithHostTranslator(h func(string) (string, error)) RegistryOpt

WithHostTranslator defines the default translator to use for registry hosts.

func WithPlainHTTP

func WithPlainHTTP(f func(string) (bool, error)) RegistryOpt

WithPlainHTTP configures registries to use plaintext http scheme for the provided host match function.

type ResolverOptions

type ResolverOptions struct {
	// Hosts returns registry host configurations for a namespace.
	Hosts RegistryHosts

	// Headers are the HTTP request header fields sent by the resolver
	Headers http.Header

	// Tracker is used to track uploads to the registry. This is used
	// since the registry does not have upload tracking and the existing
	// mechanism for getting blob upload status is expensive.
	Tracker StatusTracker

	// Authorizer is used to authorize registry requests
	// Deprecated: use Hosts
	Authorizer Authorizer

	// Credentials provides username and secret given a host.
	// If username is empty but a secret is given, that secret
	// is interpreted as a long lived token.
	// Deprecated: use Hosts
	Credentials func(string) (string, string, error)

	// Host provides the hostname given a namespace.
	// Deprecated: use Hosts
	Host func(string) (string, error)

	// PlainHTTP specifies to use plain http and not https
	// Deprecated: use Hosts
	PlainHTTP bool

	// Client is the http client to used when making registry requests
	// Deprecated: use Hosts
	Client *http.Client
}

ResolverOptions are used to configured a new Docker register resolver.

type Status

type Status = docker.Status

type StatusTrackLocker

type StatusTrackLocker = docker.StatusTrackLocker

type StatusTracker

type StatusTracker = docker.StatusTracker

type TagList

type TagList struct {
	Name string   `json:"name"`
	Tags []string `json:"tags"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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