registry.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. package registry // import "github.com/docker/docker/api/types/registry"
  2. import (
  3. "encoding/json"
  4. "net"
  5. ocispec "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. // {
  42. // "Index" : {
  43. // "Name" : "docker.io",
  44. // "Mirrors" : ["https://registry-2.docker.io/v1/", "https://registry-3.docker.io/v1/"],
  45. // "Secure" : true,
  46. // "Official" : true,
  47. // },
  48. // "RemoteName" : "library/debian",
  49. // "LocalName" : "debian",
  50. // "CanonicalName" : "docker.io/debian"
  51. // "Official" : true,
  52. // }
  53. //
  54. // {
  55. // "Index" : {
  56. // "Name" : "127.0.0.1:5000",
  57. // "Mirrors" : [],
  58. // "Secure" : false,
  59. // "Official" : false,
  60. // },
  61. // "RemoteName" : "user/repo",
  62. // "LocalName" : "127.0.0.1:5000/user/repo",
  63. // "CanonicalName" : "127.0.0.1:5000/user/repo",
  64. // "Official" : false,
  65. // }
  66. type IndexInfo struct {
  67. // Name is the name of the registry, such as "docker.io"
  68. Name string
  69. // Mirrors is a list of mirrors, expressed as URIs
  70. Mirrors []string
  71. // Secure is set to false if the registry is part of the list of
  72. // insecure registries. Insecure registries accept HTTP and/or accept
  73. // HTTPS with certificates from unknown CAs.
  74. Secure bool
  75. // Official indicates whether this is an official registry
  76. Official bool
  77. }
  78. // SearchResult describes a search result returned from a registry
  79. type SearchResult struct {
  80. // StarCount indicates the number of stars this repository has
  81. StarCount int `json:"star_count"`
  82. // IsOfficial is true if the result is from an official repository.
  83. IsOfficial bool `json:"is_official"`
  84. // Name is the name of the repository
  85. Name string `json:"name"`
  86. // IsAutomated indicates whether the result is automated.
  87. //
  88. // Deprecated: the "is_automated" field is deprecated and will always be "false" in the future.
  89. IsAutomated bool `json:"is_automated"`
  90. // Description is a textual description of the repository
  91. Description string `json:"description"`
  92. }
  93. // SearchResults lists a collection search results returned from a registry
  94. type SearchResults struct {
  95. // Query contains the query string that generated the search results
  96. Query string `json:"query"`
  97. // NumResults indicates the number of results the query returned
  98. NumResults int `json:"num_results"`
  99. // Results is a slice containing the actual results for the search
  100. Results []SearchResult `json:"results"`
  101. }
  102. // DistributionInspect describes the result obtained from contacting the
  103. // registry to retrieve image metadata
  104. type DistributionInspect struct {
  105. // Descriptor contains information about the manifest, including
  106. // the content addressable digest
  107. Descriptor ocispec.Descriptor
  108. // Platforms contains the list of platforms supported by the image,
  109. // obtained by parsing the manifest
  110. Platforms []ocispec.Platform
  111. }