registry.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. package registry // import "github.com/docker/docker/api/types/registry"
  2. import (
  3. "encoding/json"
  4. "net"
  5. v1 "github.com/opencontainers/image-spec/specs-go/v1"
  6. )
  7. // ServiceConfig stores daemon registry services configuration.
  8. type ServiceConfig struct {
  9. AllowNondistributableArtifactsCIDRs []*NetIPNet
  10. AllowNondistributableArtifactsHostnames []string
  11. InsecureRegistryCIDRs []*NetIPNet `json:"InsecureRegistryCIDRs"`
  12. IndexConfigs map[string]*IndexInfo `json:"IndexConfigs"`
  13. Mirrors []string
  14. }
  15. // NetIPNet is the net.IPNet type, which can be marshalled and
  16. // unmarshalled to JSON
  17. type NetIPNet net.IPNet
  18. // String returns the CIDR notation of ipnet
  19. func (ipnet *NetIPNet) String() string {
  20. return (*net.IPNet)(ipnet).String()
  21. }
  22. // MarshalJSON returns the JSON representation of the IPNet
  23. func (ipnet *NetIPNet) MarshalJSON() ([]byte, error) {
  24. return json.Marshal((*net.IPNet)(ipnet).String())
  25. }
  26. // UnmarshalJSON sets the IPNet from a byte array of JSON
  27. func (ipnet *NetIPNet) UnmarshalJSON(b []byte) (err error) {
  28. var ipnetStr string
  29. if err = json.Unmarshal(b, &ipnetStr); err == nil {
  30. var cidr *net.IPNet
  31. if _, cidr, err = net.ParseCIDR(ipnetStr); err == nil {
  32. *ipnet = NetIPNet(*cidr)
  33. }
  34. }
  35. return
  36. }
  37. // IndexInfo contains information about a registry
  38. //
  39. // RepositoryInfo Examples:
  40. // {
  41. // "Index" : {
  42. // "Name" : "docker.io",
  43. // "Mirrors" : ["https://registry-2.docker.io/v1/", "https://registry-3.docker.io/v1/"],
  44. // "Secure" : true,
  45. // "Official" : true,
  46. // },
  47. // "RemoteName" : "library/debian",
  48. // "LocalName" : "debian",
  49. // "CanonicalName" : "docker.io/debian"
  50. // "Official" : true,
  51. // }
  52. //
  53. // {
  54. // "Index" : {
  55. // "Name" : "127.0.0.1:5000",
  56. // "Mirrors" : [],
  57. // "Secure" : false,
  58. // "Official" : false,
  59. // },
  60. // "RemoteName" : "user/repo",
  61. // "LocalName" : "127.0.0.1:5000/user/repo",
  62. // "CanonicalName" : "127.0.0.1:5000/user/repo",
  63. // "Official" : false,
  64. // }
  65. type IndexInfo struct {
  66. // Name is the name of the registry, such as "docker.io"
  67. Name string
  68. // Mirrors is a list of mirrors, expressed as URIs
  69. Mirrors []string
  70. // Secure is set to false if the registry is part of the list of
  71. // insecure registries. Insecure registries accept HTTP and/or accept
  72. // HTTPS with certificates from unknown CAs.
  73. Secure bool
  74. // Official indicates whether this is an official registry
  75. Official bool
  76. }
  77. // SearchResult describes a search result returned from a registry
  78. type SearchResult struct {
  79. // StarCount indicates the number of stars this repository has
  80. StarCount int `json:"star_count"`
  81. // IsOfficial is true if the result is from an official repository.
  82. IsOfficial bool `json:"is_official"`
  83. // Name is the name of the repository
  84. Name string `json:"name"`
  85. // IsAutomated indicates whether the result is automated
  86. IsAutomated bool `json:"is_automated"`
  87. // Description is a textual description of the repository
  88. Description string `json:"description"`
  89. }
  90. // SearchResults lists a collection search results returned from a registry
  91. type SearchResults struct {
  92. // Query contains the query string that generated the search results
  93. Query string `json:"query"`
  94. // NumResults indicates the number of results the query returned
  95. NumResults int `json:"num_results"`
  96. // Results is a slice containing the actual results for the search
  97. Results []SearchResult `json:"results"`
  98. }
  99. // DistributionInspect describes the result obtained from contacting the
  100. // registry to retrieve image metadata
  101. type DistributionInspect struct {
  102. // Descriptor contains information about the manifest, including
  103. // the content addressable digest
  104. Descriptor v1.Descriptor
  105. // Platforms contains the list of platforms supported by the image,
  106. // obtained by parsing the manifest
  107. Platforms []v1.Platform
  108. }