2014-08-07 10:43:06 -04:00
|
|
|
package registry
|
|
|
|
|
2015-11-18 17:20:54 -05:00
|
|
|
import (
|
|
|
|
"github.com/docker/distribution/reference"
|
|
|
|
)
|
|
|
|
|
2015-07-21 15:40:36 -04:00
|
|
|
// SearchResult describes a search result returned from a registry
|
2014-08-07 10:43:06 -04:00
|
|
|
type SearchResult struct {
|
2015-07-21 15:40:36 -04:00
|
|
|
// StarCount indicates the number of stars this repository has
|
|
|
|
StarCount int `json:"star_count"`
|
|
|
|
// IsOfficial indicates whether the result is an official repository or not
|
|
|
|
IsOfficial bool `json:"is_official"`
|
|
|
|
// Name is the name of the repository
|
|
|
|
Name string `json:"name"`
|
|
|
|
// IsOfficial indicates whether the result is trusted
|
|
|
|
IsTrusted bool `json:"is_trusted"`
|
|
|
|
// IsAutomated indicates whether the result is automated
|
|
|
|
IsAutomated bool `json:"is_automated"`
|
|
|
|
// Description is a textual description of the repository
|
2014-08-07 10:43:06 -04:00
|
|
|
Description string `json:"description"`
|
|
|
|
}
|
|
|
|
|
2015-07-21 15:40:36 -04:00
|
|
|
// SearchResults lists a collection search results returned from a registry
|
2014-08-07 10:43:06 -04:00
|
|
|
type SearchResults struct {
|
2015-07-21 15:40:36 -04:00
|
|
|
// Query contains the query string that generated the search results
|
|
|
|
Query string `json:"query"`
|
|
|
|
// NumResults indicates the number of results the query returned
|
|
|
|
NumResults int `json:"num_results"`
|
|
|
|
// Results is a slice containing the acutal results for the search
|
|
|
|
Results []SearchResult `json:"results"`
|
2014-08-07 10:43:06 -04:00
|
|
|
}
|
|
|
|
|
2015-07-21 15:40:36 -04:00
|
|
|
// RepositoryData tracks the image list, list of endpoints, and list of tokens
|
|
|
|
// for a repository
|
2014-08-07 10:43:06 -04:00
|
|
|
type RepositoryData struct {
|
2015-07-21 15:40:36 -04:00
|
|
|
// ImgList is a list of images in the repository
|
|
|
|
ImgList map[string]*ImgData
|
|
|
|
// Endpoints is a list of endpoints returned in X-Docker-Endpoints
|
2014-08-07 10:43:06 -04:00
|
|
|
Endpoints []string
|
2015-07-21 15:40:36 -04:00
|
|
|
// Tokens is currently unused (remove it?)
|
|
|
|
Tokens []string
|
2014-08-07 10:43:06 -04:00
|
|
|
}
|
|
|
|
|
2015-07-21 15:40:36 -04:00
|
|
|
// ImgData is used to transfer image checksums to and from the registry
|
2014-08-07 10:43:06 -04:00
|
|
|
type ImgData struct {
|
2015-07-21 15:40:36 -04:00
|
|
|
// ID is an opaque string that identifies the image
|
2014-08-07 10:43:06 -04:00
|
|
|
ID string `json:"id"`
|
|
|
|
Checksum string `json:"checksum,omitempty"`
|
|
|
|
ChecksumPayload string `json:"-"`
|
|
|
|
Tag string `json:",omitempty"`
|
|
|
|
}
|
|
|
|
|
2015-07-21 15:40:36 -04:00
|
|
|
// 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 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"`
|
2014-08-07 10:43:06 -04:00
|
|
|
}
|
2014-08-26 19:21:04 -04:00
|
|
|
|
2015-07-21 15:40:36 -04:00
|
|
|
// APIVersion is an integral representation of an API version (presently
|
|
|
|
// either 1 or 2)
|
2014-08-26 19:21:04 -04:00
|
|
|
type APIVersion int
|
|
|
|
|
|
|
|
func (av APIVersion) String() string {
|
|
|
|
return apiVersions[av]
|
|
|
|
}
|
|
|
|
|
|
|
|
var apiVersions = map[APIVersion]string{
|
|
|
|
1: "v1",
|
|
|
|
2: "v2",
|
|
|
|
}
|
|
|
|
|
2014-12-11 20:55:15 -05:00
|
|
|
// API Version identifiers.
|
2014-08-26 19:21:04 -04:00
|
|
|
const (
|
2014-12-11 20:55:15 -05:00
|
|
|
APIVersionUnknown = iota
|
|
|
|
APIVersion1
|
2014-08-26 19:21:04 -04:00
|
|
|
APIVersion2
|
|
|
|
)
|
2014-10-06 21:54:52 -04:00
|
|
|
|
2015-07-21 15:40:36 -04:00
|
|
|
// IndexInfo contains information about a registry
|
|
|
|
//
|
2014-10-06 21:54:52 -04:00
|
|
|
// RepositoryInfo Examples:
|
|
|
|
// {
|
|
|
|
// "Index" : {
|
|
|
|
// "Name" : "docker.io",
|
|
|
|
// "Mirrors" : ["https://registry-2.docker.io/v1/", "https://registry-3.docker.io/v1/"],
|
|
|
|
// "Secure" : true,
|
|
|
|
// "Official" : true,
|
|
|
|
// },
|
|
|
|
// "RemoteName" : "library/debian",
|
|
|
|
// "LocalName" : "debian",
|
|
|
|
// "CanonicalName" : "docker.io/debian"
|
|
|
|
// "Official" : true,
|
|
|
|
// }
|
2015-07-21 15:40:36 -04:00
|
|
|
//
|
2014-10-06 21:54:52 -04:00
|
|
|
// {
|
|
|
|
// "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,
|
|
|
|
// }
|
|
|
|
type IndexInfo struct {
|
2015-07-21 15:40:36 -04:00
|
|
|
// Name is the name of the registry, such as "docker.io"
|
|
|
|
Name string
|
|
|
|
// Mirrors is a list of mirrors, expressed as URIs
|
|
|
|
Mirrors []string
|
|
|
|
// Secure is set to false if the registry is part of the list of
|
|
|
|
// insecure registries. Insecure registries accept HTTP and/or accept
|
|
|
|
// HTTPS with certificates from unknown CAs.
|
|
|
|
Secure bool
|
|
|
|
// Official indicates whether this is an official registry
|
2014-10-06 21:54:52 -04:00
|
|
|
Official bool
|
|
|
|
}
|
|
|
|
|
2015-07-21 15:40:36 -04:00
|
|
|
// RepositoryInfo describes a repository
|
2014-10-06 21:54:52 -04:00
|
|
|
type RepositoryInfo struct {
|
2015-07-21 15:40:36 -04:00
|
|
|
// Index points to registry information
|
|
|
|
Index *IndexInfo
|
|
|
|
// RemoteName is the remote name of the repository, such as
|
|
|
|
// "library/ubuntu-12.04-base"
|
2015-11-18 17:20:54 -05:00
|
|
|
RemoteName reference.Named
|
2015-07-21 15:40:36 -04:00
|
|
|
// LocalName is the local name of the repository, such as
|
|
|
|
// "ubuntu-12.04-base"
|
2015-11-18 17:20:54 -05:00
|
|
|
LocalName reference.Named
|
2015-07-21 15:40:36 -04:00
|
|
|
// CanonicalName is the canonical name of the repository, such as
|
|
|
|
// "docker.io/library/ubuntu-12.04-base"
|
2015-11-18 17:20:54 -05:00
|
|
|
CanonicalName reference.Named
|
2015-07-21 15:40:36 -04:00
|
|
|
// 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
|
2014-10-06 21:54:52 -04:00
|
|
|
}
|