registry

package
v1.4.2-0...-77bbee3 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2015 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_NAMESPACE               = "docker.io"
	DEFAULT_V2_REGISTRY             = "https://registry-1.docker.io"
	DEFAULT_REGISTRY_VERSION_HEADER = "Docker-Distribution-Api-Version"
	DEFAULT_V1_REGISTRY             = "https://index.docker.io"

	CERTS_DIR = "/etc/docker/certs.d"

	// Only used for user auth + account creation
	REGISTRYSERVER = DEFAULT_V2_REGISTRY
	INDEXSERVER    = DEFAULT_V1_REGISTRY + "/v1/"
	INDEXNAME      = "docker.io"
)
View Source
const (
	APIVersionUnknown = iota
	APIVersion1
	APIVersion2
)

API Version identifiers.

Variables

View Source
var (
	ErrAlreadyExists = errors.New("Image already exists")
	ErrDoesNotExist  = errors.New("Image does not exist")
)
View Source
var (
	ErrInvalidRepositoryName = errors.New("Invalid repository name (ex: \"registry.domain.tld/myrepos\")")
)
View Source
var (
	ErrRepoNotFound = errors.New("Repository not found")
)

Functions

func AddRequiredHeadersToRedirectedRequests

func AddRequiredHeadersToRedirectedRequests(req *http.Request, via []*http.Request) error

func AuthTransport

func AuthTransport(base http.RoundTripper, authConfig *cliconfig.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

func ContinueOnError(err error) bool

func DockerHeaders

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 HTTPClient

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

func Login

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

Login tries to register/login to the registry server.

func NewTransport

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

func NormalizeLocalName

func NormalizeLocalName(name string) string

NormalizeLocalName transforms a repository name into a normalize LocalName Passes through the name without transformation on error (image id, etc)

func ResolveAuthConfig

func ResolveAuthConfig(config *cliconfig.ConfigFile, index *IndexInfo) cliconfig.AuthConfig

this method matches a auth configuration to a server address or a url

func ValidateIndexName

func ValidateIndexName(val string) (string, error)

ValidateIndexName validates an index name.

func ValidateMirror

func ValidateMirror(val string) (string, error)

ValidateMirror validates an HTTP(S) registry mirror

func ValidateRepositoryName

func ValidateRepositoryName(reposName string) error

ValidateRepositoryName validates a repository name

Types

type APIEndpoint

type APIEndpoint struct {
	Mirror        bool
	URL           string
	Version       APIVersion
	Official      bool
	TrimHostname  bool
	TLSConfig     *tls.Config
	VersionHeader string
	Versions      []auth.APIVersion
}

func (APIEndpoint) ToV1Endpoint

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

type APIVersion

type APIVersion int

func (APIVersion) String

func (av APIVersion) String() string

type AuthorizationChallenge

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

AuthorizationChallenge carries information from a WWW-Authenticate response header.

type Endpoint

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

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

NewEndpoint parses the given address to return a registry endpoint.

func (*Endpoint) Path

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

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

func (*Endpoint) String

func (e *Endpoint) String() string

Get the formated URL for the root of this registry Endpoint

func (*Endpoint) VersionString

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

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

type ErrNoSupport

type ErrNoSupport struct{ Err error }

func (ErrNoSupport) Error

func (e ErrNoSupport) Error() string

type FSLayer

type FSLayer struct {
	BlobSum string `json:"blobSum"`
}

type ImgData

type ImgData struct {
	ID              string `json:"id"`
	Checksum        string `json:"checksum,omitempty"`
	ChecksumPayload string `json:"-"`
	Tag             string `json:",omitempty"`
}

type IndexInfo

type IndexInfo struct {
	Name     string
	Mirrors  []string
	Secure   bool
	Official bool
}
{
  "Index" : {
    "Name" : "127.0.0.1:5000",
    "Mirrors" : [],
    "Secure" : false,
    "Official" : false,
  },
  "RemoteName" : "user/repo",
  "LocalName" : "127.0.0.1:5000/user/repo",
  "CanonicalName" : "127.0.0.1:5000/user/repo",
  "Official" : false,
}

func (*IndexInfo) GetAuthConfigKey

func (index *IndexInfo) GetAuthConfigKey() 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.

type ManifestData

type ManifestData struct {
	Name          string             `json:"name"`
	Tag           string             `json:"tag"`
	Architecture  string             `json:"architecture"`
	FSLayers      []*FSLayer         `json:"fsLayers"`
	History       []*ManifestHistory `json:"history"`
	SchemaVersion int                `json:"schemaVersion"`
}

type ManifestHistory

type ManifestHistory struct {
	V1Compatibility string `json:"v1Compatibility"`
}

type Options

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

Options holds command line options.

func (*Options) InstallFlags

func (options *Options) InstallFlags()

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

type RegistryInfo

type RegistryInfo struct {
	Version    string `json:"version"`
	Standalone bool   `json:"standalone"`
}

type RepositoryData

type RepositoryData struct {
	ImgList   map[string]*ImgData
	Endpoints []string
	Tokens    []string
}

type RepositoryInfo

type RepositoryInfo struct {
	Index         *IndexInfo
	RemoteName    string
	LocalName     string
	CanonicalName string
	Official      bool
}

func ParseRepositoryInfo

func ParseRepositoryInfo(reposName string) (*RepositoryInfo, error)

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

func (*RepositoryInfo) GetEndpoint

func (repoInfo *RepositoryInfo) GetEndpoint(metaHeaders http.Header) (*Endpoint, error)

func (*RepositoryInfo) GetSearchTerm

func (repoInfo *RepositoryInfo) GetSearchTerm() string

GetSearchTerm special-cases using local name for official index, and remote name for private indexes.

type RequestAuthorization

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

func NewRequestAuthorization

func NewRequestAuthorization(authConfig *cliconfig.AuthConfig, registryEndpoint *Endpoint, resource, scope string, actions []string) *RequestAuthorization

func (*RequestAuthorization) Authorize

func (auth *RequestAuthorization) Authorize(req *http.Request) error

func (*RequestAuthorization) CanAuthorizeV2

func (auth *RequestAuthorization) CanAuthorizeV2() bool

Checks that requests to the v2 registry can be authorized.

type SearchResult

type SearchResult struct {
	StarCount   int    `json:"star_count"`
	IsOfficial  bool   `json:"is_official"`
	Name        string `json:"name"`
	IsTrusted   bool   `json:"is_trusted"`
	IsAutomated bool   `json:"is_automated"`
	Description string `json:"description"`
}

type SearchResults

type SearchResults struct {
	Query      string         `json:"query"`
	NumResults int            `json:"num_results"`
	Results    []SearchResult `json:"results"`
}

type Service

type Service struct {
	Config *ServiceConfig
}

func NewService

func NewService(options *Options) *Service

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

func (*Service) Auth

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

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

func (*Service) LookupEndpoints

func (s *Service) LookupEndpoints(repoName string) (endpoints []APIEndpoint, err error)

func (*Service) ResolveIndex

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

ResolveIndex takes indexName and returns index info

func (*Service) ResolveRepository

func (s *Service) ResolveRepository(name string) (*RepositoryInfo, error)

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

func (*Service) Search

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

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

func (*Service) TlsConfig

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

type ServiceConfig

type ServiceConfig struct {
	InsecureRegistryCIDRs []*netIPNet           `json:"InsecureRegistryCIDRs"`
	IndexConfigs          map[string]*IndexInfo `json:"IndexConfigs"`
	Mirrors               []string
}

ServiceConfig stores daemon registry services configuration.

func NewServiceConfig

func NewServiceConfig(options *Options) *ServiceConfig

NewServiceConfig returns a new instance of ServiceConfig

func (*ServiceConfig) NewIndexInfo

func (config *ServiceConfig) NewIndexInfo(indexName string) (*IndexInfo, error)

NewIndexInfo returns IndexInfo configuration from indexName

func (*ServiceConfig) NewRepositoryInfo

func (config *ServiceConfig) NewRepositoryInfo(reposName string) (*RepositoryInfo, error)

NewRepositoryInfo validates and breaks down a repository name into a RepositoryInfo

type Session

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

func NewSession

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

TODO(tiborvass): remove authConfig param once registry client v2 is vendored

func (*Session) GetAuthConfig

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

TODO(tiborvass): remove this once registry client v2 is vendored

func (*Session) GetRemoteHistory

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

Retrieve the history of a given image from the Registry. Return a list of the parent's json (requested image included)

func (*Session) GetRemoteImageJSON

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

Retrieve an image from the Registry.

func (*Session) GetRemoteImageLayer

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

func (*Session) GetRemoteTag

func (r *Session) GetRemoteTag(registries []string, repository string, askedTag string) (string, error)

func (*Session) GetRemoteTags

func (r *Session) GetRemoteTags(registries []string, repository string) (map[string]string, error)

func (*Session) GetRepositoryData

func (r *Session) GetRepositoryData(remote string) (*RepositoryData, error)

func (*Session) ID

func (r *Session) ID() string

ID returns this registry session's ID.

func (*Session) LookupRemoteImage

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

Check if an image exists in the Registry

func (*Session) PushImageChecksumRegistry

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

func (*Session) PushImageJSONIndex

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

func (*Session) PushImageJSONRegistry

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

Push a local image to the registry

func (*Session) PushImageLayerRegistry

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

func (*Session) PushRegistryTag

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

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

func (*Session) SearchRepositories

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

type TimeoutType

type TimeoutType uint32
const (
	NoTimeout TimeoutType = iota
	ReceiveTimeout
	ConnectTimeout
)

Jump to

Keyboard shortcuts

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