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