types.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package registry
  2. import (
  3. "github.com/docker/distribution/reference"
  4. registrytypes "github.com/docker/docker/api/types/registry"
  5. )
  6. // RepositoryData tracks the image list, list of endpoints for a repository
  7. type RepositoryData struct {
  8. // ImgList is a list of images in the repository
  9. ImgList map[string]*ImgData
  10. // Endpoints is a list of endpoints returned in X-Docker-Endpoints
  11. Endpoints []string
  12. }
  13. // ImgData is used to transfer image checksums to and from the registry
  14. type ImgData struct {
  15. // ID is an opaque string that identifies the image
  16. ID string `json:"id"`
  17. Checksum string `json:"checksum,omitempty"`
  18. ChecksumPayload string `json:"-"`
  19. Tag string `json:",omitempty"`
  20. }
  21. // PingResult contains the information returned when pinging a registry. It
  22. // indicates the registry's version and whether the registry claims to be a
  23. // standalone registry.
  24. type PingResult struct {
  25. // Version is the registry version supplied by the registry in an HTTP
  26. // header
  27. Version string `json:"version"`
  28. // Standalone is set to true if the registry indicates it is a
  29. // standalone registry in the X-Docker-Registry-Standalone
  30. // header
  31. Standalone bool `json:"standalone"`
  32. }
  33. // APIVersion is an integral representation of an API version (presently
  34. // either 1 or 2)
  35. type APIVersion int
  36. func (av APIVersion) String() string {
  37. return apiVersions[av]
  38. }
  39. // API Version identifiers.
  40. const (
  41. _ = iota
  42. APIVersion1 APIVersion = iota
  43. APIVersion2
  44. )
  45. var apiVersions = map[APIVersion]string{
  46. APIVersion1: "v1",
  47. APIVersion2: "v2",
  48. }
  49. // RepositoryInfo describes a repository
  50. type RepositoryInfo struct {
  51. Name reference.Named
  52. // Index points to registry information
  53. Index *registrytypes.IndexInfo
  54. // Official indicates whether the repository is considered official.
  55. // If the registry is official, and the normalized name does not
  56. // contain a '/' (e.g. "foo"), then it is considered an official repo.
  57. Official bool
  58. // Class represents the class of the repository, such as "plugin"
  59. // or "image".
  60. Class string
  61. }