registry: remove unneeded alias for api/types/registry import

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-02-26 19:13:43 +01:00
parent 79aa65c1fa
commit d3c3e2c867
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
9 changed files with 88 additions and 88 deletions

View file

@ -10,7 +10,7 @@ import (
"github.com/docker/distribution/registry/client/auth/challenge"
"github.com/docker/distribution/registry/client/transport"
"github.com/docker/docker/api/types"
registrytypes "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/api/types/registry"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
@ -153,7 +153,7 @@ func ConvertToHostname(url string) string {
}
// ResolveAuthConfig matches an auth configuration to a server address or a URL
func ResolveAuthConfig(authConfigs map[string]types.AuthConfig, index *registrytypes.IndexInfo) types.AuthConfig {
func ResolveAuthConfig(authConfigs map[string]types.AuthConfig, index *registry.IndexInfo) types.AuthConfig {
configKey := GetAuthConfigKey(index)
// First try the happy case
if c, found := authConfigs[configKey]; found || index.Official {

View file

@ -4,15 +4,15 @@ import (
"testing"
"github.com/docker/docker/api/types"
registrytypes "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/api/types/registry"
"gotest.tools/v3/assert"
)
func buildAuthConfigs() map[string]types.AuthConfig {
authConfigs := map[string]types.AuthConfig{}
for _, registry := range []string{"testIndex", IndexServer} {
authConfigs[registry] = types.AuthConfig{
for _, reg := range []string{"testIndex", IndexServer} {
authConfigs[reg] = types.AuthConfig{
Username: "docker-user",
Password: "docker-pass",
}
@ -25,10 +25,10 @@ func TestResolveAuthConfigIndexServer(t *testing.T) {
authConfigs := buildAuthConfigs()
indexConfig := authConfigs[IndexServer]
officialIndex := &registrytypes.IndexInfo{
officialIndex := &registry.IndexInfo{
Official: true,
}
privateIndex := &registrytypes.IndexInfo{
privateIndex := &registry.IndexInfo{
Official: false,
}
@ -88,19 +88,19 @@ func TestResolveAuthConfigFullURL(t *testing.T) {
if !ok {
t.Fail()
}
index := &registrytypes.IndexInfo{
index := &registry.IndexInfo{
Name: configKey,
}
for _, registry := range registries {
authConfigs[registry] = configured
for _, reg := range registries {
authConfigs[reg] = configured
resolved := ResolveAuthConfig(authConfigs, index)
if resolved.Username != configured.Username || resolved.Password != configured.Password {
t.Errorf("%s -> %v != %v\n", registry, resolved, configured)
t.Errorf("%s -> %v != %v\n", reg, resolved, configured)
}
delete(authConfigs, registry)
delete(authConfigs, reg)
resolved = ResolveAuthConfig(authConfigs, index)
if resolved.Username == configured.Username || resolved.Password == configured.Password {
t.Errorf("%s -> %v == %v\n", registry, resolved, configured)
t.Errorf("%s -> %v == %v\n", reg, resolved, configured)
}
}
}

View file

@ -8,7 +8,7 @@ import (
"strings"
"github.com/docker/distribution/reference"
registrytypes "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/api/types/registry"
"github.com/sirupsen/logrus"
)
@ -21,7 +21,7 @@ type ServiceOptions struct {
// serviceConfig holds daemon configuration for the registry service.
type serviceConfig struct {
registrytypes.ServiceConfig
registry.ServiceConfig
}
// TODO(thaJeztah) both the "index.docker.io" and "registry-1.docker.io" domains
@ -66,9 +66,9 @@ var (
// newServiceConfig returns a new instance of ServiceConfig
func newServiceConfig(options ServiceOptions) (*serviceConfig, error) {
config := &serviceConfig{
ServiceConfig: registrytypes.ServiceConfig{
InsecureRegistryCIDRs: make([]*registrytypes.NetIPNet, 0),
IndexConfigs: make(map[string]*registrytypes.IndexInfo),
ServiceConfig: registry.ServiceConfig{
InsecureRegistryCIDRs: make([]*registry.NetIPNet, 0),
IndexConfigs: make(map[string]*registry.IndexInfo),
// Hack: Bypass setting the mirrors to IndexConfigs since they are going away
// and Mirrors are only for the official registry anyways.
},
@ -88,7 +88,7 @@ func newServiceConfig(options ServiceOptions) (*serviceConfig, error) {
// loadAllowNondistributableArtifacts loads allow-nondistributable-artifacts registries into config.
func (config *serviceConfig) loadAllowNondistributableArtifacts(registries []string) error {
cidrs := map[string]*registrytypes.NetIPNet{}
cidrs := map[string]*registry.NetIPNet{}
hostnames := map[string]bool{}
for _, r := range registries {
@ -101,7 +101,7 @@ func (config *serviceConfig) loadAllowNondistributableArtifacts(registries []str
if _, ipnet, err := net.ParseCIDR(r); err == nil {
// Valid CIDR.
cidrs[ipnet.String()] = (*registrytypes.NetIPNet)(ipnet)
cidrs[ipnet.String()] = (*registry.NetIPNet)(ipnet)
} else if err = validateHostPort(r); err == nil {
// Must be `host:port` if not CIDR.
hostnames[r] = true
@ -110,7 +110,7 @@ func (config *serviceConfig) loadAllowNondistributableArtifacts(registries []str
}
}
config.AllowNondistributableArtifactsCIDRs = make([]*(registrytypes.NetIPNet), 0)
config.AllowNondistributableArtifactsCIDRs = make([]*(registry.NetIPNet), 0)
for _, c := range cidrs {
config.AllowNondistributableArtifactsCIDRs = append(config.AllowNondistributableArtifactsCIDRs, c)
}
@ -143,7 +143,7 @@ func (config *serviceConfig) loadMirrors(mirrors []string) error {
config.Mirrors = unique
// Configure public registry since mirrors may have changed.
config.IndexConfigs[IndexName] = &registrytypes.IndexInfo{
config.IndexConfigs[IndexName] = &registry.IndexInfo{
Name: IndexName,
Mirrors: config.Mirrors,
Secure: true,
@ -164,8 +164,8 @@ func (config *serviceConfig) loadInsecureRegistries(registries []string) error {
originalCIDRs := config.ServiceConfig.InsecureRegistryCIDRs
originalIndexInfos := config.ServiceConfig.IndexConfigs
config.ServiceConfig.InsecureRegistryCIDRs = make([]*registrytypes.NetIPNet, 0)
config.ServiceConfig.IndexConfigs = make(map[string]*registrytypes.IndexInfo)
config.ServiceConfig.InsecureRegistryCIDRs = make([]*registry.NetIPNet, 0)
config.ServiceConfig.IndexConfigs = make(map[string]*registry.IndexInfo)
skip:
for _, r := range registries {
@ -193,7 +193,7 @@ skip:
_, ipnet, err := net.ParseCIDR(r)
if err == nil {
// Valid CIDR. If ipnet is already in config.InsecureRegistryCIDRs, skip.
data := (*registrytypes.NetIPNet)(ipnet)
data := (*registry.NetIPNet)(ipnet)
for _, value := range config.InsecureRegistryCIDRs {
if value.IP.String() == data.IP.String() && value.Mask.String() == data.Mask.String() {
continue skip
@ -209,7 +209,7 @@ skip:
return invalidParamWrapf(err, "insecure registry %s is not valid", r)
}
// Assume `host:port` if not CIDR.
config.IndexConfigs[r] = &registrytypes.IndexInfo{
config.IndexConfigs[r] = &registry.IndexInfo{
Name: r,
Mirrors: make([]string, 0),
Secure: false,
@ -219,7 +219,7 @@ skip:
}
// Configure public registry.
config.IndexConfigs[IndexName] = &registrytypes.IndexInfo{
config.IndexConfigs[IndexName] = &registry.IndexInfo{
Name: IndexName,
Mirrors: config.Mirrors,
Secure: true,
@ -272,7 +272,7 @@ func isSecureIndex(config *serviceConfig, indexName string) bool {
// isCIDRMatch returns true if URLHost matches an element of cidrs. URLHost is a URL.Host (`host:port` or `host`)
// where the `host` part can be either a domain name or an IP address. If it is a domain name, then it will be
// resolved to IP addresses for matching. If resolution fails, false is returned.
func isCIDRMatch(cidrs []*registrytypes.NetIPNet, URLHost string) bool {
func isCIDRMatch(cidrs []*registry.NetIPNet, URLHost string) bool {
host, _, err := net.SplitHostPort(URLHost)
if err != nil {
// Assume URLHost is of the form `host` without the port and go on.
@ -365,7 +365,7 @@ func validateHostPort(s string) error {
}
// newIndexInfo returns IndexInfo configuration from indexName
func newIndexInfo(config *serviceConfig, indexName string) (*registrytypes.IndexInfo, error) {
func newIndexInfo(config *serviceConfig, indexName string) (*registry.IndexInfo, error) {
var err error
indexName, err = ValidateIndexName(indexName)
if err != nil {
@ -378,7 +378,7 @@ func newIndexInfo(config *serviceConfig, indexName string) (*registrytypes.Index
}
// Construct a non-configured index info.
index := &registrytypes.IndexInfo{
index := &registry.IndexInfo{
Name: indexName,
Mirrors: make([]string, 0),
Official: false,
@ -389,7 +389,7 @@ func newIndexInfo(config *serviceConfig, indexName string) (*registrytypes.Index
// 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 GetAuthConfigKey(index *registrytypes.IndexInfo) string {
func GetAuthConfigKey(index *registry.IndexInfo) string {
if index.Official {
return IndexServer
}
@ -423,7 +423,7 @@ func ParseRepositoryInfo(reposName reference.Named) (*RepositoryInfo, error) {
// information of the registry (to provide credentials if needed). We should
// move this function (or equivalent) to the CLI, as it's doing too much just
// for that.
func ParseSearchIndexInfo(reposName string) (*registrytypes.IndexInfo, error) {
func ParseSearchIndexInfo(reposName string) (*registry.IndexInfo, error) {
indexName, _ := splitReposSearchTerm(reposName)
indexInfo, err := newIndexInfo(emptyServiceConfig, indexName)

View file

@ -9,7 +9,7 @@ import (
"strings"
"github.com/docker/distribution/registry/client/transport"
registrytypes "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/api/types/registry"
"github.com/sirupsen/logrus"
)
@ -35,7 +35,7 @@ type v1Endpoint struct {
// newV1Endpoint parses the given address to return a registry endpoint.
// TODO: remove. This is only used by search.
func newV1Endpoint(index *registrytypes.IndexInfo, userAgent string, metaHeaders http.Header) (*v1Endpoint, error) {
func newV1Endpoint(index *registry.IndexInfo, userAgent string, metaHeaders http.Header) (*v1Endpoint, error) {
tlsConfig, err := newTLSConfig(index.Name, index.Secure)
if err != nil {
return nil, err

View file

@ -9,7 +9,7 @@ import (
"net/http/httptest"
"testing"
registrytypes "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/api/types/registry"
"github.com/gorilla/mux"
"github.com/sirupsen/logrus"
"gotest.tools/v3/assert"
@ -75,22 +75,22 @@ func makeHTTPSURL(req string) string {
return testHTTPSServer.URL + req
}
func makeIndex(req string) *registrytypes.IndexInfo {
index := &registrytypes.IndexInfo{
func makeIndex(req string) *registry.IndexInfo {
index := &registry.IndexInfo{
Name: makeURL(req),
}
return index
}
func makeHTTPSIndex(req string) *registrytypes.IndexInfo {
index := &registrytypes.IndexInfo{
func makeHTTPSIndex(req string) *registry.IndexInfo {
index := &registry.IndexInfo{
Name: makeHTTPSURL(req),
}
return index
}
func makePublicIndex() *registrytypes.IndexInfo {
index := &registrytypes.IndexInfo{
func makePublicIndex() *registry.IndexInfo {
index := &registry.IndexInfo{
Name: IndexServer,
Secure: true,
Official: true,
@ -134,10 +134,10 @@ func handlerGetPing(w http.ResponseWriter, r *http.Request) {
}
func handlerSearch(w http.ResponseWriter, r *http.Request) {
result := &registrytypes.SearchResults{
result := &registry.SearchResults{
Query: "fakequery",
NumResults: 1,
Results: []registrytypes.SearchResult{{Name: "fakeimage", StarCount: 42}},
Results: []registry.SearchResult{{Name: "fakeimage", StarCount: 42}},
}
writeResponse(w, result, http.StatusOK)
}

View file

@ -10,7 +10,7 @@ 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"
"github.com/docker/docker/api/types/registry"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/skip"
@ -48,7 +48,7 @@ func spawnTestRegistrySession(t *testing.T) *session {
func TestPingRegistryEndpoint(t *testing.T) {
skip.If(t, os.Getuid() != 0, "skipping test that requires root")
testPing := func(index *registrytypes.IndexInfo, expectedStandalone bool, assertMessage string) {
testPing := func(index *registry.IndexInfo, expectedStandalone bool, assertMessage string) {
ep, err := newV1Endpoint(index, "", nil)
if err != nil {
t.Fatal(err)
@ -69,7 +69,7 @@ func TestPingRegistryEndpoint(t *testing.T) {
func TestEndpoint(t *testing.T) {
skip.If(t, os.Getuid() != 0, "skipping test that requires root")
// Simple wrapper to fail test if err != nil
expandEndpoint := func(index *registrytypes.IndexInfo) *v1Endpoint {
expandEndpoint := func(index *registry.IndexInfo) *v1Endpoint {
endpoint, err := newV1Endpoint(index, "", nil)
if err != nil {
t.Fatal(err)
@ -77,21 +77,21 @@ func TestEndpoint(t *testing.T) {
return endpoint
}
assertInsecureIndex := func(index *registrytypes.IndexInfo) {
assertInsecureIndex := func(index *registry.IndexInfo) {
index.Secure = true
_, err := newV1Endpoint(index, "", nil)
assert.ErrorContains(t, err, "insecure-registry", index.Name+": Expected insecure-registry error for insecure index")
index.Secure = false
}
assertSecureIndex := func(index *registrytypes.IndexInfo) {
assertSecureIndex := func(index *registry.IndexInfo) {
index.Secure = true
_, err := newV1Endpoint(index, "", nil)
assert.ErrorContains(t, err, "certificate signed by unknown authority", index.Name+": Expected cert error for secure index")
index.Secure = false
}
index := &registrytypes.IndexInfo{}
index := &registry.IndexInfo{}
index.Name = makeURL("/v1/")
endpoint := expandEndpoint(index)
assert.Equal(t, endpoint.String(), index.Name, "Expected endpoint to be "+index.Name)
@ -140,7 +140,7 @@ func TestEndpoint(t *testing.T) {
func TestParseRepositoryInfo(t *testing.T) {
type staticRepositoryInfo struct {
Index *registrytypes.IndexInfo
Index *registry.IndexInfo
RemoteName string
CanonicalName string
LocalName string
@ -149,7 +149,7 @@ func TestParseRepositoryInfo(t *testing.T) {
expectedRepoInfos := map[string]staticRepositoryInfo{
"fooo/bar": {
Index: &registrytypes.IndexInfo{
Index: &registry.IndexInfo{
Name: IndexName,
Official: true,
},
@ -159,7 +159,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"library/ubuntu": {
Index: &registrytypes.IndexInfo{
Index: &registry.IndexInfo{
Name: IndexName,
Official: true,
},
@ -169,7 +169,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: true,
},
"nonlibrary/ubuntu": {
Index: &registrytypes.IndexInfo{
Index: &registry.IndexInfo{
Name: IndexName,
Official: true,
},
@ -179,7 +179,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"ubuntu": {
Index: &registrytypes.IndexInfo{
Index: &registry.IndexInfo{
Name: IndexName,
Official: true,
},
@ -189,7 +189,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: true,
},
"other/library": {
Index: &registrytypes.IndexInfo{
Index: &registry.IndexInfo{
Name: IndexName,
Official: true,
},
@ -199,7 +199,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"127.0.0.1:8000/private/moonbase": {
Index: &registrytypes.IndexInfo{
Index: &registry.IndexInfo{
Name: "127.0.0.1:8000",
Official: false,
},
@ -209,7 +209,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"127.0.0.1:8000/privatebase": {
Index: &registrytypes.IndexInfo{
Index: &registry.IndexInfo{
Name: "127.0.0.1:8000",
Official: false,
},
@ -219,7 +219,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"localhost:8000/private/moonbase": {
Index: &registrytypes.IndexInfo{
Index: &registry.IndexInfo{
Name: "localhost:8000",
Official: false,
},
@ -229,7 +229,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"localhost:8000/privatebase": {
Index: &registrytypes.IndexInfo{
Index: &registry.IndexInfo{
Name: "localhost:8000",
Official: false,
},
@ -239,7 +239,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"example.com/private/moonbase": {
Index: &registrytypes.IndexInfo{
Index: &registry.IndexInfo{
Name: "example.com",
Official: false,
},
@ -249,7 +249,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"example.com/privatebase": {
Index: &registrytypes.IndexInfo{
Index: &registry.IndexInfo{
Name: "example.com",
Official: false,
},
@ -259,7 +259,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"example.com:8000/private/moonbase": {
Index: &registrytypes.IndexInfo{
Index: &registry.IndexInfo{
Name: "example.com:8000",
Official: false,
},
@ -269,7 +269,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"example.com:8000/privatebase": {
Index: &registrytypes.IndexInfo{
Index: &registry.IndexInfo{
Name: "example.com:8000",
Official: false,
},
@ -279,7 +279,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"localhost/private/moonbase": {
Index: &registrytypes.IndexInfo{
Index: &registry.IndexInfo{
Name: "localhost",
Official: false,
},
@ -289,7 +289,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"localhost/privatebase": {
Index: &registrytypes.IndexInfo{
Index: &registry.IndexInfo{
Name: "localhost",
Official: false,
},
@ -299,7 +299,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
IndexName + "/public/moonbase": {
Index: &registrytypes.IndexInfo{
Index: &registry.IndexInfo{
Name: IndexName,
Official: true,
},
@ -309,7 +309,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"index." + IndexName + "/public/moonbase": {
Index: &registrytypes.IndexInfo{
Index: &registry.IndexInfo{
Name: IndexName,
Official: true,
},
@ -319,7 +319,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: false,
},
"ubuntu-12.04-base": {
Index: &registrytypes.IndexInfo{
Index: &registry.IndexInfo{
Name: IndexName,
Official: true,
},
@ -329,7 +329,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: true,
},
IndexName + "/ubuntu-12.04-base": {
Index: &registrytypes.IndexInfo{
Index: &registry.IndexInfo{
Name: IndexName,
Official: true,
},
@ -339,7 +339,7 @@ func TestParseRepositoryInfo(t *testing.T) {
Official: true,
},
"index." + IndexName + "/ubuntu-12.04-base": {
Index: &registrytypes.IndexInfo{
Index: &registry.IndexInfo{
Name: IndexName,
Official: true,
},
@ -371,7 +371,7 @@ func TestParseRepositoryInfo(t *testing.T) {
}
func TestNewIndexInfo(t *testing.T) {
testIndexInfo := func(config *serviceConfig, expectedIndexInfos map[string]*registrytypes.IndexInfo) {
testIndexInfo := func(config *serviceConfig, expectedIndexInfos map[string]*registry.IndexInfo) {
for indexName, expectedIndexInfo := range expectedIndexInfos {
index, err := newIndexInfo(config, indexName)
if err != nil {
@ -387,7 +387,7 @@ func TestNewIndexInfo(t *testing.T) {
config := emptyServiceConfig
var noMirrors []string
expectedIndexInfos := map[string]*registrytypes.IndexInfo{
expectedIndexInfos := map[string]*registry.IndexInfo{
IndexName: {
Name: IndexName,
Official: true,
@ -422,7 +422,7 @@ func TestNewIndexInfo(t *testing.T) {
t.Fatal(err)
}
expectedIndexInfos = map[string]*registrytypes.IndexInfo{
expectedIndexInfos = map[string]*registry.IndexInfo{
IndexName: {
Name: IndexName,
Official: true,
@ -472,7 +472,7 @@ func TestNewIndexInfo(t *testing.T) {
if err != nil {
t.Fatal(err)
}
expectedIndexInfos = map[string]*registrytypes.IndexInfo{
expectedIndexInfos = map[string]*registry.IndexInfo{
"example.com": {
Name: "example.com",
Official: false,

View file

@ -11,7 +11,7 @@ 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"
"github.com/docker/docker/api/types/registry"
"github.com/docker/docker/errdefs"
"github.com/sirupsen/logrus"
)
@ -27,8 +27,8 @@ type Service interface {
LookupPullEndpoints(hostname string) (endpoints []APIEndpoint, err error)
LookupPushEndpoints(hostname string) (endpoints []APIEndpoint, err error)
ResolveRepository(name reference.Named) (*RepositoryInfo, error)
Search(ctx context.Context, term string, limit int, authConfig *types.AuthConfig, userAgent string, headers map[string][]string) (*registrytypes.SearchResults, error)
ServiceConfig() *registrytypes.ServiceConfig
Search(ctx context.Context, term string, limit int, authConfig *types.AuthConfig, userAgent string, headers map[string][]string) (*registry.SearchResults, error)
ServiceConfig() *registry.ServiceConfig
TLSConfig(hostname string) (*tls.Config, error)
LoadAllowNondistributableArtifacts([]string) error
LoadMirrors([]string) error
@ -51,15 +51,15 @@ func NewService(options ServiceOptions) (Service, error) {
}
// ServiceConfig returns the public registry service configuration.
func (s *defaultService) ServiceConfig() *registrytypes.ServiceConfig {
func (s *defaultService) ServiceConfig() *registry.ServiceConfig {
s.mu.Lock()
defer s.mu.Unlock()
servConfig := registrytypes.ServiceConfig{
AllowNondistributableArtifactsCIDRs: make([]*(registrytypes.NetIPNet), 0),
servConfig := registry.ServiceConfig{
AllowNondistributableArtifactsCIDRs: make([]*(registry.NetIPNet), 0),
AllowNondistributableArtifactsHostnames: make([]string, 0),
InsecureRegistryCIDRs: make([]*(registrytypes.NetIPNet), 0),
IndexConfigs: make(map[string]*(registrytypes.IndexInfo)),
InsecureRegistryCIDRs: make([]*(registry.NetIPNet), 0),
IndexConfigs: make(map[string]*(registry.IndexInfo)),
Mirrors: make([]string, 0),
}
@ -158,7 +158,7 @@ func splitReposSearchTerm(reposName string) (string, string) {
// Search queries the public registry for images matching the specified
// search terms, and returns the results.
func (s *defaultService) Search(ctx context.Context, term string, limit int, authConfig *types.AuthConfig, userAgent string, headers map[string][]string) (*registrytypes.SearchResults, error) {
func (s *defaultService) Search(ctx context.Context, term string, limit int, authConfig *types.AuthConfig, userAgent string, headers map[string][]string) (*registry.SearchResults, error) {
// TODO Use ctx when searching for repositories
if hasScheme(term) {
return nil, invalidParamf("invalid repository name: repository name (%s) should not have a scheme", term)

View file

@ -12,7 +12,7 @@ import (
"sync"
"github.com/docker/docker/api/types"
registrytypes "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/api/types/registry"
"github.com/docker/docker/errdefs"
"github.com/docker/docker/pkg/ioutils"
"github.com/docker/docker/pkg/jsonmessage"
@ -185,7 +185,7 @@ func newSession(client *http.Client, endpoint *v1Endpoint) *session {
}
// searchRepositories performs a search against the remote repository
func (r *session) searchRepositories(term string, limit int) (*registrytypes.SearchResults, error) {
func (r *session) searchRepositories(term string, limit int) (*registry.SearchResults, error) {
if limit < 1 || limit > 100 {
return nil, invalidParamf("limit %d is outside the range of [1, 100]", limit)
}
@ -209,6 +209,6 @@ func (r *session) searchRepositories(term string, limit int) (*registrytypes.Sea
Code: res.StatusCode,
}
}
result := new(registrytypes.SearchResults)
result := new(registry.SearchResults)
return result, errors.Wrap(json.NewDecoder(res.Body).Decode(result), "error decoding registry search results")
}

View file

@ -2,7 +2,7 @@ package registry // import "github.com/docker/docker/registry"
import (
"github.com/docker/distribution/reference"
registrytypes "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/api/types/registry"
)
// APIVersion is an integral representation of an API version (presently
@ -28,7 +28,7 @@ var apiVersions = map[APIVersion]string{
type RepositoryInfo struct {
Name reference.Named
// Index points to registry information
Index *registrytypes.IndexInfo
Index *registry.IndexInfo
// Official indicates whether the repository is considered official.
// If the registry is official, and the normalized name does not
// contain a '/' (e.g. "foo"), then it is considered an official repo.