github.com/moby/docker@v26.1.3+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  	ocispec "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  	//
    97  	// Deprecated: the "is_automated" field is deprecated and will always be "false".
    98  	IsAutomated bool `json:"is_automated"`
    99  	// Description is a textual description of the repository
   100  	Description string `json:"description"`
   101  }
   102  
   103  // SearchResults lists a collection search results returned from a registry
   104  type SearchResults struct {
   105  	// Query contains the query string that generated the search results
   106  	Query string `json:"query"`
   107  	// NumResults indicates the number of results the query returned
   108  	NumResults int `json:"num_results"`
   109  	// Results is a slice containing the actual results for the search
   110  	Results []SearchResult `json:"results"`
   111  }
   112  
   113  // DistributionInspect describes the result obtained from contacting the
   114  // registry to retrieve image metadata
   115  type DistributionInspect struct {
   116  	// Descriptor contains information about the manifest, including
   117  	// the content addressable digest
   118  	Descriptor ocispec.Descriptor
   119  	// Platforms contains the list of platforms supported by the image,
   120  	// obtained by parsing the manifest
   121  	Platforms []ocispec.Platform
   122  }