github.com/tompao/docker@v1.9.1/registry/types.go (about)

     1  package registry
     2  
     3  // SearchResult describes a search result returned from a registry
     4  type SearchResult struct {
     5  	// StarCount indicates the number of stars this repository has
     6  	StarCount int `json:"star_count"`
     7  	// IsOfficial indicates whether the result is an official repository or not
     8  	IsOfficial bool `json:"is_official"`
     9  	// Name is the name of the repository
    10  	Name string `json:"name"`
    11  	// IsOfficial indicates whether the result is trusted
    12  	IsTrusted bool `json:"is_trusted"`
    13  	// IsAutomated indicates whether the result is automated
    14  	IsAutomated bool `json:"is_automated"`
    15  	// Description is a textual description of the repository
    16  	Description string `json:"description"`
    17  }
    18  
    19  // SearchResults lists a collection search results returned from a registry
    20  type SearchResults struct {
    21  	// Query contains the query string that generated the search results
    22  	Query string `json:"query"`
    23  	// NumResults indicates the number of results the query returned
    24  	NumResults int `json:"num_results"`
    25  	// Results is a slice containing the acutal results for the search
    26  	Results []SearchResult `json:"results"`
    27  }
    28  
    29  // RepositoryData tracks the image list, list of endpoints, and list of tokens
    30  // for a repository
    31  type RepositoryData struct {
    32  	// ImgList is a list of images in the repository
    33  	ImgList map[string]*ImgData
    34  	// Endpoints is a list of endpoints returned in X-Docker-Endpoints
    35  	Endpoints []string
    36  	// Tokens is currently unused (remove it?)
    37  	Tokens []string
    38  }
    39  
    40  // ImgData is used to transfer image checksums to and from the registry
    41  type ImgData struct {
    42  	// ID is an opaque string that identifies the image
    43  	ID              string `json:"id"`
    44  	Checksum        string `json:"checksum,omitempty"`
    45  	ChecksumPayload string `json:"-"`
    46  	Tag             string `json:",omitempty"`
    47  }
    48  
    49  // PingResult contains the information returned when pinging a registry. It
    50  // indicates the registry's version and whether the registry claims to be a
    51  // standalone registry.
    52  type PingResult struct {
    53  	// Version is the registry version supplied by the registry in a HTTP
    54  	// header
    55  	Version string `json:"version"`
    56  	// Standalone is set to true if the registry indicates it is a
    57  	// standalone registry in the X-Docker-Registry-Standalone
    58  	// header
    59  	Standalone bool `json:"standalone"`
    60  }
    61  
    62  // APIVersion is an integral representation of an API version (presently
    63  // either 1 or 2)
    64  type APIVersion int
    65  
    66  func (av APIVersion) String() string {
    67  	return apiVersions[av]
    68  }
    69  
    70  var apiVersions = map[APIVersion]string{
    71  	1: "v1",
    72  	2: "v2",
    73  }
    74  
    75  // API Version identifiers.
    76  const (
    77  	APIVersionUnknown = iota
    78  	APIVersion1
    79  	APIVersion2
    80  )
    81  
    82  // IndexInfo contains information about a registry
    83  //
    84  // RepositoryInfo Examples:
    85  // {
    86  //   "Index" : {
    87  //     "Name" : "docker.io",
    88  //     "Mirrors" : ["https://registry-2.docker.io/v1/", "https://registry-3.docker.io/v1/"],
    89  //     "Secure" : true,
    90  //     "Official" : true,
    91  //   },
    92  //   "RemoteName" : "library/debian",
    93  //   "LocalName" : "debian",
    94  //   "CanonicalName" : "docker.io/debian"
    95  //   "Official" : true,
    96  // }
    97  //
    98  // {
    99  //   "Index" : {
   100  //     "Name" : "127.0.0.1:5000",
   101  //     "Mirrors" : [],
   102  //     "Secure" : false,
   103  //     "Official" : false,
   104  //   },
   105  //   "RemoteName" : "user/repo",
   106  //   "LocalName" : "127.0.0.1:5000/user/repo",
   107  //   "CanonicalName" : "127.0.0.1:5000/user/repo",
   108  //   "Official" : false,
   109  // }
   110  type IndexInfo struct {
   111  	// Name is the name of the registry, such as "docker.io"
   112  	Name string
   113  	// Mirrors is a list of mirrors, expressed as URIs
   114  	Mirrors []string
   115  	// Secure is set to false if the registry is part of the list of
   116  	// insecure registries. Insecure registries accept HTTP and/or accept
   117  	// HTTPS with certificates from unknown CAs.
   118  	Secure bool
   119  	// Official indicates whether this is an official registry
   120  	Official bool
   121  }
   122  
   123  // RepositoryInfo describes a repository
   124  type RepositoryInfo struct {
   125  	// Index points to registry information
   126  	Index *IndexInfo
   127  	// RemoteName is the remote name of the repository, such as
   128  	// "library/ubuntu-12.04-base"
   129  	RemoteName string
   130  	// LocalName is the local name of the repository, such as
   131  	// "ubuntu-12.04-base"
   132  	LocalName string
   133  	// CanonicalName is the canonical name of the repository, such as
   134  	// "docker.io/library/ubuntu-12.04-base"
   135  	CanonicalName string
   136  	// Official indicates whether the repository is considered official.
   137  	// If the registry is official, and the normalized name does not
   138  	// contain a '/' (e.g. "foo"), then it is considered an official repo.
   139  	Official bool
   140  }