Browse code

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

Signed-off-by: Daniel Nephin <dnephin@gmail.com>

Daniel Nephin authored on 2015/12/12 11:14:52
Showing 25 changed files
... ...
@@ -9,6 +9,7 @@ import (
9 9
 	"strings"
10 10
 
11 11
 	"github.com/docker/docker/api/client/lib"
12
+	"github.com/docker/docker/api/types"
12 13
 	Cli "github.com/docker/docker/cli"
13 14
 	flag "github.com/docker/docker/pkg/mflag"
14 15
 	"github.com/docker/docker/pkg/term"
... ...
@@ -8,7 +8,6 @@ import (
8 8
 	"github.com/docker/docker/api/client/lib"
9 9
 	"github.com/docker/docker/api/types"
10 10
 	Cli "github.com/docker/docker/cli"
11
-	"github.com/docker/docker/cliconfig"
12 11
 	"github.com/docker/docker/pkg/jsonmessage"
13 12
 	flag "github.com/docker/docker/pkg/mflag"
14 13
 	"github.com/docker/docker/registry"
... ...
@@ -78,7 +77,7 @@ func (cli *DockerCli) CmdPull(args ...string) error {
78 78
 
79 79
 func (cli *DockerCli) imagePullPrivileged(authConfig types.AuthConfig, imageID, tag string, requestPrivilege lib.RequestPrivilegeFunc) error {
80 80
 
81
-	encodedAuth, err := cliconfig.EncodeAuthToBase64(authConfig)
81
+	encodedAuth, err := encodeAuthToBase64(authConfig)
82 82
 	if err != nil {
83 83
 		return err
84 84
 	}
... ...
@@ -9,7 +9,6 @@ import (
9 9
 	"github.com/docker/docker/api/client/lib"
10 10
 	"github.com/docker/docker/api/types"
11 11
 	Cli "github.com/docker/docker/cli"
12
-	"github.com/docker/docker/cliconfig"
13 12
 	"github.com/docker/docker/pkg/jsonmessage"
14 13
 	flag "github.com/docker/docker/pkg/mflag"
15 14
 	"github.com/docker/docker/registry"
... ...
@@ -66,7 +65,7 @@ func (cli *DockerCli) CmdPush(args ...string) error {
66 66
 }
67 67
 
68 68
 func (cli *DockerCli) imagePushPrivileged(authConfig types.AuthConfig, imageID, tag string, outputStream io.Writer, requestPrivilege lib.RequestPrivilegeFunc) error {
69
-	encodedAuth, err := cliconfig.EncodeAuthToBase64(authConfig)
69
+	encodedAuth, err := encodeAuthToBase64(authConfig)
70 70
 	if err != nil {
71 71
 		return err
72 72
 	}
... ...
@@ -9,7 +9,6 @@ import (
9 9
 
10 10
 	"github.com/docker/docker/api/types"
11 11
 	Cli "github.com/docker/docker/cli"
12
-	"github.com/docker/docker/cliconfig"
13 12
 	flag "github.com/docker/docker/pkg/mflag"
14 13
 	"github.com/docker/docker/pkg/stringutils"
15 14
 	"github.com/docker/docker/registry"
... ...
@@ -39,7 +38,7 @@ func (cli *DockerCli) CmdSearch(args ...string) error {
39 39
 	authConfig := registry.ResolveAuthConfig(cli.configFile.AuthConfigs, indexInfo)
40 40
 	requestPrivilege := cli.registryAuthenticationPrivilegedFunc(indexInfo, "search")
41 41
 
42
-	encodedAuth, err := cliconfig.EncodeAuthToBase64(authConfig)
42
+	encodedAuth, err := encodeAuthToBase64(authConfig)
43 43
 	if err != nil {
44 44
 		return err
45 45
 	}
... ...
@@ -24,6 +24,7 @@ import (
24 24
 	"github.com/docker/distribution/registry/client/transport"
25 25
 	"github.com/docker/docker/api/client/lib"
26 26
 	"github.com/docker/docker/api/types"
27
+	registrytypes "github.com/docker/docker/api/types/registry"
27 28
 	"github.com/docker/docker/cliconfig"
28 29
 	"github.com/docker/docker/pkg/ansiescape"
29 30
 	"github.com/docker/docker/pkg/ioutils"
... ...
@@ -81,7 +82,7 @@ func (cli *DockerCli) certificateDirectory(server string) (string, error) {
81 81
 	return filepath.Join(cliconfig.ConfigDir(), "tls", u.Host), nil
82 82
 }
83 83
 
84
-func trustServer(index *registry.IndexInfo) (string, error) {
84
+func trustServer(index *registrytypes.IndexInfo) (string, error) {
85 85
 	if s := os.Getenv("DOCKER_CONTENT_TRUST_SERVER"); s != "" {
86 86
 		urlObj, err := url.Parse(s)
87 87
 		if err != nil || urlObj.Scheme != "https" {
... ...
@@ -4,6 +4,7 @@ import (
4 4
 	"os"
5 5
 	"testing"
6 6
 
7
+	registrytypes "github.com/docker/docker/api/types/registry"
7 8
 	"github.com/docker/docker/registry"
8 9
 )
9 10
 
... ...
@@ -14,7 +15,7 @@ func unsetENV() {
14 14
 
15 15
 func TestENVTrustServer(t *testing.T) {
16 16
 	defer unsetENV()
17
-	indexInfo := &registry.IndexInfo{Name: "testserver"}
17
+	indexInfo := &registrytypes.IndexInfo{Name: "testserver"}
18 18
 	if err := os.Setenv("DOCKER_CONTENT_TRUST_SERVER", "https://notary-test.com:5000"); err != nil {
19 19
 		t.Fatal("Failed to set ENV variable")
20 20
 	}
... ...
@@ -27,7 +28,7 @@ func TestENVTrustServer(t *testing.T) {
27 27
 
28 28
 func TestHTTPENVTrustServer(t *testing.T) {
29 29
 	defer unsetENV()
30
-	indexInfo := &registry.IndexInfo{Name: "testserver"}
30
+	indexInfo := &registrytypes.IndexInfo{Name: "testserver"}
31 31
 	if err := os.Setenv("DOCKER_CONTENT_TRUST_SERVER", "http://notary-test.com:5000"); err != nil {
32 32
 		t.Fatal("Failed to set ENV variable")
33 33
 	}
... ...
@@ -38,7 +39,7 @@ func TestHTTPENVTrustServer(t *testing.T) {
38 38
 }
39 39
 
40 40
 func TestOfficialTrustServer(t *testing.T) {
41
-	indexInfo := &registry.IndexInfo{Name: "testserver", Official: true}
41
+	indexInfo := &registrytypes.IndexInfo{Name: "testserver", Official: true}
42 42
 	output, err := trustServer(indexInfo)
43 43
 	if err != nil || output != registry.NotaryServer {
44 44
 		t.Fatalf("Expected server to be %s, got %s", registry.NotaryServer, output)
... ...
@@ -46,7 +47,7 @@ func TestOfficialTrustServer(t *testing.T) {
46 46
 }
47 47
 
48 48
 func TestNonOfficialTrustServer(t *testing.T) {
49
-	indexInfo := &registry.IndexInfo{Name: "testserver", Official: false}
49
+	indexInfo := &registrytypes.IndexInfo{Name: "testserver", Official: false}
50 50
 	output, err := trustServer(indexInfo)
51 51
 	expectedStr := "https://" + indexInfo.Name
52 52
 	if err != nil || output != expectedStr {
... ...
@@ -12,13 +12,14 @@ import (
12 12
 	"github.com/Sirupsen/logrus"
13 13
 	"github.com/docker/docker/api/client/lib"
14 14
 	"github.com/docker/docker/api/types"
15
+	registrytypes "github.com/docker/docker/api/types/registry"
15 16
 	"github.com/docker/docker/pkg/signal"
16 17
 	"github.com/docker/docker/pkg/term"
17 18
 	"github.com/docker/docker/registry"
18 19
 )
19 20
 
20 21
 // encodeAuthToBase64 serializes the auth configuration as JSON base64 payload
21
-func encodeAuthToBase64(authConfig AuthConfig) (string, error) {
22
+func encodeAuthToBase64(authConfig types.AuthConfig) (string, error) {
22 23
 	buf, err := json.Marshal(authConfig)
23 24
 	if err != nil {
24 25
 		return "", err
... ...
@@ -26,15 +27,15 @@ func encodeAuthToBase64(authConfig AuthConfig) (string, error) {
26 26
 	return base64.URLEncoding.EncodeToString(buf), nil
27 27
 }
28 28
 
29
-func (cli *DockerCli) encodeRegistryAuth(index *registry.IndexInfo) (string, error) {
29
+func (cli *DockerCli) encodeRegistryAuth(index *registrytypes.IndexInfo) (string, error) {
30 30
 	authConfig := registry.ResolveAuthConfig(cli.configFile.AuthConfigs, index)
31
-	return cliconfig.EncodeAuthToBase64(authConfig)
31
+	return encodeAuthToBase64(authConfig)
32 32
 }
33 33
 
34
-func (cli *DockerCli) registryAuthenticationPrivilegedFunc(index *registry.IndexInfo, cmdName string) lib.RequestPrivilegeFunc {
34
+func (cli *DockerCli) registryAuthenticationPrivilegedFunc(index *registrytypes.IndexInfo, cmdName string) lib.RequestPrivilegeFunc {
35 35
 	return func() (string, error) {
36 36
 		fmt.Fprintf(cli.out, "\nPlease login prior to %s:\n", cmdName)
37
-		if err := cli.CmdLogin(index.GetAuthConfigKey()); err != nil {
37
+		if err := cli.CmdLogin(registry.GetAuthConfigKey(index)); err != nil {
38 38
 			return "", err
39 39
 		}
40 40
 		return cli.encodeRegistryAuth(index)
... ...
@@ -134,7 +134,7 @@ type ImageBuildOptions struct {
134 134
 	Dockerfile     string
135 135
 	Ulimits        []*ulimit.Ulimit
136 136
 	BuildArgs      []string
137
-	AuthConfigs    map[string]types.AuthConfig
137
+	AuthConfigs    map[string]AuthConfig
138 138
 	Context        io.Reader
139 139
 }
140 140
 
141 141
new file mode 100644
... ...
@@ -0,0 +1,75 @@
0
+package registry
1
+
2
+import (
3
+	"encoding/json"
4
+	"net"
5
+)
6
+
7
+// ServiceConfig stores daemon registry services configuration.
8
+type ServiceConfig struct {
9
+	InsecureRegistryCIDRs []*NetIPNet           `json:"InsecureRegistryCIDRs"`
10
+	IndexConfigs          map[string]*IndexInfo `json:"IndexConfigs"`
11
+	Mirrors               []string
12
+}
13
+
14
+// NetIPNet is the net.IPNet type, which can be marshalled and
15
+// unmarshalled to JSON
16
+type NetIPNet net.IPNet
17
+
18
+// MarshalJSON returns the JSON representation of the IPNet
19
+func (ipnet *NetIPNet) MarshalJSON() ([]byte, error) {
20
+	return json.Marshal((*net.IPNet)(ipnet).String())
21
+}
22
+
23
+// UnmarshalJSON sets the IPNet from a byte array of JSON
24
+func (ipnet *NetIPNet) UnmarshalJSON(b []byte) (err error) {
25
+	var ipnetStr string
26
+	if err = json.Unmarshal(b, &ipnetStr); err == nil {
27
+		var cidr *net.IPNet
28
+		if _, cidr, err = net.ParseCIDR(ipnetStr); err == nil {
29
+			*ipnet = NetIPNet(*cidr)
30
+		}
31
+	}
32
+	return
33
+}
34
+
35
+// IndexInfo contains information about a registry
36
+//
37
+// RepositoryInfo Examples:
38
+// {
39
+//   "Index" : {
40
+//     "Name" : "docker.io",
41
+//     "Mirrors" : ["https://registry-2.docker.io/v1/", "https://registry-3.docker.io/v1/"],
42
+//     "Secure" : true,
43
+//     "Official" : true,
44
+//   },
45
+//   "RemoteName" : "library/debian",
46
+//   "LocalName" : "debian",
47
+//   "CanonicalName" : "docker.io/debian"
48
+//   "Official" : true,
49
+// }
50
+//
51
+// {
52
+//   "Index" : {
53
+//     "Name" : "127.0.0.1:5000",
54
+//     "Mirrors" : [],
55
+//     "Secure" : false,
56
+//     "Official" : false,
57
+//   },
58
+//   "RemoteName" : "user/repo",
59
+//   "LocalName" : "127.0.0.1:5000/user/repo",
60
+//   "CanonicalName" : "127.0.0.1:5000/user/repo",
61
+//   "Official" : false,
62
+// }
63
+type IndexInfo struct {
64
+	// Name is the name of the registry, such as "docker.io"
65
+	Name string
66
+	// Mirrors is a list of mirrors, expressed as URIs
67
+	Mirrors []string
68
+	// Secure is set to false if the registry is part of the list of
69
+	// insecure registries. Insecure registries accept HTTP and/or accept
70
+	// HTTPS with certificates from unknown CAs.
71
+	Secure bool
72
+	// Official indicates whether this is an official registry
73
+	Official bool
74
+}
... ...
@@ -5,9 +5,9 @@ import (
5 5
 	"time"
6 6
 
7 7
 	"github.com/docker/docker/api/types/network"
8
+	"github.com/docker/docker/api/types/registry"
8 9
 	"github.com/docker/docker/pkg/nat"
9 10
 	"github.com/docker/docker/pkg/version"
10
-	"github.com/docker/docker/registry"
11 11
 	"github.com/docker/docker/runconfig"
12 12
 )
13 13
 
... ...
@@ -45,15 +45,6 @@ func SetConfigDir(dir string) {
45 45
 	configDir = dir
46 46
 }
47 47
 
48
-// EncodeAuthToBase64 serializes the auth configuration as JSON base64 payload
49
-func EncodeAuthToBase64(authConfig AuthConfig) (string, error) {
50
-	buf, err := json.Marshal(authConfig)
51
-	if err != nil {
52
-		return "", err
53
-	}
54
-	return base64.URLEncoding.EncodeToString(buf), nil
55
-}
56
-
57 48
 // ConfigFile ~/.docker/config.json file info
58 49
 type ConfigFile struct {
59 50
 	AuthConfigs map[string]types.AuthConfig `json:"auths"`
... ...
@@ -13,7 +13,6 @@ import (
13 13
 	"github.com/docker/docker/api"
14 14
 	"github.com/docker/docker/api/types"
15 15
 	"github.com/docker/docker/builder"
16
-	"github.com/docker/docker/cliconfig"
17 16
 	"github.com/docker/docker/container"
18 17
 	"github.com/docker/docker/daemon"
19 18
 	"github.com/docker/docker/image"
... ...
@@ -7,6 +7,7 @@ import (
7 7
 
8 8
 	"github.com/Sirupsen/logrus"
9 9
 	"github.com/docker/distribution/reference"
10
+	"github.com/docker/docker/api/types"
10 11
 	"github.com/docker/docker/daemon/events"
11 12
 	"github.com/docker/docker/distribution/metadata"
12 13
 	"github.com/docker/docker/distribution/xfer"
... ...
@@ -9,6 +9,7 @@ import (
9 9
 	"github.com/Sirupsen/logrus"
10 10
 	"github.com/docker/distribution/digest"
11 11
 	"github.com/docker/distribution/reference"
12
+	"github.com/docker/docker/api/types"
12 13
 	"github.com/docker/docker/daemon/events"
13 14
 	"github.com/docker/docker/distribution/metadata"
14 15
 	"github.com/docker/docker/distribution/xfer"
... ...
@@ -17,6 +17,7 @@ import (
17 17
 	"github.com/docker/distribution/registry/client"
18 18
 	"github.com/docker/distribution/registry/client/auth"
19 19
 	"github.com/docker/distribution/registry/client/transport"
20
+	"github.com/docker/docker/api/types"
20 21
 	"github.com/docker/docker/distribution/xfer"
21 22
 	"github.com/docker/docker/registry"
22 23
 	"golang.org/x/net/context"
... ...
@@ -10,6 +10,8 @@ import (
10 10
 	"github.com/Sirupsen/logrus"
11 11
 	"github.com/docker/distribution/reference"
12 12
 	"github.com/docker/distribution/registry/client/auth"
13
+	"github.com/docker/docker/api/types"
14
+	registrytypes "github.com/docker/docker/api/types/registry"
13 15
 	"github.com/docker/docker/registry"
14 16
 	"github.com/docker/docker/utils"
15 17
 	"golang.org/x/net/context"
... ...
@@ -56,7 +58,7 @@ func TestTokenPassThru(t *testing.T) {
56 56
 	}
57 57
 	n, _ := reference.ParseNamed("testremotename")
58 58
 	repoInfo := &registry.RepositoryInfo{
59
-		Index: &registry.IndexInfo{
59
+		Index: &registrytypes.IndexInfo{
60 60
 			Name:     "testrepo",
61 61
 			Mirrors:  nil,
62 62
 			Secure:   false,
... ...
@@ -8,7 +8,8 @@ import (
8 8
 	"strings"
9 9
 
10 10
 	"github.com/Sirupsen/logrus"
11
-	"github.com/docker/docker/cliconfig"
11
+	"github.com/docker/docker/api/types"
12
+	registrytypes "github.com/docker/docker/api/types/registry"
12 13
 )
13 14
 
14 15
 // Login tries to register/login to the registry server.
... ...
@@ -221,8 +222,8 @@ func tryV2TokenAuthLogin(authConfig *types.AuthConfig, params map[string]string,
221 221
 }
222 222
 
223 223
 // ResolveAuthConfig matches an auth configuration to a server address or a URL
224
-func ResolveAuthConfig(authConfigs map[string]types.AuthConfig, index *IndexInfo) types.AuthConfig {
225
-	configKey := index.GetAuthConfigKey()
224
+func ResolveAuthConfig(authConfigs map[string]types.AuthConfig, index *registrytypes.IndexInfo) types.AuthConfig {
225
+	configKey := GetAuthConfigKey(index)
226 226
 	// First try the happy case
227 227
 	if c, found := authConfigs[configKey]; found || index.Official {
228 228
 		return c
... ...
@@ -3,6 +3,8 @@ package registry
3 3
 import (
4 4
 	"testing"
5 5
 
6
+	"github.com/docker/docker/api/types"
7
+	registrytypes "github.com/docker/docker/api/types/registry"
6 8
 	"github.com/docker/docker/cliconfig"
7 9
 )
8 10
 
... ...
@@ -26,8 +28,8 @@ func TestEncodeAuth(t *testing.T) {
26 26
 	}
27 27
 }
28 28
 
29
-func buildAuthConfigs() map[string]cliconfig.AuthConfig {
30
-	authConfigs := map[string]cliconfig.AuthConfig{}
29
+func buildAuthConfigs() map[string]types.AuthConfig {
30
+	authConfigs := map[string]types.AuthConfig{}
31 31
 
32 32
 	for _, registry := range []string{"testIndex", IndexServer} {
33 33
 		authConfigs[registry] = types.AuthConfig{
... ...
@@ -61,10 +63,10 @@ func TestResolveAuthConfigIndexServer(t *testing.T) {
61 61
 	authConfigs := buildAuthConfigs()
62 62
 	indexConfig := authConfigs[IndexServer]
63 63
 
64
-	officialIndex := &IndexInfo{
64
+	officialIndex := &registrytypes.IndexInfo{
65 65
 		Official: true,
66 66
 	}
67
-	privateIndex := &IndexInfo{
67
+	privateIndex := &registrytypes.IndexInfo{
68 68
 		Official: false,
69 69
 	}
70 70
 
... ...
@@ -127,7 +129,7 @@ func TestResolveAuthConfigFullURL(t *testing.T) {
127 127
 		if !ok || configured.Email == "" {
128 128
 			t.Fail()
129 129
 		}
130
-		index := &IndexInfo{
130
+		index := &registrytypes.IndexInfo{
131 131
 			Name: configKey,
132 132
 		}
133 133
 		for _, registry := range registries {
... ...
@@ -1,7 +1,6 @@
1 1
 package registry
2 2
 
3 3
 import (
4
-	"encoding/json"
5 4
 	"errors"
6 5
 	"fmt"
7 6
 	"net"
... ...
@@ -9,6 +8,7 @@ import (
9 9
 	"strings"
10 10
 
11 11
 	"github.com/docker/distribution/reference"
12
+	registrytypes "github.com/docker/docker/api/types/registry"
12 13
 	"github.com/docker/docker/image/v1"
13 14
 	"github.com/docker/docker/opts"
14 15
 	flag "github.com/docker/docker/pkg/mflag"
... ...
@@ -60,32 +60,8 @@ func (options *Options) InstallFlags(cmd *flag.FlagSet, usageFn func(string) str
60 60
 	cmd.BoolVar(&V2Only, []string{"-disable-legacy-registry"}, false, "Do not contact legacy registries")
61 61
 }
62 62
 
63
-type netIPNet net.IPNet
64
-
65
-func (ipnet *netIPNet) MarshalJSON() ([]byte, error) {
66
-	return json.Marshal((*net.IPNet)(ipnet).String())
67
-}
68
-
69
-func (ipnet *netIPNet) UnmarshalJSON(b []byte) (err error) {
70
-	var ipnetStr string
71
-	if err = json.Unmarshal(b, &ipnetStr); err == nil {
72
-		var cidr *net.IPNet
73
-		if _, cidr, err = net.ParseCIDR(ipnetStr); err == nil {
74
-			*ipnet = netIPNet(*cidr)
75
-		}
76
-	}
77
-	return
78
-}
79
-
80
-// ServiceConfig stores daemon registry services configuration.
81
-type ServiceConfig struct {
82
-	InsecureRegistryCIDRs []*netIPNet           `json:"InsecureRegistryCIDRs"`
83
-	IndexConfigs          map[string]*IndexInfo `json:"IndexConfigs"`
84
-	Mirrors               []string
85
-}
86
-
87 63
 // NewServiceConfig returns a new instance of ServiceConfig
88
-func NewServiceConfig(options *Options) *ServiceConfig {
64
+func NewServiceConfig(options *Options) *registrytypes.ServiceConfig {
89 65
 	if options == nil {
90 66
 		options = &Options{
91 67
 			Mirrors:            opts.NewListOpts(nil),
... ...
@@ -100,9 +76,9 @@ func NewServiceConfig(options *Options) *ServiceConfig {
100 100
 	// daemon flags on boot2docker?
101 101
 	options.InsecureRegistries.Set("127.0.0.0/8")
102 102
 
103
-	config := &ServiceConfig{
104
-		InsecureRegistryCIDRs: make([]*netIPNet, 0),
105
-		IndexConfigs:          make(map[string]*IndexInfo, 0),
103
+	config := &registrytypes.ServiceConfig{
104
+		InsecureRegistryCIDRs: make([]*registrytypes.NetIPNet, 0),
105
+		IndexConfigs:          make(map[string]*registrytypes.IndexInfo, 0),
106 106
 		// Hack: Bypass setting the mirrors to IndexConfigs since they are going away
107 107
 		// and Mirrors are only for the official registry anyways.
108 108
 		Mirrors: options.Mirrors.GetAll(),
... ...
@@ -113,10 +89,10 @@ func NewServiceConfig(options *Options) *ServiceConfig {
113 113
 		_, ipnet, err := net.ParseCIDR(r)
114 114
 		if err == nil {
115 115
 			// Valid CIDR.
116
-			config.InsecureRegistryCIDRs = append(config.InsecureRegistryCIDRs, (*netIPNet)(ipnet))
116
+			config.InsecureRegistryCIDRs = append(config.InsecureRegistryCIDRs, (*registrytypes.NetIPNet)(ipnet))
117 117
 		} else {
118 118
 			// Assume `host:port` if not CIDR.
119
-			config.IndexConfigs[r] = &IndexInfo{
119
+			config.IndexConfigs[r] = &registrytypes.IndexInfo{
120 120
 				Name:     r,
121 121
 				Mirrors:  make([]string, 0),
122 122
 				Secure:   false,
... ...
@@ -126,7 +102,7 @@ func NewServiceConfig(options *Options) *ServiceConfig {
126 126
 	}
127 127
 
128 128
 	// Configure public registry.
129
-	config.IndexConfigs[IndexName] = &IndexInfo{
129
+	config.IndexConfigs[IndexName] = &registrytypes.IndexInfo{
130 130
 		Name:     IndexName,
131 131
 		Mirrors:  config.Mirrors,
132 132
 		Secure:   true,
... ...
@@ -147,9 +123,9 @@ func NewServiceConfig(options *Options) *ServiceConfig {
147 147
 // or an IP address. If it is a domain name, then it will be resolved in order to check if the IP is contained
148 148
 // in a subnet. If the resolving is not successful, isSecureIndex will only try to match hostname to any element
149 149
 // of insecureRegistries.
150
-func (config *ServiceConfig) isSecureIndex(indexName string) bool {
150
+func isSecureIndex(config *registrytypes.ServiceConfig, indexName string) bool {
151 151
 	// Check for configured index, first.  This is needed in case isSecureIndex
152
-	// is called from anything besides NewIndexInfo, in order to honor per-index configurations.
152
+	// is called from anything besides newIndexInfo, in order to honor per-index configurations.
153 153
 	if index, ok := config.IndexConfigs[indexName]; ok {
154 154
 		return index.Secure
155 155
 	}
... ...
@@ -258,8 +234,8 @@ func loadRepositoryName(reposName reference.Named) (string, reference.Named, err
258 258
 	return indexName, remoteName, nil
259 259
 }
260 260
 
261
-// NewIndexInfo returns IndexInfo configuration from indexName
262
-func (config *ServiceConfig) NewIndexInfo(indexName string) (*IndexInfo, error) {
261
+// newIndexInfo returns IndexInfo configuration from indexName
262
+func newIndexInfo(config *registrytypes.ServiceConfig, indexName string) (*registrytypes.IndexInfo, error) {
263 263
 	var err error
264 264
 	indexName, err = ValidateIndexName(indexName)
265 265
 	if err != nil {
... ...
@@ -272,18 +248,18 @@ func (config *ServiceConfig) NewIndexInfo(indexName string) (*IndexInfo, error)
272 272
 	}
273 273
 
274 274
 	// Construct a non-configured index info.
275
-	index := &IndexInfo{
275
+	index := &registrytypes.IndexInfo{
276 276
 		Name:     indexName,
277 277
 		Mirrors:  make([]string, 0),
278 278
 		Official: false,
279 279
 	}
280
-	index.Secure = config.isSecureIndex(indexName)
280
+	index.Secure = isSecureIndex(config, indexName)
281 281
 	return index, nil
282 282
 }
283 283
 
284 284
 // GetAuthConfigKey special-cases using the full index address of the official
285 285
 // index as the AuthConfig key, and uses the (host)name[:port] for private indexes.
286
-func (index *IndexInfo) GetAuthConfigKey() string {
286
+func GetAuthConfigKey(index *registrytypes.IndexInfo) string {
287 287
 	if index.Official {
288 288
 		return IndexServer
289 289
 	}
... ...
@@ -306,8 +282,8 @@ func splitReposName(reposName reference.Named) (indexName string, remoteName ref
306 306
 	return
307 307
 }
308 308
 
309
-// NewRepositoryInfo validates and breaks down a repository name into a RepositoryInfo
310
-func (config *ServiceConfig) NewRepositoryInfo(reposName reference.Named) (*RepositoryInfo, error) {
309
+// newRepositoryInfo validates and breaks down a repository name into a RepositoryInfo
310
+func newRepositoryInfo(config *registrytypes.ServiceConfig, reposName reference.Named) (*RepositoryInfo, error) {
311 311
 	if err := validateNoSchema(reposName.Name()); err != nil {
312 312
 		return nil, err
313 313
 	}
... ...
@@ -323,7 +299,7 @@ func (config *ServiceConfig) NewRepositoryInfo(reposName reference.Named) (*Repo
323 323
 		return nil, err
324 324
 	}
325 325
 
326
-	repoInfo.Index, err = config.NewIndexInfo(indexName)
326
+	repoInfo.Index, err = newIndexInfo(config, indexName)
327 327
 	if err != nil {
328 328
 		return nil, err
329 329
 	}
... ...
@@ -364,14 +340,14 @@ func (config *ServiceConfig) NewRepositoryInfo(reposName reference.Named) (*Repo
364 364
 // ParseRepositoryInfo performs the breakdown of a repository name into a RepositoryInfo, but
365 365
 // lacks registry configuration.
366 366
 func ParseRepositoryInfo(reposName reference.Named) (*RepositoryInfo, error) {
367
-	return emptyServiceConfig.NewRepositoryInfo(reposName)
367
+	return newRepositoryInfo(emptyServiceConfig, reposName)
368 368
 }
369 369
 
370 370
 // ParseSearchIndexInfo will use repository name to get back an indexInfo.
371
-func ParseSearchIndexInfo(reposName string) (*IndexInfo, error) {
371
+func ParseSearchIndexInfo(reposName string) (*registrytypes.IndexInfo, error) {
372 372
 	indexName, _ := splitReposSearchTerm(reposName)
373 373
 
374
-	indexInfo, err := emptyServiceConfig.NewIndexInfo(indexName)
374
+	indexInfo, err := newIndexInfo(emptyServiceConfig, indexName)
375 375
 	if err != nil {
376 376
 		return nil, err
377 377
 	}
... ...
@@ -13,6 +13,7 @@ import (
13 13
 	"github.com/Sirupsen/logrus"
14 14
 	"github.com/docker/distribution/registry/api/v2"
15 15
 	"github.com/docker/distribution/registry/client/transport"
16
+	registrytypes "github.com/docker/docker/api/types/registry"
16 17
 )
17 18
 
18 19
 // for mocking in unit tests
... ...
@@ -44,12 +45,12 @@ func scanForAPIVersion(address string) (string, APIVersion) {
44 44
 
45 45
 // NewEndpoint parses the given address to return a registry endpoint.  v can be used to
46 46
 // specify a specific endpoint version
47
-func NewEndpoint(index *IndexInfo, metaHeaders http.Header, v APIVersion) (*Endpoint, error) {
47
+func NewEndpoint(index *registrytypes.IndexInfo, metaHeaders http.Header, v APIVersion) (*Endpoint, error) {
48 48
 	tlsConfig, err := newTLSConfig(index.Name, index.Secure)
49 49
 	if err != nil {
50 50
 		return nil, err
51 51
 	}
52
-	endpoint, err := newEndpoint(index.GetAuthConfigKey(), tlsConfig, metaHeaders)
52
+	endpoint, err := newEndpoint(GetAuthConfigKey(index), tlsConfig, metaHeaders)
53 53
 	if err != nil {
54 54
 		return nil, err
55 55
 	}
... ...
@@ -16,6 +16,7 @@ import (
16 16
 	"time"
17 17
 
18 18
 	"github.com/docker/distribution/reference"
19
+	registrytypes "github.com/docker/docker/api/types/registry"
19 20
 	"github.com/docker/docker/opts"
20 21
 	"github.com/gorilla/mux"
21 22
 
... ...
@@ -150,22 +151,22 @@ func makeHTTPSURL(req string) string {
150 150
 	return testHTTPSServer.URL + req
151 151
 }
152 152
 
153
-func makeIndex(req string) *IndexInfo {
154
-	index := &IndexInfo{
153
+func makeIndex(req string) *registrytypes.IndexInfo {
154
+	index := &registrytypes.IndexInfo{
155 155
 		Name: makeURL(req),
156 156
 	}
157 157
 	return index
158 158
 }
159 159
 
160
-func makeHTTPSIndex(req string) *IndexInfo {
161
-	index := &IndexInfo{
160
+func makeHTTPSIndex(req string) *registrytypes.IndexInfo {
161
+	index := &registrytypes.IndexInfo{
162 162
 		Name: makeHTTPSURL(req),
163 163
 	}
164 164
 	return index
165 165
 }
166 166
 
167
-func makePublicIndex() *IndexInfo {
168
-	index := &IndexInfo{
167
+func makePublicIndex() *registrytypes.IndexInfo {
168
+	index := &registrytypes.IndexInfo{
169 169
 		Name:     IndexServer,
170 170
 		Secure:   true,
171 171
 		Official: true,
... ...
@@ -173,7 +174,7 @@ func makePublicIndex() *IndexInfo {
173 173
 	return index
174 174
 }
175 175
 
176
-func makeServiceConfig(mirrors []string, insecureRegistries []string) *ServiceConfig {
176
+func makeServiceConfig(mirrors []string, insecureRegistries []string) *registrytypes.ServiceConfig {
177 177
 	options := &Options{
178 178
 		Mirrors:            opts.NewListOpts(nil),
179 179
 		InsecureRegistries: opts.NewListOpts(nil),
... ...
@@ -10,6 +10,8 @@ import (
10 10
 
11 11
 	"github.com/docker/distribution/reference"
12 12
 	"github.com/docker/distribution/registry/client/transport"
13
+	"github.com/docker/docker/api/types"
14
+	registrytypes "github.com/docker/docker/api/types/registry"
13 15
 )
14 16
 
15 17
 var (
... ...
@@ -49,7 +51,7 @@ func spawnTestRegistrySession(t *testing.T) *Session {
49 49
 }
50 50
 
51 51
 func TestPingRegistryEndpoint(t *testing.T) {
52
-	testPing := func(index *IndexInfo, expectedStandalone bool, assertMessage string) {
52
+	testPing := func(index *registrytypes.IndexInfo, expectedStandalone bool, assertMessage string) {
53 53
 		ep, err := NewEndpoint(index, nil, APIVersionUnknown)
54 54
 		if err != nil {
55 55
 			t.Fatal(err)
... ...
@@ -69,7 +71,7 @@ func TestPingRegistryEndpoint(t *testing.T) {
69 69
 
70 70
 func TestEndpoint(t *testing.T) {
71 71
 	// Simple wrapper to fail test if err != nil
72
-	expandEndpoint := func(index *IndexInfo) *Endpoint {
72
+	expandEndpoint := func(index *registrytypes.IndexInfo) *Endpoint {
73 73
 		endpoint, err := NewEndpoint(index, nil, APIVersionUnknown)
74 74
 		if err != nil {
75 75
 			t.Fatal(err)
... ...
@@ -77,7 +79,7 @@ func TestEndpoint(t *testing.T) {
77 77
 		return endpoint
78 78
 	}
79 79
 
80
-	assertInsecureIndex := func(index *IndexInfo) {
80
+	assertInsecureIndex := func(index *registrytypes.IndexInfo) {
81 81
 		index.Secure = true
82 82
 		_, err := NewEndpoint(index, nil, APIVersionUnknown)
83 83
 		assertNotEqual(t, err, nil, index.Name+": Expected error for insecure index")
... ...
@@ -85,7 +87,7 @@ func TestEndpoint(t *testing.T) {
85 85
 		index.Secure = false
86 86
 	}
87 87
 
88
-	assertSecureIndex := func(index *IndexInfo) {
88
+	assertSecureIndex := func(index *registrytypes.IndexInfo) {
89 89
 		index.Secure = true
90 90
 		_, err := NewEndpoint(index, nil, APIVersionUnknown)
91 91
 		assertNotEqual(t, err, nil, index.Name+": Expected cert error for secure index")
... ...
@@ -93,7 +95,7 @@ func TestEndpoint(t *testing.T) {
93 93
 		index.Secure = false
94 94
 	}
95 95
 
96
-	index := &IndexInfo{}
96
+	index := &registrytypes.IndexInfo{}
97 97
 	index.Name = makeURL("/v1/")
98 98
 	endpoint := expandEndpoint(index)
99 99
 	assertEqual(t, endpoint.String(), index.Name, "Expected endpoint to be "+index.Name)
... ...
@@ -363,7 +365,7 @@ func TestParseRepositoryInfo(t *testing.T) {
363 363
 
364 364
 	expectedRepoInfos := map[string]RepositoryInfo{
365 365
 		"fooo/bar": {
366
-			Index: &IndexInfo{
366
+			Index: &registrytypes.IndexInfo{
367 367
 				Name:     IndexName,
368 368
 				Official: true,
369 369
 			},
... ...
@@ -373,7 +375,7 @@ func TestParseRepositoryInfo(t *testing.T) {
373 373
 			Official:      false,
374 374
 		},
375 375
 		"library/ubuntu": {
376
-			Index: &IndexInfo{
376
+			Index: &registrytypes.IndexInfo{
377 377
 				Name:     IndexName,
378 378
 				Official: true,
379 379
 			},
... ...
@@ -383,7 +385,7 @@ func TestParseRepositoryInfo(t *testing.T) {
383 383
 			Official:      true,
384 384
 		},
385 385
 		"nonlibrary/ubuntu": {
386
-			Index: &IndexInfo{
386
+			Index: &registrytypes.IndexInfo{
387 387
 				Name:     IndexName,
388 388
 				Official: true,
389 389
 			},
... ...
@@ -393,7 +395,7 @@ func TestParseRepositoryInfo(t *testing.T) {
393 393
 			Official:      false,
394 394
 		},
395 395
 		"ubuntu": {
396
-			Index: &IndexInfo{
396
+			Index: &registrytypes.IndexInfo{
397 397
 				Name:     IndexName,
398 398
 				Official: true,
399 399
 			},
... ...
@@ -403,7 +405,7 @@ func TestParseRepositoryInfo(t *testing.T) {
403 403
 			Official:      true,
404 404
 		},
405 405
 		"other/library": {
406
-			Index: &IndexInfo{
406
+			Index: &registrytypes.IndexInfo{
407 407
 				Name:     IndexName,
408 408
 				Official: true,
409 409
 			},
... ...
@@ -413,7 +415,7 @@ func TestParseRepositoryInfo(t *testing.T) {
413 413
 			Official:      false,
414 414
 		},
415 415
 		"127.0.0.1:8000/private/moonbase": {
416
-			Index: &IndexInfo{
416
+			Index: &registrytypes.IndexInfo{
417 417
 				Name:     "127.0.0.1:8000",
418 418
 				Official: false,
419 419
 			},
... ...
@@ -423,7 +425,7 @@ func TestParseRepositoryInfo(t *testing.T) {
423 423
 			Official:      false,
424 424
 		},
425 425
 		"127.0.0.1:8000/privatebase": {
426
-			Index: &IndexInfo{
426
+			Index: &registrytypes.IndexInfo{
427 427
 				Name:     "127.0.0.1:8000",
428 428
 				Official: false,
429 429
 			},
... ...
@@ -433,7 +435,7 @@ func TestParseRepositoryInfo(t *testing.T) {
433 433
 			Official:      false,
434 434
 		},
435 435
 		"localhost:8000/private/moonbase": {
436
-			Index: &IndexInfo{
436
+			Index: &registrytypes.IndexInfo{
437 437
 				Name:     "localhost:8000",
438 438
 				Official: false,
439 439
 			},
... ...
@@ -443,7 +445,7 @@ func TestParseRepositoryInfo(t *testing.T) {
443 443
 			Official:      false,
444 444
 		},
445 445
 		"localhost:8000/privatebase": {
446
-			Index: &IndexInfo{
446
+			Index: &registrytypes.IndexInfo{
447 447
 				Name:     "localhost:8000",
448 448
 				Official: false,
449 449
 			},
... ...
@@ -453,7 +455,7 @@ func TestParseRepositoryInfo(t *testing.T) {
453 453
 			Official:      false,
454 454
 		},
455 455
 		"example.com/private/moonbase": {
456
-			Index: &IndexInfo{
456
+			Index: &registrytypes.IndexInfo{
457 457
 				Name:     "example.com",
458 458
 				Official: false,
459 459
 			},
... ...
@@ -463,7 +465,7 @@ func TestParseRepositoryInfo(t *testing.T) {
463 463
 			Official:      false,
464 464
 		},
465 465
 		"example.com/privatebase": {
466
-			Index: &IndexInfo{
466
+			Index: &registrytypes.IndexInfo{
467 467
 				Name:     "example.com",
468 468
 				Official: false,
469 469
 			},
... ...
@@ -473,7 +475,7 @@ func TestParseRepositoryInfo(t *testing.T) {
473 473
 			Official:      false,
474 474
 		},
475 475
 		"example.com:8000/private/moonbase": {
476
-			Index: &IndexInfo{
476
+			Index: &registrytypes.IndexInfo{
477 477
 				Name:     "example.com:8000",
478 478
 				Official: false,
479 479
 			},
... ...
@@ -483,7 +485,7 @@ func TestParseRepositoryInfo(t *testing.T) {
483 483
 			Official:      false,
484 484
 		},
485 485
 		"example.com:8000/privatebase": {
486
-			Index: &IndexInfo{
486
+			Index: &registrytypes.IndexInfo{
487 487
 				Name:     "example.com:8000",
488 488
 				Official: false,
489 489
 			},
... ...
@@ -493,7 +495,7 @@ func TestParseRepositoryInfo(t *testing.T) {
493 493
 			Official:      false,
494 494
 		},
495 495
 		"localhost/private/moonbase": {
496
-			Index: &IndexInfo{
496
+			Index: &registrytypes.IndexInfo{
497 497
 				Name:     "localhost",
498 498
 				Official: false,
499 499
 			},
... ...
@@ -503,7 +505,7 @@ func TestParseRepositoryInfo(t *testing.T) {
503 503
 			Official:      false,
504 504
 		},
505 505
 		"localhost/privatebase": {
506
-			Index: &IndexInfo{
506
+			Index: &registrytypes.IndexInfo{
507 507
 				Name:     "localhost",
508 508
 				Official: false,
509 509
 			},
... ...
@@ -513,7 +515,7 @@ func TestParseRepositoryInfo(t *testing.T) {
513 513
 			Official:      false,
514 514
 		},
515 515
 		IndexName + "/public/moonbase": {
516
-			Index: &IndexInfo{
516
+			Index: &registrytypes.IndexInfo{
517 517
 				Name:     IndexName,
518 518
 				Official: true,
519 519
 			},
... ...
@@ -523,7 +525,7 @@ func TestParseRepositoryInfo(t *testing.T) {
523 523
 			Official:      false,
524 524
 		},
525 525
 		"index." + IndexName + "/public/moonbase": {
526
-			Index: &IndexInfo{
526
+			Index: &registrytypes.IndexInfo{
527 527
 				Name:     IndexName,
528 528
 				Official: true,
529 529
 			},
... ...
@@ -533,7 +535,7 @@ func TestParseRepositoryInfo(t *testing.T) {
533 533
 			Official:      false,
534 534
 		},
535 535
 		"ubuntu-12.04-base": {
536
-			Index: &IndexInfo{
536
+			Index: &registrytypes.IndexInfo{
537 537
 				Name:     IndexName,
538 538
 				Official: true,
539 539
 			},
... ...
@@ -543,7 +545,7 @@ func TestParseRepositoryInfo(t *testing.T) {
543 543
 			Official:      true,
544 544
 		},
545 545
 		IndexName + "/ubuntu-12.04-base": {
546
-			Index: &IndexInfo{
546
+			Index: &registrytypes.IndexInfo{
547 547
 				Name:     IndexName,
548 548
 				Official: true,
549 549
 			},
... ...
@@ -553,7 +555,7 @@ func TestParseRepositoryInfo(t *testing.T) {
553 553
 			Official:      true,
554 554
 		},
555 555
 		"index." + IndexName + "/ubuntu-12.04-base": {
556
-			Index: &IndexInfo{
556
+			Index: &registrytypes.IndexInfo{
557 557
 				Name:     IndexName,
558 558
 				Official: true,
559 559
 			},
... ...
@@ -585,9 +587,9 @@ func TestParseRepositoryInfo(t *testing.T) {
585 585
 }
586 586
 
587 587
 func TestNewIndexInfo(t *testing.T) {
588
-	testIndexInfo := func(config *ServiceConfig, expectedIndexInfos map[string]*IndexInfo) {
588
+	testIndexInfo := func(config *registrytypes.ServiceConfig, expectedIndexInfos map[string]*registrytypes.IndexInfo) {
589 589
 		for indexName, expectedIndexInfo := range expectedIndexInfos {
590
-			index, err := config.NewIndexInfo(indexName)
590
+			index, err := newIndexInfo(config, indexName)
591 591
 			if err != nil {
592 592
 				t.Fatal(err)
593 593
 			} else {
... ...
@@ -601,7 +603,7 @@ func TestNewIndexInfo(t *testing.T) {
601 601
 
602 602
 	config := NewServiceConfig(nil)
603 603
 	noMirrors := []string{}
604
-	expectedIndexInfos := map[string]*IndexInfo{
604
+	expectedIndexInfos := map[string]*registrytypes.IndexInfo{
605 605
 		IndexName: {
606 606
 			Name:     IndexName,
607 607
 			Official: true,
... ...
@@ -632,7 +634,7 @@ func TestNewIndexInfo(t *testing.T) {
632 632
 	publicMirrors := []string{"http://mirror1.local", "http://mirror2.local"}
633 633
 	config = makeServiceConfig(publicMirrors, []string{"example.com"})
634 634
 
635
-	expectedIndexInfos = map[string]*IndexInfo{
635
+	expectedIndexInfos = map[string]*registrytypes.IndexInfo{
636 636
 		IndexName: {
637 637
 			Name:     IndexName,
638 638
 			Official: true,
... ...
@@ -679,7 +681,7 @@ func TestNewIndexInfo(t *testing.T) {
679 679
 	testIndexInfo(config, expectedIndexInfos)
680 680
 
681 681
 	config = makeServiceConfig(nil, []string{"42.42.0.0/16"})
682
-	expectedIndexInfos = map[string]*IndexInfo{
682
+	expectedIndexInfos = map[string]*registrytypes.IndexInfo{
683 683
 		"example.com": {
684 684
 			Name:     "example.com",
685 685
 			Official: false,
... ...
@@ -981,7 +983,7 @@ func TestIsSecureIndex(t *testing.T) {
981 981
 	}
982 982
 	for _, tt := range tests {
983 983
 		config := makeServiceConfig(nil, tt.insecureRegistries)
984
-		if sec := config.isSecureIndex(tt.addr); sec != tt.expected {
984
+		if sec := isSecureIndex(config, tt.addr); sec != tt.expected {
985 985
 			t.Errorf("isSecureIndex failed for %q %v, expected %v got %v", tt.addr, tt.insecureRegistries, tt.expected, sec)
986 986
 		}
987 987
 	}
... ...
@@ -8,12 +8,14 @@ import (
8 8
 
9 9
 	"github.com/docker/distribution/reference"
10 10
 	"github.com/docker/distribution/registry/client/auth"
11
+	"github.com/docker/docker/api/types"
12
+	registrytypes "github.com/docker/docker/api/types/registry"
11 13
 )
12 14
 
13 15
 // Service is a registry service. It tracks configuration data such as a list
14 16
 // of mirrors.
15 17
 type Service struct {
16
-	Config *ServiceConfig
18
+	Config *registrytypes.ServiceConfig
17 19
 }
18 20
 
19 21
 // 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[
78 78
 
79 79
 	indexName, remoteName := splitReposSearchTerm(term)
80 80
 
81
-	index, err := s.Config.NewIndexInfo(indexName)
81
+	index, err := newIndexInfo(s.Config, indexName)
82 82
 	if err != nil {
83 83
 		return nil, err
84 84
 	}
... ...
@@ -109,12 +111,12 @@ func (s *Service) Search(term string, authConfig *types.AuthConfig, headers map[
109 109
 // ResolveRepository splits a repository name into its components
110 110
 // and configuration of the associated registry.
111 111
 func (s *Service) ResolveRepository(name reference.Named) (*RepositoryInfo, error) {
112
-	return s.Config.NewRepositoryInfo(name)
112
+	return newRepositoryInfo(s.Config, name)
113 113
 }
114 114
 
115 115
 // ResolveIndex takes indexName and returns index info
116
-func (s *Service) ResolveIndex(name string) (*IndexInfo, error) {
117
-	return s.Config.NewIndexInfo(name)
116
+func (s *Service) ResolveIndex(name string) (*registrytypes.IndexInfo, error) {
117
+	return newIndexInfo(s.Config, name)
118 118
 }
119 119
 
120 120
 // APIEndpoint represents a remote API endpoint
... ...
@@ -136,7 +138,7 @@ func (e APIEndpoint) ToV1Endpoint(metaHeaders http.Header) (*Endpoint, error) {
136 136
 
137 137
 // TLSConfig constructs a client TLS configuration based on server defaults
138 138
 func (s *Service) TLSConfig(hostname string) (*tls.Config, error) {
139
-	return newTLSConfig(hostname, s.Config.isSecureIndex(hostname))
139
+	return newTLSConfig(hostname, isSecureIndex(s.Config, hostname))
140 140
 }
141 141
 
142 142
 func (s *Service) tlsConfigForMirror(mirror string) (*tls.Config, error) {
... ...
@@ -20,6 +20,7 @@ import (
20 20
 
21 21
 	"github.com/Sirupsen/logrus"
22 22
 	"github.com/docker/distribution/reference"
23
+	"github.com/docker/docker/api/types"
23 24
 	"github.com/docker/docker/pkg/httputils"
24 25
 	"github.com/docker/docker/pkg/ioutils"
25 26
 	"github.com/docker/docker/pkg/stringid"
... ...
@@ -2,6 +2,7 @@ package registry
2 2
 
3 3
 import (
4 4
 	"github.com/docker/distribution/reference"
5
+	registrytypes "github.com/docker/docker/api/types/registry"
5 6
 )
6 7
 
7 8
 // SearchResult describes a search result returned from a registry
... ...
@@ -83,51 +84,10 @@ const (
83 83
 	APIVersion2
84 84
 )
85 85
 
86
-// IndexInfo contains information about a registry
87
-//
88
-// RepositoryInfo Examples:
89
-// {
90
-//   "Index" : {
91
-//     "Name" : "docker.io",
92
-//     "Mirrors" : ["https://registry-2.docker.io/v1/", "https://registry-3.docker.io/v1/"],
93
-//     "Secure" : true,
94
-//     "Official" : true,
95
-//   },
96
-//   "RemoteName" : "library/debian",
97
-//   "LocalName" : "debian",
98
-//   "CanonicalName" : "docker.io/debian"
99
-//   "Official" : true,
100
-// }
101
-//
102
-// {
103
-//   "Index" : {
104
-//     "Name" : "127.0.0.1:5000",
105
-//     "Mirrors" : [],
106
-//     "Secure" : false,
107
-//     "Official" : false,
108
-//   },
109
-//   "RemoteName" : "user/repo",
110
-//   "LocalName" : "127.0.0.1:5000/user/repo",
111
-//   "CanonicalName" : "127.0.0.1:5000/user/repo",
112
-//   "Official" : false,
113
-// }
114
-type IndexInfo struct {
115
-	// Name is the name of the registry, such as "docker.io"
116
-	Name string
117
-	// Mirrors is a list of mirrors, expressed as URIs
118
-	Mirrors []string
119
-	// Secure is set to false if the registry is part of the list of
120
-	// insecure registries. Insecure registries accept HTTP and/or accept
121
-	// HTTPS with certificates from unknown CAs.
122
-	Secure bool
123
-	// Official indicates whether this is an official registry
124
-	Official bool
125
-}
126
-
127 86
 // RepositoryInfo describes a repository
128 87
 type RepositoryInfo struct {
129 88
 	// Index points to registry information
130
-	Index *IndexInfo
89
+	Index *registrytypes.IndexInfo
131 90
 	// RemoteName is the remote name of the repository, such as
132 91
 	// "library/ubuntu-12.04-base"
133 92
 	RemoteName reference.Named