docker: Index | Files

package registry

import ""

Package registry contains client primitives to interact with a remote Docker registry.


Package Files

auth.go authchallenge.go config.go config_unix.go endpoint.go reference.go registry.go service.go service_v1.go service_v2.go session.go token.go types.go


const (
    // DefaultNamespace is the default namespace
    DefaultNamespace = ""
    // DefaultRegistryVersionHeader is the name of the default HTTP header
    // that carries Registry version info
    DefaultRegistryVersionHeader = "Docker-Distribution-Api-Version"

    // IndexServer is the v1 registry server used for user auth + account creation
    IndexServer = DefaultV1Registry + "/v1/"
    // IndexName is the name of the index
    IndexName = ""

    // NotaryServer is the endpoint serving the Notary trust server
    NotaryServer = ""
const (
    // DefaultV1Registry is the URI of the default v1 registry
    DefaultV1Registry = ""

    // DefaultV2Registry is the URI of the default v2 registry
    DefaultV2Registry = ""
const (
    APIVersionUnknown = iota

API Version identifiers.


var (
    // ErrInvalidRepositoryName is an error returned if the repository name did
    // not have the correct form
    ErrInvalidRepositoryName = errors.New("Invalid repository name (ex: \"registry.domain.tld/myrepos\")")

    // V2Only controls access to legacy registries.  If it is set to true via the
    // command line flag the daemon will not attempt to contact v1 legacy registries
    V2Only = false
var (
    // CertsDir is the directory where certificates are stored
    CertsDir = "/etc/docker/certs.d"
var (
    // ErrAlreadyExists is an error returned if an image being pushed
    // already exists on the remote side
    ErrAlreadyExists = errors.New("Image already exists")
var (
    // ErrRepoNotFound is returned if the repository didn't exist on the
    // remote side
    ErrRepoNotFound = errors.New("Repository not found")

func AuthTransport Uses

func AuthTransport(base http.RoundTripper, authConfig *types.AuthConfig, alwaysSetBasicAuth bool) http.RoundTripper

AuthTransport handles the auth layer when communicating with a v1 registry (private or official)

For private v1 registries, set alwaysSetBasicAuth to true.

For the official v1 registry, if there isn't already an Authorization header in the request, but there is an X-Docker-Token header set to true, then Basic Auth will be used to set the Authorization header. After sending the request with the provided base http.RoundTripper, if an X-Docker-Token header, representing a token, is present in the response, then it gets cached and sent in the Authorization header of all subsequent requests.

If the server sends a token without the client having requested it, it is ignored.

This RoundTripper also has a CancelRequest method important for correct timeout handling.

func ContinueOnError Uses

func ContinueOnError(err error) bool

ContinueOnError returns true if we should fallback to the next endpoint as a result of this error.

func DockerHeaders Uses

func DockerHeaders(metaHeaders http.Header) []transport.RequestModifier

DockerHeaders returns request modifiers that ensure requests have the User-Agent header set to dockerUserAgent and that metaHeaders are added.

func GetAuthConfigKey Uses

func GetAuthConfigKey(index *registrytypes.IndexInfo) string

GetAuthConfigKey special-cases using the full index address of the official index as the AuthConfig key, and uses the (host)name[:port] for private indexes.

func HTTPClient Uses

func HTTPClient(transport http.RoundTripper) *http.Client

HTTPClient returns a HTTP client structure which uses the given transport and contains the necessary headers for redirected requests

func Login Uses

func Login(authConfig *types.AuthConfig, registryEndpoint *Endpoint) (string, error)

Login tries to register/login to the registry server.

func NewServiceConfig Uses

func NewServiceConfig(options *Options) *registrytypes.ServiceConfig

NewServiceConfig returns a new instance of ServiceConfig

func NewTransport Uses

func NewTransport(tlsConfig *tls.Config) *http.Transport

NewTransport returns a new HTTP transport. If tlsConfig is nil, it uses the default TLS configuration.

func ParseSearchIndexInfo Uses

func ParseSearchIndexInfo(reposName string) (*registrytypes.IndexInfo, error)

ParseSearchIndexInfo will use repository name to get back an indexInfo.

func ReadCertsDirectory Uses

func ReadCertsDirectory(tlsConfig *tls.Config, directory string) error

ReadCertsDirectory reads the directory for TLS certificates including roots and certificate pairs and updates the provided TLS configuration.

func ResolveAuthConfig Uses

func ResolveAuthConfig(authConfigs map[string]types.AuthConfig, index *registrytypes.IndexInfo) types.AuthConfig

ResolveAuthConfig matches an auth configuration to a server address or a URL

func ShouldV2Fallback Uses

func ShouldV2Fallback(err errcode.Error) bool

ShouldV2Fallback returns true if this error is a reason to fall back to v1.

func ValidateIndexName Uses

func ValidateIndexName(val string) (string, error)

ValidateIndexName validates an index name.

func ValidateMirror Uses

func ValidateMirror(val string) (string, error)

ValidateMirror validates an HTTP(S) registry mirror

type APIEndpoint Uses

type APIEndpoint struct {
    Mirror       bool
    URL          string
    Version      APIVersion
    Official     bool
    TrimHostname bool
    TLSConfig    *tls.Config

APIEndpoint represents a remote API endpoint

func (APIEndpoint) ToV1Endpoint Uses

func (e APIEndpoint) ToV1Endpoint(metaHeaders http.Header) (*Endpoint, error)

ToV1Endpoint returns a V1 API endpoint based on the APIEndpoint

type APIVersion Uses

type APIVersion int

APIVersion is an integral representation of an API version (presently either 1 or 2)

func (APIVersion) String Uses

func (av APIVersion) String() string

type AuthorizationChallenge Uses

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

AuthorizationChallenge carries information from a WWW-Authenticate response header.

type Endpoint Uses

type Endpoint struct {
    URL            *url.URL
    Version        APIVersion
    IsSecure       bool
    AuthChallenges []*AuthorizationChallenge
    URLBuilder     *v2.URLBuilder
    // contains filtered or unexported fields

Endpoint stores basic information about a registry endpoint.

func NewEndpoint Uses

func NewEndpoint(index *registrytypes.IndexInfo, metaHeaders http.Header, v APIVersion) (*Endpoint, error)

NewEndpoint parses the given address to return a registry endpoint. v can be used to specify a specific endpoint version

func (*Endpoint) Path Uses

func (e *Endpoint) Path(path string) string

Path returns a formatted string for the URL of this endpoint with the given path appended.

func (*Endpoint) Ping Uses

func (e *Endpoint) Ping() (PingResult, error)

Ping pings the remote endpoint with v2 and v1 pings to determine the API version. It returns a PingResult containing the discovered version. The PingResult also indicates whether the registry is standalone or not.

func (*Endpoint) String Uses

func (e *Endpoint) String() string

Get the formatted URL for the root of this registry Endpoint

func (*Endpoint) VersionString Uses

func (e *Endpoint) VersionString(version APIVersion) string

VersionString returns a formatted string of this endpoint address using the given API Version.

type ErrNoSupport Uses

type ErrNoSupport struct{ Err error }

ErrNoSupport is an error type used for errors indicating that an operation is not supported. It encapsulates a more specific error.

func (ErrNoSupport) Error Uses

func (e ErrNoSupport) Error() string

type ImgData Uses

type ImgData struct {
    // ID is an opaque string that identifies the image
    ID              string `json:"id"`
    Checksum        string `json:"checksum,omitempty"`
    ChecksumPayload string `json:"-"`
    Tag             string `json:",omitempty"`

ImgData is used to transfer image checksums to and from the registry

type Options Uses

type Options struct {
    Mirrors            opts.ListOpts
    InsecureRegistries opts.ListOpts

Options holds command line options.

func (*Options) InstallFlags Uses

func (options *Options) InstallFlags(cmd *flag.FlagSet, usageFn func(string) string)

InstallFlags adds command-line options to the top-level flag parser for the current process.

type PingResult Uses

type PingResult struct {
    // Version is the registry version supplied by the registry in a HTTP
    // header
    Version string `json:"version"`
    // Standalone is set to true if the registry indicates it is a
    // standalone registry in the X-Docker-Registry-Standalone
    // header
    Standalone bool `json:"standalone"`

PingResult contains the information returned when pinging a registry. It indicates the registry's version and whether the registry claims to be a standalone registry.

type Reference Uses

type Reference interface {
    // HasDigest returns whether the reference has a verifiable
    // content addressable reference which may be considered secure.
    HasDigest() bool

    // ImageName returns an image name for the given repository
    ImageName(string) string

    // Returns a string representation of the reference
    String() string

Reference represents a tag or digest within a repository

func DigestReference Uses

func DigestReference(dgst digest.Digest) Reference

DigestReference creates a digest reference using a digest

func ParseReference Uses

func ParseReference(ref string) Reference

ParseReference parses a reference into either a digest or tag reference

type RepositoryData Uses

type RepositoryData struct {
    // ImgList is a list of images in the repository
    ImgList map[string]*ImgData
    // Endpoints is a list of endpoints returned in X-Docker-Endpoints
    Endpoints []string
    // Tokens is currently unused (remove it?)
    Tokens []string

RepositoryData tracks the image list, list of endpoints, and list of tokens for a repository

type RepositoryInfo Uses

type RepositoryInfo struct {
    // Index points to registry information
    Index *registrytypes.IndexInfo
    // Official indicates whether the repository is considered official.
    // If the registry is official, and the normalized name does not
    // contain a '/' (e.g. "foo"), then it is considered an official repo.
    Official bool

RepositoryInfo describes a repository

func ParseRepositoryInfo Uses

func ParseRepositoryInfo(reposName reference.Named) (*RepositoryInfo, error)

ParseRepositoryInfo performs the breakdown of a repository name into a RepositoryInfo, but lacks registry configuration.

type Service Uses

type Service struct {
    Config *registrytypes.ServiceConfig

Service is a registry service. It tracks configuration data such as a list of mirrors.

func NewService Uses

func NewService(options *Options) *Service

NewService returns a new instance of Service ready to be installed into an engine.

func (*Service) Auth Uses

func (s *Service) Auth(authConfig *types.AuthConfig) (string, error)

Auth contacts the public registry with the provided credentials, and returns OK if authentication was successful. It can be used to verify the validity of a client's credentials.

func (*Service) LookupPullEndpoints Uses

func (s *Service) LookupPullEndpoints(repoName reference.Named) (endpoints []APIEndpoint, err error)

LookupPullEndpoints creates an list of endpoints to try to pull from, in order of preference. It gives preference to v2 endpoints over v1, mirrors over the actual registry, and HTTPS over plain HTTP.

func (*Service) LookupPushEndpoints Uses

func (s *Service) LookupPushEndpoints(repoName reference.Named) (endpoints []APIEndpoint, err error)

LookupPushEndpoints creates an list of endpoints to try to push to, in order of preference. It gives preference to v2 endpoints over v1, and HTTPS over plain HTTP. Mirrors are not included.

func (*Service) ResolveIndex Uses

func (s *Service) ResolveIndex(name string) (*registrytypes.IndexInfo, error)

ResolveIndex takes indexName and returns index info

func (*Service) ResolveRepository Uses

func (s *Service) ResolveRepository(name reference.Named) (*RepositoryInfo, error)

ResolveRepository splits a repository name into its components and configuration of the associated registry.

func (*Service) Search Uses

func (s *Service) Search(term string, authConfig *types.AuthConfig, headers map[string][]string) (*registrytypes.SearchResults, error)

Search queries the public registry for images matching the specified search terms, and returns the results.

func (*Service) TLSConfig Uses

func (s *Service) TLSConfig(hostname string) (*tls.Config, error)

TLSConfig constructs a client TLS configuration based on server defaults

type Session Uses

type Session struct {
    // contains filtered or unexported fields

A Session is used to communicate with a V1 registry

func NewSession Uses

func NewSession(client *http.Client, authConfig *types.AuthConfig, endpoint *Endpoint) (r *Session, err error)

NewSession creates a new session TODO(tiborvass): remove authConfig param once registry client v2 is vendored

func (*Session) GetAuthConfig Uses

func (r *Session) GetAuthConfig(withPasswd bool) *types.AuthConfig

GetAuthConfig returns the authentication settings for a session TODO(tiborvass): remove this once registry client v2 is vendored

func (*Session) GetRemoteHistory Uses

func (r *Session) GetRemoteHistory(imgID, registry string) ([]string, error)

GetRemoteHistory retrieves the history of a given image from the registry. It returns a list of the parent's JSON files (including the requested image).

func (*Session) GetRemoteImageJSON Uses

func (r *Session) GetRemoteImageJSON(imgID, registry string) ([]byte, int64, error)

GetRemoteImageJSON retrieves an image's JSON metadata from the registry.

func (*Session) GetRemoteImageLayer Uses

func (r *Session) GetRemoteImageLayer(imgID, registry string, imgSize int64) (io.ReadCloser, error)

GetRemoteImageLayer retrieves an image layer from the registry

func (*Session) GetRemoteTag Uses

func (r *Session) GetRemoteTag(registries []string, repositoryRef reference.Named, askedTag string) (string, error)

GetRemoteTag retrieves the tag named in the askedTag argument from the given repository. It queries each of the registries supplied in the registries argument, and returns data from the first one that answers the query successfully.

func (*Session) GetRemoteTags Uses

func (r *Session) GetRemoteTags(registries []string, repositoryRef reference.Named) (map[string]string, error)

GetRemoteTags retrieves all tags from the given repository. It queries each of the registries supplied in the registries argument, and returns data from the first one that answers the query successfully. It returns a map with tag names as the keys and image IDs as the values.

func (*Session) GetRepositoryData Uses

func (r *Session) GetRepositoryData(name reference.Named) (*RepositoryData, error)

GetRepositoryData returns lists of images and endpoints for the repository

func (*Session) ID Uses

func (r *Session) ID() string

ID returns this registry session's ID.

func (*Session) LookupRemoteImage Uses

func (r *Session) LookupRemoteImage(imgID, registry string) error

LookupRemoteImage checks if an image exists in the registry

func (*Session) PushImageChecksumRegistry Uses

func (r *Session) PushImageChecksumRegistry(imgData *ImgData, registry string) error

PushImageChecksumRegistry uploads checksums for an image

func (*Session) PushImageJSONIndex Uses

func (r *Session) PushImageJSONIndex(remote reference.Named, imgList []*ImgData, validate bool, regs []string) (*RepositoryData, error)

PushImageJSONIndex uploads an image list to the repository

func (*Session) PushImageJSONRegistry Uses

func (r *Session) PushImageJSONRegistry(imgData *ImgData, jsonRaw []byte, registry string) error

PushImageJSONRegistry pushes JSON metadata for a local image to the registry

func (*Session) PushImageLayerRegistry Uses

func (r *Session) PushImageLayerRegistry(imgID string, layer io.Reader, registry string, jsonRaw []byte) (checksum string, checksumPayload string, err error)

PushImageLayerRegistry sends the checksum of an image layer to the registry

func (*Session) PushRegistryTag Uses

func (r *Session) PushRegistryTag(remote reference.Named, revision, tag, registry string) error

PushRegistryTag pushes a tag on the registry. Remote has the format '<user>/<repo>

func (*Session) SearchRepositories Uses

func (r *Session) SearchRepositories(term string) (*registrytypes.SearchResults, error)

SearchRepositories performs a search against the remote repository

Package registry imports 42 packages (graph). Updated 2016-07-17. Refresh now. Tools for package owners. This is a quick bug-fix fork (has fewer than three commits, and only during the week it was created).