types.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package registry
  2. type SearchResult struct {
  3. StarCount int `json:"star_count"`
  4. IsOfficial bool `json:"is_official"`
  5. Name string `json:"name"`
  6. IsTrusted bool `json:"is_trusted"`
  7. Description string `json:"description"`
  8. }
  9. type SearchResults struct {
  10. Query string `json:"query"`
  11. NumResults int `json:"num_results"`
  12. Results []SearchResult `json:"results"`
  13. }
  14. type RepositoryData struct {
  15. ImgList map[string]*ImgData
  16. Endpoints []string
  17. Tokens []string
  18. }
  19. type ImgData struct {
  20. ID string `json:"id"`
  21. Checksum string `json:"checksum,omitempty"`
  22. ChecksumPayload string `json:"-"`
  23. Tag string `json:",omitempty"`
  24. }
  25. type RegistryInfo struct {
  26. Version string `json:"version"`
  27. Standalone bool `json:"standalone"`
  28. }
  29. type FSLayer struct {
  30. BlobSum string `json:"blobSum"`
  31. }
  32. type ManifestHistory struct {
  33. V1Compatibility string `json:"v1Compatibility"`
  34. }
  35. type ManifestData struct {
  36. Name string `json:"name"`
  37. Tag string `json:"tag"`
  38. Architecture string `json:"architecture"`
  39. FSLayers []*FSLayer `json:"fsLayers"`
  40. History []*ManifestHistory `json:"history"`
  41. SchemaVersion int `json:"schemaVersion"`
  42. }
  43. type APIVersion int
  44. func (av APIVersion) String() string {
  45. return apiVersions[av]
  46. }
  47. var DefaultAPIVersion APIVersion = APIVersion1
  48. var apiVersions = map[APIVersion]string{
  49. 1: "v1",
  50. 2: "v2",
  51. }
  52. const (
  53. APIVersion1 = iota + 1
  54. APIVersion2
  55. )
  56. // RepositoryInfo Examples:
  57. // {
  58. // "Index" : {
  59. // "Name" : "docker.io",
  60. // "Mirrors" : ["https://registry-2.docker.io/v1/", "https://registry-3.docker.io/v1/"],
  61. // "Secure" : true,
  62. // "Official" : true,
  63. // },
  64. // "RemoteName" : "library/debian",
  65. // "LocalName" : "debian",
  66. // "CanonicalName" : "docker.io/debian"
  67. // "Official" : true,
  68. // }
  69. // {
  70. // "Index" : {
  71. // "Name" : "127.0.0.1:5000",
  72. // "Mirrors" : [],
  73. // "Secure" : false,
  74. // "Official" : false,
  75. // },
  76. // "RemoteName" : "user/repo",
  77. // "LocalName" : "127.0.0.1:5000/user/repo",
  78. // "CanonicalName" : "127.0.0.1:5000/user/repo",
  79. // "Official" : false,
  80. // }
  81. type IndexInfo struct {
  82. Name string
  83. Mirrors []string
  84. Secure bool
  85. Official bool
  86. }
  87. type RepositoryInfo struct {
  88. Index *IndexInfo
  89. RemoteName string
  90. LocalName string
  91. CanonicalName string
  92. Official bool
  93. }