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