Documentation ¶
Index ¶
- Constants
- Variables
- func AddRequiredHeadersToRedirectedRequests(req *http.Request, via []*http.Request) error
- func HTTPRequestFactory(metaHeaders map[string][]string) *utils.HTTPRequestFactory
- func IndexServerAddress() string
- func IndexServerName() string
- func Login(authConfig *AuthConfig, registryEndpoint *Endpoint, ...) (string, error)
- func NormalizeLocalName(name string) string
- func SaveConfig(configFile *ConfigFile) error
- func ValidateIndexName(val string) (string, error)
- func ValidateMirror(val string) (string, error)
- func ValidateRepositoryName(reposName string) error
- type APIVersion
- type AuthConfig
- type AuthorizationChallenge
- type ConfigFile
- type Endpoint
- type FSLayer
- type ImgData
- type IndexInfo
- type ManifestData
- type ManifestHistory
- type Options
- type RegistryInfo
- type RepositoryData
- type RepositoryInfo
- type RequestAuthorization
- type SearchResult
- type SearchResults
- type Service
- func (s *Service) Auth(job *engine.Job) engine.Status
- func (s *Service) GetRegistryConfig(job *engine.Job) engine.Status
- func (s *Service) Install(eng *engine.Engine) error
- func (s *Service) ResolveIndex(job *engine.Job) engine.Status
- func (s *Service) ResolveRepository(job *engine.Job) engine.Status
- func (s *Service) Search(job *engine.Job) engine.Status
- type ServiceConfig
- type Session
- func (r *Session) GetAuthConfig(withPasswd bool) *AuthConfig
- func (r *Session) GetRemoteHistory(imgID, registry string, token []string) ([]string, error)
- func (r *Session) GetRemoteImageJSON(imgID, registry string, token []string) ([]byte, int, error)
- func (r *Session) GetRemoteImageLayer(imgID, registry string, token []string, imgSize int64) (io.ReadCloser, error)
- func (r *Session) GetRemoteTags(registries []string, repository string, token []string) (map[string]string, error)
- func (r *Session) GetRepositoryData(remote string) (*RepositoryData, error)
- func (r *Session) GetV2Authorization(ep *Endpoint, imageName string, readOnly bool) (auth *RequestAuthorization, err error)
- func (r *Session) GetV2ImageBlob(ep *Endpoint, imageName, sumType, sum string, blobWrtr io.Writer, ...) error
- func (r *Session) GetV2ImageBlobReader(ep *Endpoint, imageName, sumType, sum string, auth *RequestAuthorization) (io.ReadCloser, int64, error)
- func (r *Session) GetV2ImageManifest(ep *Endpoint, imageName, tagName string, auth *RequestAuthorization) ([]byte, string, error)
- func (r *Session) GetV2RemoteTags(ep *Endpoint, imageName string, auth *RequestAuthorization) ([]string, error)
- func (r *Session) HeadV2ImageBlob(ep *Endpoint, imageName, sumType, sum string, auth *RequestAuthorization) (bool, error)
- func (r *Session) LookupRemoteImage(imgID, registry string, token []string) error
- func (r *Session) PushImageChecksumRegistry(imgData *ImgData, registry string, token []string) error
- func (r *Session) PushImageJSONIndex(remote string, imgList []*ImgData, validate bool, regs []string) (*RepositoryData, error)
- func (r *Session) PushImageJSONRegistry(imgData *ImgData, jsonRaw []byte, registry string, token []string) error
- func (r *Session) PushImageLayerRegistry(imgID string, layer io.Reader, registry string, token []string, jsonRaw []byte) (checksum string, checksumPayload string, err error)
- func (r *Session) PushRegistryTag(remote, revision, tag, registry string, token []string) error
- func (r *Session) PutV2ImageBlob(ep *Endpoint, imageName, sumType, sumStr string, blobRdr io.Reader, ...) error
- func (r *Session) PutV2ImageManifest(ep *Endpoint, imageName, tagName string, manifestRdr io.Reader, ...) (string, error)
- func (r *Session) SearchRepositories(term string) (*SearchResults, error)
- func (r *Session) V2RegistryEndpoint(index *IndexInfo) (ep *Endpoint, err error)
- type TimeoutType
Constants ¶
const ( // Only used for user auth + account creation INDEXSERVER = "https://index.docker.io/v1/" REGISTRYSERVER = "https://registry-1.docker.io/v2/" INDEXNAME = "docker.io" )
const ( APIVersionUnknown = iota APIVersion1 APIVersion2 )
API Version identifiers.
const (
// Where we store the config file
CONFIGFILE = ".dockercfg"
)
const DockerDigestHeader = "Docker-Content-Digest"
Variables ¶
var ( ErrAlreadyExists = errors.New("Image already exists") ErrDoesNotExist = errors.New("Image does not exist") )
var (
ErrConfigFileMissing = errors.New("The Auth config file is missing")
)
var (
ErrInvalidRepositoryName = errors.New("Invalid repository name (ex: \"registry.domain.tld/myrepos\")")
)
Functions ¶
func HTTPRequestFactory ¶
func HTTPRequestFactory(metaHeaders map[string][]string) *utils.HTTPRequestFactory
func IndexServerAddress ¶
func IndexServerAddress() string
func IndexServerName ¶
func IndexServerName() string
func Login ¶
func Login(authConfig *AuthConfig, registryEndpoint *Endpoint, factory *utils.HTTPRequestFactory) (string, error)
Login tries to register/login to the registry server.
func NormalizeLocalName ¶
NormalizeLocalName transforms a repository name into a normalize LocalName Passes through the name without transformation on error (image id, etc)
func ValidateIndexName ¶
ValidateIndexName validates an index name.
func ValidateMirror ¶
ValidateMirror validates an HTTP(S) registry mirror
func ValidateRepositoryName ¶
ValidateRepositoryName validates a repository name
Types ¶
type APIVersion ¶
type APIVersion int
func (APIVersion) String ¶
func (av APIVersion) String() string
type AuthConfig ¶
type AuthorizationChallenge ¶
AuthorizationChallenge carries information from a WWW-Authenticate response header.
type ConfigFile ¶
type ConfigFile struct { Configs map[string]AuthConfig `json:"configs,omitempty"` // contains filtered or unexported fields }
func LoadConfig ¶
func LoadConfig(rootPath string) (*ConfigFile, error)
load up the auth config information and return values FIXME: use the internal golang config parser
func (*ConfigFile) ResolveAuthConfig ¶
func (config *ConfigFile) ResolveAuthConfig(index *IndexInfo) AuthConfig
this method matches a auth configuration to a server address or a url
type Endpoint ¶
type Endpoint struct { URL *url.URL Version APIVersion IsSecure bool AuthChallenges []*AuthorizationChallenge URLBuilder *v2.URLBuilder }
Endpoint stores basic information about a registry endpoint.
func NewEndpoint ¶
NewEndpoint parses the given address to return a registry endpoint.
func (*Endpoint) Path ¶
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) VersionString ¶
func (e *Endpoint) VersionString(version APIVersion) string
VersionString returns a formatted string of this endpoint address using the given API Version.
type IndexInfo ¶
{ "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 ResolveIndexInfo ¶
Convenience wrapper for calling resolve_index Job from a running job.
func (*IndexInfo) GetAuthConfigKey ¶
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 ManifestHistory ¶
type ManifestHistory struct {
V1Compatibility string `json:"v1Compatibility"`
}
type Options ¶
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 RepositoryData ¶
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 ResolveRepositoryInfo ¶
func ResolveRepositoryInfo(jobContext *engine.Job, reposName string) (*RepositoryInfo, error)
Convenience wrapper for calling resolve_repository Job from a running job.
func (*RepositoryInfo) GetEndpoint ¶
func (repoInfo *RepositoryInfo) GetEndpoint() (*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 *AuthConfig, registryEndpoint *Endpoint, resource, scope string, actions []string) *RequestAuthorization
type SearchResult ¶
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
}
Service exposes registry capabilities in the standard Engine interface. Once installed, it extends the engine with the following calls:
'auth': Authenticate against the public registry 'search': Search for images on the public registry 'pull': Download images from any registry (TODO) 'push': Upload images to any registry (TODO)
func NewService ¶
NewService returns a new instance of Service ready to be installed no an engine.
func (*Service) Auth ¶
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) GetRegistryConfig ¶
GetRegistryConfig returns current registry configuration.
func (*Service) ResolveIndex ¶
ResolveIndex takes indexName and returns index info
func (*Service) ResolveRepository ¶
ResolveRepository splits a repository name into its components and configuration of the associated registry.
func (*Service) Search ¶
Search queries the public registry for images matching the specified search terms, and returns the results.
Argument syntax: search TERM
Option environment:
'authConfig': json-encoded credentials to authenticate against the registry. The search extends to images only accessible via the credentials. 'metaHeaders': extra HTTP headers to include in the request to the registry. The headers should be passed as a json-encoded dictionary.
Output:
Results are sent as a collection of structured messages (using engine.Table). Each result is sent as a separate message. Results are ordered by number of stars on the public registry.
type ServiceConfig ¶
type ServiceConfig struct { InsecureRegistryCIDRs []*netIPNet `json:"InsecureRegistryCIDRs"` IndexConfigs map[string]*IndexInfo `json:"IndexConfigs"` }
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(authConfig *AuthConfig, factory *utils.HTTPRequestFactory, endpoint *Endpoint, timeout bool) (r *Session, err error)
func (*Session) GetAuthConfig ¶
func (r *Session) GetAuthConfig(withPasswd bool) *AuthConfig
func (*Session) GetRemoteHistory ¶
Retrieve the history of a given image from the Registry. Return a list of the parent's json (requested image included)
func (*Session) GetRemoteImageJSON ¶
Retrieve an image from the Registry.
func (*Session) GetRemoteImageLayer ¶
func (*Session) GetRemoteTags ¶
func (*Session) GetRepositoryData ¶
func (r *Session) GetRepositoryData(remote string) (*RepositoryData, error)
func (*Session) GetV2Authorization ¶
func (r *Session) GetV2Authorization(ep *Endpoint, imageName string, readOnly bool) (auth *RequestAuthorization, err error)
GetV2Authorization gets the authorization needed to the given image If readonly access is requested, then only the authorization may only be used for Get operations.
func (*Session) GetV2ImageBlob ¶
func (*Session) GetV2ImageBlobReader ¶
func (r *Session) GetV2ImageBlobReader(ep *Endpoint, imageName, sumType, sum string, auth *RequestAuthorization) (io.ReadCloser, int64, error)
func (*Session) GetV2ImageManifest ¶
func (r *Session) GetV2ImageManifest(ep *Endpoint, imageName, tagName string, auth *RequestAuthorization) ([]byte, string, error)
- Check if TarSum of each layer exists /v2/ 1.a) if 200, continue 1.b) if 300, then push the 1.c) if anything else, err
- PUT the created/signed manifest
func (*Session) GetV2RemoteTags ¶
func (r *Session) GetV2RemoteTags(ep *Endpoint, imageName string, auth *RequestAuthorization) ([]string, error)
Given a repository name, returns a json array of string tags
func (*Session) HeadV2ImageBlob ¶
func (r *Session) HeadV2ImageBlob(ep *Endpoint, imageName, sumType, sum string, auth *RequestAuthorization) (bool, error)
- Succeeded to head image blob (already exists) - Failed with no error (continue to Push the Blob) - Failed with error
func (*Session) LookupRemoteImage ¶
Check if an image exists in the Registry
func (*Session) PushImageChecksumRegistry ¶
func (*Session) PushImageJSONIndex ¶
func (*Session) PushImageJSONRegistry ¶
func (r *Session) PushImageJSONRegistry(imgData *ImgData, jsonRaw []byte, registry string, token []string) error
Push a local image to the registry
func (*Session) PushImageLayerRegistry ¶
func (*Session) PushRegistryTag ¶
push a tag on the registry. Remote has the format '<user>/<repo>
func (*Session) PutV2ImageBlob ¶
func (r *Session) PutV2ImageBlob(ep *Endpoint, imageName, sumType, sumStr string, blobRdr io.Reader, auth *RequestAuthorization) error
Push the image to the server for storage. 'layer' is an uncompressed reader of the blob to be pushed. The server will generate it's own checksum calculation.
func (*Session) PutV2ImageManifest ¶
func (r *Session) PutV2ImageManifest(ep *Endpoint, imageName, tagName string, manifestRdr io.Reader, auth *RequestAuthorization) (string, error)
Finally Push the (signed) manifest of the blobs we've just pushed
func (*Session) SearchRepositories ¶
func (r *Session) SearchRepositories(term string) (*SearchResults, error)
type TimeoutType ¶
type TimeoutType uint32
const ( NoTimeout TimeoutType = iota ReceiveTimeout ConnectTimeout )