Documentation ¶
Index ¶
- Constants
- Variables
- func AddRequiredHeadersToRedirectedRequests(req *http.Request, via []*http.Request) error
- func AuthTransport(base http.RoundTripper, authConfig *cliconfig.AuthConfig, ...) http.RoundTripper
- func DockerHeaders(metaHeaders http.Header) []transport.RequestModifier
- func HTTPClient(transport http.RoundTripper) *http.Client
- func IndexServerAddress() string
- func IndexServerName() string
- func Login(authConfig *cliconfig.AuthConfig, registryEndpoint *Endpoint) (string, error)
- func NewTransport(timeout TimeoutType, secure bool) http.RoundTripper
- func NormalizeLocalName(name string) string
- func ResolveAuthConfig(config *cliconfig.ConfigFile, index *IndexInfo) cliconfig.AuthConfig
- func ValidateIndexName(val string) (string, error)
- func ValidateMirror(val string) (string, error)
- func ValidateRepositoryName(reposName string) error
- type APIVersion
- type AuthorizationChallenge
- 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(authConfig *cliconfig.AuthConfig) (string, error)
- func (s *Service) ResolveIndex(name string) (*IndexInfo, error)
- func (s *Service) ResolveRepository(name string) (*RepositoryInfo, error)
- func (s *Service) Search(term string, authConfig *cliconfig.AuthConfig, headers map[string][]string) (*SearchResults, error)
- type ServiceConfig
- type Session
- func (r *Session) GetAuthConfig(withPasswd bool) *cliconfig.AuthConfig
- func (r *Session) GetRemoteHistory(imgID, registry string) ([]string, error)
- func (r *Session) GetRemoteImageJSON(imgID, registry string) ([]byte, int, error)
- func (r *Session) GetRemoteImageLayer(imgID, registry string, imgSize int64) (io.ReadCloser, error)
- func (r *Session) GetRemoteTags(registries []string, repository 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 string, dgst digest.Digest, blobWrtr io.Writer, ...) error
- func (r *Session) GetV2ImageBlobReader(ep *Endpoint, imageName string, dgst digest.Digest, auth *RequestAuthorization) (io.ReadCloser, int64, error)
- func (r *Session) GetV2ImageManifest(ep *Endpoint, imageName, tagName string, auth *RequestAuthorization) (remoteDigest digest.Digest, p []byte, err error)
- func (r *Session) GetV2RemoteTags(ep *Endpoint, imageName string, auth *RequestAuthorization) ([]string, error)
- func (r *Session) HeadV2ImageBlob(ep *Endpoint, imageName string, dgst digest.Digest, auth *RequestAuthorization) (bool, error)
- func (r *Session) LookupRemoteImage(imgID, registry string) error
- func (r *Session) PushImageChecksumRegistry(imgData *ImgData, registry 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) error
- func (r *Session) PushImageLayerRegistry(imgID string, layer io.Reader, registry string, jsonRaw []byte) (checksum string, checksumPayload string, err error)
- func (r *Session) PushRegistryTag(remote, revision, tag, registry string) error
- func (r *Session) PutV2ImageBlob(ep *Endpoint, imageName string, dgst digest.Digest, blobRdr io.Reader, ...) error
- func (r *Session) PutV2ImageManifest(ep *Endpoint, imageName, tagName string, signedManifest, rawManifest []byte, ...) (digest.Digest, 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 DockerDigestHeader = "Docker-Content-Digest"
Variables ¶
var ( ErrAlreadyExists = errors.New("Image already exists") ErrDoesNotExist = errors.New("Image does not exist") )
var (
ErrInvalidRepositoryName = errors.New("Invalid repository name (ex: \"registry.domain.tld/myrepos\")")
)
Functions ¶
func AddRequiredHeadersToRedirectedRequests ¶ added in v0.12.0
func AuthTransport ¶ added in v1.7.0
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 DockerHeaders ¶ added in v1.7.0
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 ¶ added in v1.7.0
func HTTPClient(transport http.RoundTripper) *http.Client
func IndexServerAddress ¶ added in v0.10.0
func IndexServerAddress() string
func IndexServerName ¶ added in v1.5.0
func IndexServerName() string
func Login ¶ added in v0.10.0
func Login(authConfig *cliconfig.AuthConfig, registryEndpoint *Endpoint) (string, error)
Login tries to register/login to the registry server.
func NewTransport ¶ added in v1.7.0
func NewTransport(timeout TimeoutType, secure bool) http.RoundTripper
func NormalizeLocalName ¶ added in v1.5.0
NormalizeLocalName transforms a repository name into a normalize LocalName Passes through the name without transformation on error (image id, etc)
func ResolveAuthConfig ¶ added in v1.7.0
func ResolveAuthConfig(config *cliconfig.ConfigFile, index *IndexInfo) cliconfig.AuthConfig
this method matches a auth configuration to a server address or a url
func ValidateIndexName ¶ added in v1.5.0
ValidateIndexName validates an index name.
func ValidateMirror ¶ added in v1.5.0
ValidateMirror validates an HTTP(S) registry mirror
func ValidateRepositoryName ¶ added in v1.5.0
ValidateRepositoryName validates a repository name
Types ¶
type APIVersion ¶ added in v1.3.0
type APIVersion int
func (APIVersion) String ¶ added in v1.3.0
func (av APIVersion) String() string
type AuthorizationChallenge ¶ added in v1.5.0
AuthorizationChallenge carries information from a WWW-Authenticate response header.
type Endpoint ¶ added in v1.3.0
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 ¶ added in v1.3.0
NewEndpoint parses the given address to return a registry endpoint.
func (*Endpoint) Path ¶ added in v1.5.0
Path returns a formatted string for the URL of this endpoint with the given path appended.
func (*Endpoint) Ping ¶ added in v1.3.0
func (e *Endpoint) Ping() (RegistryInfo, error)
func (*Endpoint) String ¶ added in v1.3.0
Get the formated URL for the root of this registry Endpoint
func (*Endpoint) VersionString ¶ added in v1.3.0
func (e *Endpoint) VersionString(version APIVersion) string
VersionString returns a formatted string of this endpoint address using the given API Version.
type IndexInfo ¶ added in v1.5.0
{ "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 ¶ added in v1.5.0
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 ¶ added in v1.3.0
type ManifestHistory ¶ added in v1.3.0
type ManifestHistory struct {
V1Compatibility string `json:"v1Compatibility"`
}
type Options ¶ added in v1.5.0
Options holds command line options.
func (*Options) InstallFlags ¶ added in v1.5.0
func (options *Options) InstallFlags()
InstallFlags adds command-line options to the top-level flag parser for the current process.
type RegistryInfo ¶ added in v0.11.0
type RepositoryData ¶
type RepositoryInfo ¶ added in v1.5.0
type RepositoryInfo struct { Index *IndexInfo RemoteName string LocalName string CanonicalName string Official bool }
func ParseRepositoryInfo ¶ added in v1.5.0
func ParseRepositoryInfo(reposName string) (*RepositoryInfo, error)
ParseRepositoryInfo performs the breakdown of a repository name into a RepositoryInfo, but lacks registry configuration.
func (*RepositoryInfo) GetEndpoint ¶ added in v1.5.0
func (repoInfo *RepositoryInfo) GetEndpoint(metaHeaders http.Header) (*Endpoint, error)
func (*RepositoryInfo) GetSearchTerm ¶ added in v1.5.0
func (repoInfo *RepositoryInfo) GetSearchTerm() string
GetSearchTerm special-cases using local name for official index, and remote name for private indexes.
type RequestAuthorization ¶ added in v1.5.0
type RequestAuthorization struct {
// contains filtered or unexported fields
}
func NewRequestAuthorization ¶ added in v1.5.0
func NewRequestAuthorization(authConfig *cliconfig.AuthConfig, registryEndpoint *Endpoint, resource, scope string, actions []string) *RequestAuthorization
type SearchResult ¶ added in v0.6.6
type SearchResults ¶
type SearchResults struct { Query string `json:"query"` NumResults int `json:"num_results"` Results []SearchResult `json:"results"` }
type Service ¶ added in v0.11.0
type Service struct {
Config *ServiceConfig
}
func NewService ¶ added in v0.11.0
NewService returns a new instance of Service ready to be installed no an engine.
func (*Service) Auth ¶ added in v0.11.0
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) ResolveIndex ¶ added in v1.5.0
ResolveIndex takes indexName and returns index info
func (*Service) ResolveRepository ¶ added in v1.5.0
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 ¶ added in v0.11.0
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.
type ServiceConfig ¶ added in v1.5.0
type ServiceConfig struct { InsecureRegistryCIDRs []*netIPNet `json:"InsecureRegistryCIDRs"` IndexConfigs map[string]*IndexInfo `json:"IndexConfigs"` }
ServiceConfig stores daemon registry services configuration.
func NewServiceConfig ¶ added in v1.5.0
func NewServiceConfig(options *Options) *ServiceConfig
NewServiceConfig returns a new instance of ServiceConfig
func (*ServiceConfig) NewIndexInfo ¶ added in v1.5.0
func (config *ServiceConfig) NewIndexInfo(indexName string) (*IndexInfo, error)
NewIndexInfo returns IndexInfo configuration from indexName
func (*ServiceConfig) NewRepositoryInfo ¶ added in v1.5.0
func (config *ServiceConfig) NewRepositoryInfo(reposName string) (*RepositoryInfo, error)
NewRepositoryInfo validates and breaks down a repository name into a RepositoryInfo
type Session ¶ added in v1.2.0
type Session struct {
// contains filtered or unexported fields
}
func NewSession ¶ added in v1.2.0
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 ¶ added in v1.2.0
func (r *Session) GetAuthConfig(withPasswd bool) *cliconfig.AuthConfig
TODO(tiborvass): remove this once registry client v2 is vendored
func (*Session) GetRemoteHistory ¶ added in v1.2.0
Retrieve the history of a given image from the Registry. Return a list of the parent's json (requested image included)
func (*Session) GetRemoteImageJSON ¶ added in v1.2.0
Retrieve an image from the Registry.
func (*Session) GetRemoteImageLayer ¶ added in v1.2.0
func (*Session) GetRemoteTags ¶ added in v1.2.0
func (*Session) GetRepositoryData ¶ added in v1.2.0
func (r *Session) GetRepositoryData(remote string) (*RepositoryData, error)
func (*Session) GetV2Authorization ¶ added in v1.5.0
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 the authorization may only be used for Get operations.
func (*Session) GetV2ImageBlob ¶ added in v1.3.0
func (*Session) GetV2ImageBlobReader ¶ added in v1.3.0
func (r *Session) GetV2ImageBlobReader(ep *Endpoint, imageName string, dgst digest.Digest, auth *RequestAuthorization) (io.ReadCloser, int64, error)
func (*Session) GetV2ImageManifest ¶ added in v1.3.0
func (r *Session) GetV2ImageManifest(ep *Endpoint, imageName, tagName string, auth *RequestAuthorization) (remoteDigest digest.Digest, p []byte, err error)
GetV2ImageManifest simply fetches the bytes of a manifest and the remote digest, if available in the request. Note that the application shouldn't rely on the untrusted remoteDigest, and should also verify against a locally provided digest, if applicable.
func (*Session) GetV2RemoteTags ¶ added in v1.3.0
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 ¶ added in v1.5.0
func (r *Session) HeadV2ImageBlob(ep *Endpoint, imageName string, dgst digest.Digest, 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 ¶ added in v1.2.0
Check if an image exists in the Registry
func (*Session) PushImageChecksumRegistry ¶ added in v1.2.0
func (*Session) PushImageJSONIndex ¶ added in v1.2.0
func (*Session) PushImageJSONRegistry ¶ added in v1.2.0
Push a local image to the registry
func (*Session) PushImageLayerRegistry ¶ added in v1.2.0
func (*Session) PushRegistryTag ¶ added in v1.2.0
push a tag on the registry. Remote has the format '<user>/<repo>
func (*Session) PutV2ImageBlob ¶ added in v1.3.0
func (r *Session) PutV2ImageBlob(ep *Endpoint, imageName string, dgst digest.Digest, 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 ¶ added in v1.3.0
func (r *Session) PutV2ImageManifest(ep *Endpoint, imageName, tagName string, signedManifest, rawManifest []byte, auth *RequestAuthorization) (digest.Digest, error)
Finally Push the (signed) manifest of the blobs we've just pushed
func (*Session) SearchRepositories ¶ added in v1.2.0
func (r *Session) SearchRepositories(term string) (*SearchResults, error)
type TimeoutType ¶ added in v1.2.0
type TimeoutType uint32
const ( NoTimeout TimeoutType = iota ReceiveTimeout ConnectTimeout )