Improve documentation and golint compliance of registry package
* Add godoc documentation where it was missing * Change identifier names that don't match Go style, such as INDEX_NAME * Rename RegistryInfo to PingResult, which more accurately describes what this structure is for. It also has the benefit of making the name not stutter if used outside the package. Updates #14756 Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
This commit is contained in:
parent
a246ab0a5e
commit
52136ab008
11 changed files with 231 additions and 142 deletions
|
@ -1,38 +1,66 @@
|
|||
package registry
|
||||
|
||||
// SearchResult describes a search result returned from a registry
|
||||
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"`
|
||||
// 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
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
// SearchResults lists a collection search results returned from a registry
|
||||
type SearchResults struct {
|
||||
Query string `json:"query"`
|
||||
NumResults int `json:"num_results"`
|
||||
Results []SearchResult `json:"results"`
|
||||
// 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"`
|
||||
}
|
||||
|
||||
// RepositoryData tracks the image list, list of endpoints, and list of tokens
|
||||
// for a repository
|
||||
type RepositoryData struct {
|
||||
ImgList map[string]*ImgData
|
||||
// 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 []string
|
||||
// Tokens is currently unused (remove it?)
|
||||
Tokens []string
|
||||
}
|
||||
|
||||
// ImgData is used to transfer image checksums to and from the registry
|
||||
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"`
|
||||
}
|
||||
|
||||
type RegistryInfo struct {
|
||||
Version string `json:"version"`
|
||||
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 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"`
|
||||
}
|
||||
|
||||
// APIVersion is an integral representation of an API version (presently
|
||||
// either 1 or 2)
|
||||
type APIVersion int
|
||||
|
||||
func (av APIVersion) String() string {
|
||||
|
@ -51,6 +79,8 @@ const (
|
|||
APIVersion2
|
||||
)
|
||||
|
||||
// IndexInfo contains information about a registry
|
||||
//
|
||||
// RepositoryInfo Examples:
|
||||
// {
|
||||
// "Index" : {
|
||||
|
@ -64,7 +94,7 @@ const (
|
|||
// "CanonicalName" : "docker.io/debian"
|
||||
// "Official" : true,
|
||||
// }
|
||||
|
||||
//
|
||||
// {
|
||||
// "Index" : {
|
||||
// "Name" : "127.0.0.1:5000",
|
||||
|
@ -78,16 +108,33 @@ const (
|
|||
// "Official" : false,
|
||||
// }
|
||||
type IndexInfo struct {
|
||||
Name string
|
||||
Mirrors []string
|
||||
Secure bool
|
||||
// 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
|
||||
Official bool
|
||||
}
|
||||
|
||||
// RepositoryInfo describes a repository
|
||||
type RepositoryInfo struct {
|
||||
Index *IndexInfo
|
||||
RemoteName string
|
||||
LocalName string
|
||||
// Index points to registry information
|
||||
Index *IndexInfo
|
||||
// RemoteName is the remote name of the repository, such as
|
||||
// "library/ubuntu-12.04-base"
|
||||
RemoteName string
|
||||
// LocalName is the local name of the repository, such as
|
||||
// "ubuntu-12.04-base"
|
||||
LocalName string
|
||||
// CanonicalName is the canonical name of the repository, such as
|
||||
// "docker.io/library/ubuntu-12.04-base"
|
||||
CanonicalName string
|
||||
Official bool
|
||||
// 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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue