Move IndexInfo and ServiceConfig types to api/types/registry/registry.go

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
Daniel Nephin 2015-12-11 18:14:52 -08:00 committed by Daniel Nephin
parent 6fc54d049b
commit aead731d54
9 changed files with 87 additions and 141 deletions

View file

@ -8,7 +8,8 @@ import (
"strings"
"github.com/Sirupsen/logrus"
"github.com/docker/docker/cliconfig"
"github.com/docker/docker/api/types"
registrytypes "github.com/docker/docker/api/types/registry"
)
// Login tries to register/login to the registry server.
@ -221,8 +222,8 @@ func tryV2TokenAuthLogin(authConfig *types.AuthConfig, params map[string]string,
}
// ResolveAuthConfig matches an auth configuration to a server address or a URL
func ResolveAuthConfig(authConfigs map[string]types.AuthConfig, index *IndexInfo) types.AuthConfig {
configKey := index.GetAuthConfigKey()
func ResolveAuthConfig(authConfigs map[string]types.AuthConfig, index *registrytypes.IndexInfo) types.AuthConfig {
configKey := GetAuthConfigKey(index)
// First try the happy case
if c, found := authConfigs[configKey]; found || index.Official {
return c

View file

@ -3,6 +3,8 @@ package registry
import (
"testing"
"github.com/docker/docker/api/types"
registrytypes "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/cliconfig"
)
@ -26,8 +28,8 @@ func TestEncodeAuth(t *testing.T) {
}
}
func buildAuthConfigs() map[string]cliconfig.AuthConfig {
authConfigs := map[string]cliconfig.AuthConfig{}
func buildAuthConfigs() map[string]types.AuthConfig {
authConfigs := map[string]types.AuthConfig{}
for _, registry := range []string{"testIndex", IndexServer} {
authConfigs[registry] = types.AuthConfig{
@ -61,10 +63,10 @@ func TestResolveAuthConfigIndexServer(t *testing.T) {
authConfigs := buildAuthConfigs()
indexConfig := authConfigs[IndexServer]
officialIndex := &IndexInfo{
officialIndex := &registrytypes.IndexInfo{
Official: true,
}
privateIndex := &IndexInfo{
privateIndex := &registrytypes.IndexInfo{
Official: false,
}
@ -127,7 +129,7 @@ func TestResolveAuthConfigFullURL(t *testing.T) {
if !ok || configured.Email == "" {
t.Fail()
}
index := &IndexInfo{
index := &registrytypes.IndexInfo{
Name: configKey,
}
for _, registry := range registries {

View file

@ -1,7 +1,6 @@
package registry
import (
"encoding/json"
"errors"
"fmt"
"net"
@ -9,6 +8,7 @@ import (
"strings"
"github.com/docker/distribution/reference"
registrytypes "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/image/v1"
"github.com/docker/docker/opts"
flag "github.com/docker/docker/pkg/mflag"
@ -60,32 +60,8 @@ func (options *Options) InstallFlags(cmd *flag.FlagSet, usageFn func(string) str
cmd.BoolVar(&V2Only, []string{"-disable-legacy-registry"}, false, "Do not contact legacy registries")
}
type netIPNet net.IPNet
func (ipnet *netIPNet) MarshalJSON() ([]byte, error) {
return json.Marshal((*net.IPNet)(ipnet).String())
}
func (ipnet *netIPNet) UnmarshalJSON(b []byte) (err error) {
var ipnetStr string
if err = json.Unmarshal(b, &ipnetStr); err == nil {
var cidr *net.IPNet
if _, cidr, err = net.ParseCIDR(ipnetStr); err == nil {
*ipnet = netIPNet(*cidr)
}
}
return
}
// ServiceConfig stores daemon registry services configuration.
type ServiceConfig struct {
InsecureRegistryCIDRs []*netIPNet `json:"InsecureRegistryCIDRs"`
IndexConfigs map[string]*IndexInfo `json:"IndexConfigs"`
Mirrors []string
}
// NewServiceConfig returns a new instance of ServiceConfig
func NewServiceConfig(options *Options) *ServiceConfig {
func NewServiceConfig(options *Options) *registrytypes.ServiceConfig {
if options == nil {
options = &Options{
Mirrors: opts.NewListOpts(nil),
@ -100,9 +76,9 @@ func NewServiceConfig(options *Options) *ServiceConfig {
// daemon flags on boot2docker?
options.InsecureRegistries.Set("127.0.0.0/8")
config := &ServiceConfig{
InsecureRegistryCIDRs: make([]*netIPNet, 0),
IndexConfigs: make(map[string]*IndexInfo, 0),
config := &registrytypes.ServiceConfig{
InsecureRegistryCIDRs: make([]*registrytypes.NetIPNet, 0),
IndexConfigs: make(map[string]*registrytypes.IndexInfo, 0),
// Hack: Bypass setting the mirrors to IndexConfigs since they are going away
// and Mirrors are only for the official registry anyways.
Mirrors: options.Mirrors.GetAll(),
@ -113,10 +89,10 @@ func NewServiceConfig(options *Options) *ServiceConfig {
_, ipnet, err := net.ParseCIDR(r)
if err == nil {
// Valid CIDR.
config.InsecureRegistryCIDRs = append(config.InsecureRegistryCIDRs, (*netIPNet)(ipnet))
config.InsecureRegistryCIDRs = append(config.InsecureRegistryCIDRs, (*registrytypes.NetIPNet)(ipnet))
} else {
// Assume `host:port` if not CIDR.
config.IndexConfigs[r] = &IndexInfo{
config.IndexConfigs[r] = &registrytypes.IndexInfo{
Name: r,
Mirrors: make([]string, 0),
Secure: false,
@ -126,7 +102,7 @@ func NewServiceConfig(options *Options) *ServiceConfig {
}
// Configure public registry.
config.IndexConfigs[IndexName] = &IndexInfo{
config.IndexConfigs[IndexName] = &registrytypes.IndexInfo{
Name: IndexName,
Mirrors: config.Mirrors,
Secure: true,
@ -147,9 +123,9 @@ func NewServiceConfig(options *Options) *ServiceConfig {
// or an IP address. If it is a domain name, then it will be resolved in order to check if the IP is contained
// in a subnet. If the resolving is not successful, isSecureIndex will only try to match hostname to any element
// of insecureRegistries.
func (config *ServiceConfig) isSecureIndex(indexName string) bool {
func isSecureIndex(config *registrytypes.ServiceConfig, indexName string) bool {
// Check for configured index, first. This is needed in case isSecureIndex
// is called from anything besides NewIndexInfo, in order to honor per-index configurations.
// is called from anything besides newIndexInfo, in order to honor per-index configurations.
if index, ok := config.IndexConfigs[indexName]; ok {
return index.Secure
}
@ -258,8 +234,8 @@ func loadRepositoryName(reposName reference.Named) (string, reference.Named, err
return indexName, remoteName, nil
}
// NewIndexInfo returns IndexInfo configuration from indexName
func (config *ServiceConfig) NewIndexInfo(indexName string) (*IndexInfo, error) {
// newIndexInfo returns IndexInfo configuration from indexName
func newIndexInfo(config *registrytypes.ServiceConfig, indexName string) (*registrytypes.IndexInfo, error) {
var err error
indexName, err = ValidateIndexName(indexName)
if err != nil {
@ -272,18 +248,18 @@ func (config *ServiceConfig) NewIndexInfo(indexName string) (*IndexInfo, error)
}
// Construct a non-configured index info.
index := &IndexInfo{
index := &registrytypes.IndexInfo{
Name: indexName,
Mirrors: make([]string, 0),
Official: false,
}
index.Secure = config.isSecureIndex(indexName)
index.Secure = isSecureIndex(config, indexName)
return index, nil
}
// GetAuthConfigKey special-cases using the full index address of the official
// index as the AuthConfig key, and uses the (host)name[:port] for private indexes.
func (index *IndexInfo) GetAuthConfigKey() string {
func GetAuthConfigKey(index *registrytypes.IndexInfo) string {
if index.Official {
return IndexServer
}
@ -306,8 +282,8 @@ func splitReposName(reposName reference.Named) (indexName string, remoteName ref
return
}
// NewRepositoryInfo validates and breaks down a repository name into a RepositoryInfo
func (config *ServiceConfig) NewRepositoryInfo(reposName reference.Named) (*RepositoryInfo, error) {
// newRepositoryInfo validates and breaks down a repository name into a RepositoryInfo
func newRepositoryInfo(config *registrytypes.ServiceConfig, reposName reference.Named) (*RepositoryInfo, error) {
if err := validateNoSchema(reposName.Name()); err != nil {
return nil, err
}
@ -323,7 +299,7 @@ func (config *ServiceConfig) NewRepositoryInfo(reposName reference.Named) (*Repo
return nil, err
}
repoInfo.Index, err = config.NewIndexInfo(indexName)
repoInfo.Index, err = newIndexInfo(config, indexName)
if err != nil {
return nil, err
}
@ -364,14 +340,14 @@ func (config *ServiceConfig) NewRepositoryInfo(reposName reference.Named) (*Repo
// ParseRepositoryInfo performs the breakdown of a repository name into a RepositoryInfo, but
// lacks registry configuration.
func ParseRepositoryInfo(reposName reference.Named) (*RepositoryInfo, error) {
return emptyServiceConfig.NewRepositoryInfo(reposName)
return newRepositoryInfo(emptyServiceConfig, reposName)
}
// ParseSearchIndexInfo will use repository name to get back an indexInfo.
func ParseSearchIndexInfo(reposName string) (*IndexInfo, error) {
func ParseSearchIndexInfo(reposName string) (*registrytypes.IndexInfo, error) {
indexName, _ := splitReposSearchTerm(reposName)
indexInfo, err := emptyServiceConfig.NewIndexInfo(indexName)
indexInfo, err := newIndexInfo(emptyServiceConfig, indexName)
if err != nil {
return nil, err
}

View file

@ -13,6 +13,7 @@ import (
"github.com/Sirupsen/logrus"
"github.com/docker/distribution/registry/api/v2"
"github.com/docker/distribution/registry/client/transport"
registrytypes "github.com/docker/docker/api/types/registry"
)
// for mocking in unit tests
@ -44,12 +45,12 @@ func scanForAPIVersion(address string) (string, APIVersion) {
// NewEndpoint parses the given address to return a registry endpoint. v can be used to
// specify a specific endpoint version
func NewEndpoint(index *IndexInfo, metaHeaders http.Header, v APIVersion) (*Endpoint, error) {
func NewEndpoint(index *registrytypes.IndexInfo, metaHeaders http.Header, v APIVersion) (*Endpoint, error) {
tlsConfig, err := newTLSConfig(index.Name, index.Secure)
if err != nil {
return nil, err
}
endpoint, err := newEndpoint(index.GetAuthConfigKey(), tlsConfig, metaHeaders)
endpoint, err := newEndpoint(GetAuthConfigKey(index), tlsConfig, metaHeaders)
if err != nil {
return nil, err
}

View file

@ -16,6 +16,7 @@ import (
"time"
"github.com/docker/distribution/reference"
registrytypes "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/opts"
"github.com/gorilla/mux"
@ -150,22 +151,22 @@ func makeHTTPSURL(req string) string {
return testHTTPSServer.URL + req
}
func makeIndex(req string) *IndexInfo {
index := &IndexInfo{
func makeIndex(req string) *registrytypes.IndexInfo {
index := &registrytypes.IndexInfo{
Name: makeURL(req),
}
return index
}
func makeHTTPSIndex(req string) *IndexInfo {
index := &IndexInfo{
func makeHTTPSIndex(req string) *registrytypes.IndexInfo {
index := &registrytypes.IndexInfo{
Name: makeHTTPSURL(req),
}
return index
}
func makePublicIndex() *IndexInfo {
index := &IndexInfo{
func makePublicIndex() *registrytypes.IndexInfo {
index := &registrytypes.IndexInfo{
Name: IndexServer,
Secure: true,
Official: true,
@ -173,7 +174,7 @@ func makePublicIndex() *IndexInfo {
return index
}
func makeServiceConfig(mirrors []string, insecureRegistries []string) *ServiceConfig {
func makeServiceConfig(mirrors []string, insecureRegistries []string) *registrytypes.ServiceConfig {
options := &Options{
Mirrors: opts.NewListOpts(nil),
InsecureRegistries: opts.NewListOpts(nil),

View file

@ -10,6 +10,8 @@ import (
"github.com/docker/distribution/reference"
"github.com/docker/distribution/registry/client/transport"
"github.com/docker/docker/api/types"
registrytypes "github.com/docker/docker/api/types/registry"
)
var (
@ -49,7 +51,7 @@ func spawnTestRegistrySession(t *testing.T) *Session {
}
func TestPingRegistryEndpoint(t *testing.T) {
testPing := func(index *IndexInfo, expectedStandalone bool, assertMessage string) {
testPing := func(index *registrytypes.IndexInfo, expectedStandalone bool, assertMessage string) {
ep, err := NewEndpoint(index, nil, APIVersionUnknown)
if err != nil {
t.Fatal(err)
@ -69,7 +71,7 @@ func TestPingRegistryEndpoint(t *testing.T) {
func TestEndpoint(t *testing.T) {
// Simple wrapper to fail test if err != nil
expandEndpoint := func(index *IndexInfo) *Endpoint {
expandEndpoint := func(index *registrytypes.IndexInfo) *Endpoint {
endpoint, err := NewEndpoint(index, nil, APIVersionUnknown)
if err != nil {
t.Fatal(err)
@ -77,7 +79,7 @@ func TestEndpoint(t *testing.T) {
return endpoint
}
assertInsecureIndex := func(index *IndexInfo) {
assertInsecureIndex := func(index *registrytypes.IndexInfo) {
index.Secure = true
_, err := NewEndpoint(index, nil, APIVersionUnknown)
assertNotEqual(t, err, nil, index.Name+": Expected error for insecure index")
@ -85,7 +87,7 @@ func TestEndpoint(t *testing.T) {
index.Secure = false
}
assertSecureIndex := func(index *IndexInfo) {
assertSecureIndex := func(index *registrytypes.IndexInfo) {
index.Secure = true
_, err := NewEndpoint(index, nil, APIVersionUnknown)
assertNotEqual(t, err, nil, index.Name+": Expected cert error for secure index")
@ -93,7 +95,7 @@ func TestEndpoint(t *testing.T) {
index.Secure = false
}
index := &IndexInfo{}
index := &registrytypes.IndexInfo{}
index.Name = makeURL("/v1/")
endpoint := expandEndpoint(index)
assertEqual(t, endpoint.String(), index.Name, "Expected endpoint to be "+index.Name)
@ -363,7 +365,7 @@ func TestParseRepositoryInfo(t *testing.T) {
expectedRepoInfos := map[string]RepositoryInfo{
"fooo/bar": {
Index: &IndexInfo{
Index: &registrytypes.IndexInfo{
Name: IndexName,
Official: true,
},
@ -373,7 +375,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"library/ubuntu": {
Index: &IndexInfo{
Index: &registrytypes.IndexInfo{
Name: IndexName,
Official: true,
},
@ -383,7 +385,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: true,
},
"nonlibrary/ubuntu": {
Index: &IndexInfo{
Index: &registrytypes.IndexInfo{
Name: IndexName,
Official: true,
},
@ -393,7 +395,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"ubuntu": {
Index: &IndexInfo{
Index: &registrytypes.IndexInfo{
Name: IndexName,
Official: true,
},
@ -403,7 +405,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: true,
},
"other/library": {
Index: &IndexInfo{
Index: &registrytypes.IndexInfo{
Name: IndexName,
Official: true,
},
@ -413,7 +415,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"127.0.0.1:8000/private/moonbase": {
Index: &IndexInfo{
Index: &registrytypes.IndexInfo{
Name: "127.0.0.1:8000",
Official: false,
},
@ -423,7 +425,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"127.0.0.1:8000/privatebase": {
Index: &IndexInfo{
Index: &registrytypes.IndexInfo{
Name: "127.0.0.1:8000",
Official: false,
},
@ -433,7 +435,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"localhost:8000/private/moonbase": {
Index: &IndexInfo{
Index: &registrytypes.IndexInfo{
Name: "localhost:8000",
Official: false,
},
@ -443,7 +445,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"localhost:8000/privatebase": {
Index: &IndexInfo{
Index: &registrytypes.IndexInfo{
Name: "localhost:8000",
Official: false,
},
@ -453,7 +455,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"example.com/private/moonbase": {
Index: &IndexInfo{
Index: &registrytypes.IndexInfo{
Name: "example.com",
Official: false,
},
@ -463,7 +465,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"example.com/privatebase": {
Index: &IndexInfo{
Index: &registrytypes.IndexInfo{
Name: "example.com",
Official: false,
},
@ -473,7 +475,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"example.com:8000/private/moonbase": {
Index: &IndexInfo{
Index: &registrytypes.IndexInfo{
Name: "example.com:8000",
Official: false,
},
@ -483,7 +485,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"example.com:8000/privatebase": {
Index: &IndexInfo{
Index: &registrytypes.IndexInfo{
Name: "example.com:8000",
Official: false,
},
@ -493,7 +495,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"localhost/private/moonbase": {
Index: &IndexInfo{
Index: &registrytypes.IndexInfo{
Name: "localhost",
Official: false,
},
@ -503,7 +505,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"localhost/privatebase": {
Index: &IndexInfo{
Index: &registrytypes.IndexInfo{
Name: "localhost",
Official: false,
},
@ -513,7 +515,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
IndexName + "/public/moonbase": {
Index: &IndexInfo{
Index: &registrytypes.IndexInfo{
Name: IndexName,
Official: true,
},
@ -523,7 +525,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"index." + IndexName + "/public/moonbase": {
Index: &IndexInfo{
Index: &registrytypes.IndexInfo{
Name: IndexName,
Official: true,
},
@ -533,7 +535,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"ubuntu-12.04-base": {
Index: &IndexInfo{
Index: &registrytypes.IndexInfo{
Name: IndexName,
Official: true,
},
@ -543,7 +545,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: true,
},
IndexName + "/ubuntu-12.04-base": {
Index: &IndexInfo{
Index: &registrytypes.IndexInfo{
Name: IndexName,
Official: true,
},
@ -553,7 +555,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: true,
},
"index." + IndexName + "/ubuntu-12.04-base": {
Index: &IndexInfo{
Index: &registrytypes.IndexInfo{
Name: IndexName,
Official: true,
},
@ -585,9 +587,9 @@ func TestParseRepositoryInfo(t *testing.T) {
}
func TestNewIndexInfo(t *testing.T) {
testIndexInfo := func(config *ServiceConfig, expectedIndexInfos map[string]*IndexInfo) {
testIndexInfo := func(config *registrytypes.ServiceConfig, expectedIndexInfos map[string]*registrytypes.IndexInfo) {
for indexName, expectedIndexInfo := range expectedIndexInfos {
index, err := config.NewIndexInfo(indexName)
index, err := newIndexInfo(config, indexName)
if err != nil {
t.Fatal(err)
} else {
@ -601,7 +603,7 @@ func TestNewIndexInfo(t *testing.T) {
config := NewServiceConfig(nil)
noMirrors := []string{}
expectedIndexInfos := map[string]*IndexInfo{
expectedIndexInfos := map[string]*registrytypes.IndexInfo{
IndexName: {
Name: IndexName,
Official: true,
@ -632,7 +634,7 @@ func TestNewIndexInfo(t *testing.T) {
publicMirrors := []string{"http://mirror1.local", "http://mirror2.local"}
config = makeServiceConfig(publicMirrors, []string{"example.com"})
expectedIndexInfos = map[string]*IndexInfo{
expectedIndexInfos = map[string]*registrytypes.IndexInfo{
IndexName: {
Name: IndexName,
Official: true,
@ -679,7 +681,7 @@ func TestNewIndexInfo(t *testing.T) {
testIndexInfo(config, expectedIndexInfos)
config = makeServiceConfig(nil, []string{"42.42.0.0/16"})
expectedIndexInfos = map[string]*IndexInfo{
expectedIndexInfos = map[string]*registrytypes.IndexInfo{
"example.com": {
Name: "example.com",
Official: false,
@ -981,7 +983,7 @@ func TestIsSecureIndex(t *testing.T) {
}
for _, tt := range tests {
config := makeServiceConfig(nil, tt.insecureRegistries)
if sec := config.isSecureIndex(tt.addr); sec != tt.expected {
if sec := isSecureIndex(config, tt.addr); sec != tt.expected {
t.Errorf("isSecureIndex failed for %q %v, expected %v got %v", tt.addr, tt.insecureRegistries, tt.expected, sec)
}
}

View file

@ -8,12 +8,14 @@ import (
"github.com/docker/distribution/reference"
"github.com/docker/distribution/registry/client/auth"
"github.com/docker/docker/api/types"
registrytypes "github.com/docker/docker/api/types/registry"
)
// Service is a registry service. It tracks configuration data such as a list
// of mirrors.
type Service struct {
Config *ServiceConfig
Config *registrytypes.ServiceConfig
}
// NewService returns a new instance of Service ready to be
@ -78,7 +80,7 @@ func (s *Service) Search(term string, authConfig *types.AuthConfig, headers map[
indexName, remoteName := splitReposSearchTerm(term)
index, err := s.Config.NewIndexInfo(indexName)
index, err := newIndexInfo(s.Config, indexName)
if err != nil {
return nil, err
}
@ -109,12 +111,12 @@ func (s *Service) Search(term string, authConfig *types.AuthConfig, headers map[
// ResolveRepository splits a repository name into its components
// and configuration of the associated registry.
func (s *Service) ResolveRepository(name reference.Named) (*RepositoryInfo, error) {
return s.Config.NewRepositoryInfo(name)
return newRepositoryInfo(s.Config, name)
}
// ResolveIndex takes indexName and returns index info
func (s *Service) ResolveIndex(name string) (*IndexInfo, error) {
return s.Config.NewIndexInfo(name)
func (s *Service) ResolveIndex(name string) (*registrytypes.IndexInfo, error) {
return newIndexInfo(s.Config, name)
}
// APIEndpoint represents a remote API endpoint
@ -136,7 +138,7 @@ func (e APIEndpoint) ToV1Endpoint(metaHeaders http.Header) (*Endpoint, error) {
// TLSConfig constructs a client TLS configuration based on server defaults
func (s *Service) TLSConfig(hostname string) (*tls.Config, error) {
return newTLSConfig(hostname, s.Config.isSecureIndex(hostname))
return newTLSConfig(hostname, isSecureIndex(s.Config, hostname))
}
func (s *Service) tlsConfigForMirror(mirror string) (*tls.Config, error) {

View file

@ -20,6 +20,7 @@ import (
"github.com/Sirupsen/logrus"
"github.com/docker/distribution/reference"
"github.com/docker/docker/api/types"
"github.com/docker/docker/pkg/httputils"
"github.com/docker/docker/pkg/ioutils"
"github.com/docker/docker/pkg/stringid"

View file

@ -2,6 +2,7 @@ package registry
import (
"github.com/docker/distribution/reference"
registrytypes "github.com/docker/docker/api/types/registry"
)
// SearchResult describes a search result returned from a registry
@ -83,51 +84,10 @@ const (
APIVersion2
)
// IndexInfo contains information about a registry
//
// RepositoryInfo Examples:
// {
// "Index" : {
// "Name" : "docker.io",
// "Mirrors" : ["https://registry-2.docker.io/v1/", "https://registry-3.docker.io/v1/"],
// "Secure" : true,
// "Official" : true,
// },
// "RemoteName" : "library/debian",
// "LocalName" : "debian",
// "CanonicalName" : "docker.io/debian"
// "Official" : true,
// }
//
// {
// "Index" : {
// "Name" : "127.0.0.1:5000",
// "Mirrors" : [],
// "Secure" : false,
// "Official" : false,
// },
// "RemoteName" : "user/repo",
// "LocalName" : "127.0.0.1:5000/user/repo",
// "CanonicalName" : "127.0.0.1:5000/user/repo",
// "Official" : false,
// }
type IndexInfo struct {
// Name is the name of the registry, such as "docker.io"
Name string
// Mirrors is a list of mirrors, expressed as URIs
Mirrors []string
// Secure is set to false if the registry is part of the list of
// insecure registries. Insecure registries accept HTTP and/or accept
// HTTPS with certificates from unknown CAs.
Secure bool
// Official indicates whether this is an official registry
Official bool
}
// RepositoryInfo describes a repository
type RepositoryInfo struct {
// Index points to registry information
Index *IndexInfo
Index *registrytypes.IndexInfo
// RemoteName is the remote name of the repository, such as
// "library/ubuntu-12.04-base"
RemoteName reference.Named