github.com/walkingsparrow/docker@v1.4.2-0.20151218153551-b708a2249bfa/api/types/registry/registry.go (about) 1 package registry 2 3 import ( 4 "encoding/json" 5 "net" 6 ) 7 8 // ServiceConfig stores daemon registry services configuration. 9 type ServiceConfig struct { 10 InsecureRegistryCIDRs []*NetIPNet `json:"InsecureRegistryCIDRs"` 11 IndexConfigs map[string]*IndexInfo `json:"IndexConfigs"` 12 Mirrors []string 13 } 14 15 // NetIPNet is the net.IPNet type, which can be marshalled and 16 // unmarshalled to JSON 17 type NetIPNet net.IPNet 18 19 // MarshalJSON returns the JSON representation of the IPNet 20 func (ipnet *NetIPNet) MarshalJSON() ([]byte, error) { 21 return json.Marshal((*net.IPNet)(ipnet).String()) 22 } 23 24 // UnmarshalJSON sets the IPNet from a byte array of JSON 25 func (ipnet *NetIPNet) UnmarshalJSON(b []byte) (err error) { 26 var ipnetStr string 27 if err = json.Unmarshal(b, &ipnetStr); err == nil { 28 var cidr *net.IPNet 29 if _, cidr, err = net.ParseCIDR(ipnetStr); err == nil { 30 *ipnet = NetIPNet(*cidr) 31 } 32 } 33 return 34 } 35 36 // IndexInfo contains information about a registry 37 // 38 // RepositoryInfo Examples: 39 // { 40 // "Index" : { 41 // "Name" : "docker.io", 42 // "Mirrors" : ["https://registry-2.docker.io/v1/", "https://registry-3.docker.io/v1/"], 43 // "Secure" : true, 44 // "Official" : true, 45 // }, 46 // "RemoteName" : "library/debian", 47 // "LocalName" : "debian", 48 // "CanonicalName" : "docker.io/debian" 49 // "Official" : true, 50 // } 51 // 52 // { 53 // "Index" : { 54 // "Name" : "127.0.0.1:5000", 55 // "Mirrors" : [], 56 // "Secure" : false, 57 // "Official" : false, 58 // }, 59 // "RemoteName" : "user/repo", 60 // "LocalName" : "127.0.0.1:5000/user/repo", 61 // "CanonicalName" : "127.0.0.1:5000/user/repo", 62 // "Official" : false, 63 // } 64 type IndexInfo struct { 65 // Name is the name of the registry, such as "docker.io" 66 Name string 67 // Mirrors is a list of mirrors, expressed as URIs 68 Mirrors []string 69 // Secure is set to false if the registry is part of the list of 70 // insecure registries. Insecure registries accept HTTP and/or accept 71 // HTTPS with certificates from unknown CAs. 72 Secure bool 73 // Official indicates whether this is an official registry 74 Official bool 75 } 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 indicates whether the result is an official repository or not 82 IsOfficial bool `json:"is_official"` 83 // Name is the name of the repository 84 Name string `json:"name"` 85 // IsOfficial indicates whether the result is trusted 86 IsTrusted bool `json:"is_trusted"` 87 // IsAutomated indicates whether the result is automated 88 IsAutomated bool `json:"is_automated"` 89 // Description is a textual description of the repository 90 Description string `json:"description"` 91 } 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 }