From 6f83ba2b29f820966a60bf316f18614a3fa7c5ea Mon Sep 17 00:00:00 2001 From: Tibor Vass Date: Fri, 24 Jul 2015 14:59:36 -0400 Subject: [PATCH] registry: Change default endpoint on windows to a windows-specific one Signed-off-by: Tibor Vass --- docs/config.go | 22 ---------------------- docs/consts.go | 24 ++++++++++++++++++++++++ docs/consts_unix.go | 6 ++++++ docs/consts_windows.go | 10 ++++++++++ docs/registry.go | 1 + docs/service.go | 19 +++++++++++-------- 6 files changed, 52 insertions(+), 30 deletions(-) create mode 100644 docs/consts.go create mode 100644 docs/consts_unix.go create mode 100644 docs/consts_windows.go diff --git a/docs/config.go b/docs/config.go index 95f731298..dc1ee899b 100644 --- a/docs/config.go +++ b/docs/config.go @@ -20,28 +20,6 @@ type Options struct { InsecureRegistries opts.ListOpts } -const ( - // DefaultNamespace is the default namespace - DefaultNamespace = "docker.io" - // DefaultV2Registry is the URI of the default v2 registry - DefaultV2Registry = "https://registry-1.docker.io" - // DefaultRegistryVersionHeader is the name of the default HTTP header - // that carries Registry version info - DefaultRegistryVersionHeader = "Docker-Distribution-Api-Version" - // DefaultV1Registry is the URI of the default v1 registry - DefaultV1Registry = "https://index.docker.io" - - // CertsDir is the directory where certificates are stored - CertsDir = "/etc/docker/certs.d" - - // IndexServer is the v1 registry server used for user auth + account creation - IndexServer = DefaultV1Registry + "/v1/" - // IndexName is the name of the index - IndexName = "docker.io" - // NotaryServer is the endpoint serving the Notary trust server - NotaryServer = "https://notary.docker.io" -) - var ( // ErrInvalidRepositoryName is an error returned if the repository name did // not have the correct form diff --git a/docs/consts.go b/docs/consts.go new file mode 100644 index 000000000..19471e060 --- /dev/null +++ b/docs/consts.go @@ -0,0 +1,24 @@ +package registry + +const ( + // DefaultNamespace is the default namespace + DefaultNamespace = "docker.io" + // DefaultRegistryVersionHeader is the name of the default HTTP header + // that carries Registry version info + DefaultRegistryVersionHeader = "Docker-Distribution-Api-Version" + // DefaultV1Registry is the URI of the default v1 registry + DefaultV1Registry = "https://index.docker.io" + + // CertsDir is the directory where certificates are stored + CertsDir = "/etc/docker/certs.d" + + // IndexServer is the v1 registry server used for user auth + account creation + IndexServer = DefaultV1Registry + "/v1/" + // IndexName is the name of the index + IndexName = "docker.io" + + // NotaryServer is the endpoint serving the Notary trust server + NotaryServer = "https://notary.docker.io" + + // IndexServer = "https://registry-stage.hub.docker.com/v1/" +) diff --git a/docs/consts_unix.go b/docs/consts_unix.go new file mode 100644 index 000000000..b02e579a1 --- /dev/null +++ b/docs/consts_unix.go @@ -0,0 +1,6 @@ +// +build !windows + +package registry + +// DefaultV2Registry is the URI of the default v2 registry +const DefaultV2Registry = "https://registry-1.docker.io" diff --git a/docs/consts_windows.go b/docs/consts_windows.go new file mode 100644 index 000000000..b62c5faf1 --- /dev/null +++ b/docs/consts_windows.go @@ -0,0 +1,10 @@ +// +build windows + +package registry + +// DefaultV2Registry is the URI of the default (official) v2 registry. +// This is the windows-specific endpoint. +// +// Currently it is a TEMPORARY link that allows Microsoft to continue +// development of Docker Engine for Windows. +const DefaultV2Registry = "https://ms-tp3.registry-1.docker.io" diff --git a/docs/registry.go b/docs/registry.go index 74f731bdc..e353d3cce 100644 --- a/docs/registry.go +++ b/docs/registry.go @@ -1,3 +1,4 @@ +// Package registry contains client primitives to interact with a remote Docker registry. package registry import ( diff --git a/docs/service.go b/docs/service.go index f4ea42ef9..0cceb23d4 100644 --- a/docs/service.go +++ b/docs/service.go @@ -5,6 +5,7 @@ import ( "fmt" "net/http" "net/url" + "runtime" "strings" "github.com/docker/distribution/registry/client/auth" @@ -138,14 +139,16 @@ func (s *Service) LookupEndpoints(repoName string) (endpoints []APIEndpoint, err TrimHostname: true, TLSConfig: tlsConfig, }) - // v1 registry - endpoints = append(endpoints, APIEndpoint{ - URL: DefaultV1Registry, - Version: APIVersion1, - Official: true, - TrimHostname: true, - TLSConfig: tlsConfig, - }) + if runtime.GOOS == "linux" { // do not inherit legacy API for OSes supported in the future + // v1 registry + endpoints = append(endpoints, APIEndpoint{ + URL: DefaultV1Registry, + Version: APIVersion1, + Official: true, + TrimHostname: true, + TLSConfig: tlsConfig, + }) + } return endpoints, nil }