github.com/getong/docker@v1.13.1/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  // String returns the CIDR notation of ipnet
    20  func (ipnet *NetIPNet) String() string {
    21  	return (*net.IPNet)(ipnet).String()
    22  }
    23  
    24  // MarshalJSON returns the JSON representation of the IPNet
    25  func (ipnet *NetIPNet) MarshalJSON() ([]byte, error) {
    26  	return json.Marshal((*net.IPNet)(ipnet).String())
    27  }
    28  
    29  // UnmarshalJSON sets the IPNet from a byte array of JSON
    30  func (ipnet *NetIPNet) UnmarshalJSON(b []byte) (err error) {
    31  	var ipnetStr string
    32  	if err = json.Unmarshal(b, &ipnetStr); err == nil {
    33  		var cidr *net.IPNet
    34  		if _, cidr, err = net.ParseCIDR(ipnetStr); err == nil {
    35  			*ipnet = NetIPNet(*cidr)
    36  		}
    37  	}
    38  	return
    39  }
    40  
    41  // IndexInfo contains information about a registry
    42  //
    43  // RepositoryInfo Examples:
    44  // {
    45  //   "Index" : {
    46  //     "Name" : "docker.io",
    47  //     "Mirrors" : ["https://registry-2.docker.io/v1/", "https://registry-3.docker.io/v1/"],
    48  //     "Secure" : true,
    49  //     "Official" : true,
    50  //   },
    51  //   "RemoteName" : "library/debian",
    52  //   "LocalName" : "debian",
    53  //   "CanonicalName" : "docker.io/debian"
    54  //   "Official" : true,
    55  // }
    56  //
    57  // {
    58  //   "Index" : {
    59  //     "Name" : "127.0.0.1:5000",
    60  //     "Mirrors" : [],
    61  //     "Secure" : false,
    62  //     "Official" : false,
    63  //   },
    64  //   "RemoteName" : "user/repo",
    65  //   "LocalName" : "127.0.0.1:5000/user/repo",
    66  //   "CanonicalName" : "127.0.0.1:5000/user/repo",
    67  //   "Official" : false,
    68  // }
    69  type IndexInfo struct {
    70  	// Name is the name of the registry, such as "docker.io"
    71  	Name string
    72  	// Mirrors is a list of mirrors, expressed as URIs
    73  	Mirrors []string
    74  	// Secure is set to false if the registry is part of the list of
    75  	// insecure registries. Insecure registries accept HTTP and/or accept
    76  	// HTTPS with certificates from unknown CAs.
    77  	Secure bool
    78  	// Official indicates whether this is an official registry
    79  	Official bool
    80  }
    81  
    82  // SearchResult describes a search result returned from a registry
    83  type SearchResult struct {
    84  	// StarCount indicates the number of stars this repository has
    85  	StarCount int `json:"star_count"`
    86  	// IsOfficial is true if the result is from an official repository.
    87  	IsOfficial bool `json:"is_official"`
    88  	// Name is the name of the repository
    89  	Name string `json:"name"`
    90  	// IsAutomated indicates whether the result is automated
    91  	IsAutomated bool `json:"is_automated"`
    92  	// Description is a textual description of the repository
    93  	Description string `json:"description"`
    94  }
    95  
    96  // SearchResults lists a collection search results returned from a registry
    97  type SearchResults struct {
    98  	// Query contains the query string that generated the search results
    99  	Query string `json:"query"`
   100  	// NumResults indicates the number of results the query returned
   101  	NumResults int `json:"num_results"`
   102  	// Results is a slice containing the actual results for the search
   103  	Results []SearchResult `json:"results"`
   104  }