docker

package
v1.2.10 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2019 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const LegacyConfigMediaType = "application/octet-stream"

LegacyConfigMediaType should be replaced by OCI image spec.

More detail: docker/distribution#1622

Variables

View Source
var (
	// ErrNoToken is returned if a request is successful but the body does not
	// contain an authorization token.
	ErrNoToken = errors.New("authorization server did not include a token in the response")

	// ErrInvalidAuthorization is used when credentials are passed to a server but
	// those credentials are rejected.
	ErrInvalidAuthorization = errors.New("authorization failed")
)

Functions

func ConvertManifest

func ConvertManifest(ctx context.Context, store content.Store, desc ocispec.Descriptor) (ocispec.Descriptor, error)

ConvertManifest changes application/octet-stream to schema2 config media type if need.

NOTE: 1. original manifest will be deleted by next gc round. 2. don't cover manifest list.

func DefaultHost

func DefaultHost(ns string) (string, error)

DefaultHost is the default host function.

func NewResolver

func NewResolver(options ResolverOptions) remotes.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.

func NewAuthorizer

func NewAuthorizer(client *http.Client, f func(string) (string, string, error)) Authorizer

NewAuthorizer creates a Docker authorizer using the provided function to get credentials for the token server or basic auth.

type ResolverOptions

type ResolverOptions struct {
	// Authorizer is used to authorize registry requests
	Authorizer Authorizer

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

	// Host provides the hostname given a namespace.
	Host func(string) (string, error)

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

	// PlainHTTP specifies to use plain http and not https
	PlainHTTP bool

	// Client is the http client to used when making registry requests
	Client *http.Client

	// 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
}

ResolverOptions are used to configured a new Docker register resolver

type Status

type Status struct {
	content.Status

	// UploadUUID is used by the Docker registry to reference blob uploads
	UploadUUID string
}

Status of a content operation

type StatusTracker

type StatusTracker interface {
	GetStatus(string) (Status, error)
	SetStatus(string, Status)
}

StatusTracker to track status of operations

func NewInMemoryTracker

func NewInMemoryTracker() StatusTracker

NewInMemoryTracker returns a StatusTracker that tracks content status in-memory

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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