From 0f08b6961af9103f9273b116230a575634baec5f Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Tue, 10 Feb 2015 17:25:40 -0800 Subject: [PATCH] Move registry package into handler package The goal is to free up the distribution/registry package to include common registry types. This moves the webapp definitions out of the way to allow for this change in the future. Signed-off-by: Stephen J Day --- cmd/registry/main.go | 10 +++++----- registry/doc.go | 3 +++ registry/{ => handlers}/api_test.go | 2 +- registry/{ => handlers}/app.go | 2 +- registry/{ => handlers}/app_test.go | 2 +- registry/{ => handlers}/basicauth.go | 2 +- registry/{ => handlers}/basicauth_prego14.go | 2 +- registry/{ => handlers}/context.go | 2 +- registry/{ => handlers}/helpers.go | 2 +- registry/{ => handlers}/hmac.go | 2 +- registry/{ => handlers}/hmac_test.go | 2 +- registry/{ => handlers}/images.go | 2 +- registry/{ => handlers}/layer.go | 2 +- registry/{ => handlers}/layerupload.go | 2 +- registry/{ => handlers}/tags.go | 2 +- 15 files changed, 21 insertions(+), 18 deletions(-) create mode 100644 registry/doc.go rename registry/{ => handlers}/api_test.go (99%) rename registry/{ => handlers}/app.go (99%) rename registry/{ => handlers}/app_test.go (99%) rename registry/{ => handlers}/basicauth.go (88%) rename registry/{ => handlers}/basicauth_prego14.go (98%) rename registry/{ => handlers}/context.go (99%) rename registry/{ => handlers}/helpers.go (97%) rename registry/{ => handlers}/hmac.go (99%) rename registry/{ => handlers}/hmac_test.go (99%) rename registry/{ => handlers}/images.go (99%) rename registry/{ => handlers}/layer.go (99%) rename registry/{ => handlers}/layerupload.go (99%) rename registry/{ => handlers}/tags.go (98%) diff --git a/cmd/registry/main.go b/cmd/registry/main.go index 0ed8fcd2..1c399617 100644 --- a/cmd/registry/main.go +++ b/cmd/registry/main.go @@ -14,12 +14,12 @@ import ( _ "github.com/docker/distribution/auth/token" "github.com/docker/distribution/configuration" ctxu "github.com/docker/distribution/context" - "github.com/docker/distribution/registry" + "github.com/docker/distribution/registry/handlers" _ "github.com/docker/distribution/storagedriver/filesystem" _ "github.com/docker/distribution/storagedriver/inmemory" _ "github.com/docker/distribution/storagedriver/s3" "github.com/docker/distribution/version" - "github.com/gorilla/handlers" + gorhandlers "github.com/gorilla/handlers" "github.com/yvasiyarov/gorelic" "golang.org/x/net/context" ) @@ -50,9 +50,9 @@ func main() { ctx = context.WithValue(ctx, "version", version.Version) ctx = ctxu.WithLogger(ctx, ctxu.GetLogger(ctx, "version")) - app := registry.NewApp(ctx, *config) + app := handlers.NewApp(ctx, *config) handler := configureReporting(app) - handler = handlers.CombinedLoggingHandler(os.Stdout, handler) + handler = gorhandlers.CombinedLoggingHandler(os.Stdout, handler) if config.HTTP.Debug.Addr != "" { go debugServer(config.HTTP.Debug.Addr) @@ -118,7 +118,7 @@ func logLevel(level configuration.Loglevel) log.Level { return l } -func configureReporting(app *registry.App) http.Handler { +func configureReporting(app *handlers.App) http.Handler { var handler http.Handler = app if app.Config.Reporting.Bugsnag.APIKey != "" { diff --git a/registry/doc.go b/registry/doc.go new file mode 100644 index 00000000..5049dae3 --- /dev/null +++ b/registry/doc.go @@ -0,0 +1,3 @@ +// Package registry is a placeholder package for registry interface +// destinations and utilities. +package registry diff --git a/registry/api_test.go b/registry/handlers/api_test.go similarity index 99% rename from registry/api_test.go rename to registry/handlers/api_test.go index 5e3bd72c..1d1173a9 100644 --- a/registry/api_test.go +++ b/registry/handlers/api_test.go @@ -1,4 +1,4 @@ -package registry +package handlers import ( "bytes" diff --git a/registry/app.go b/registry/handlers/app.go similarity index 99% rename from registry/app.go rename to registry/handlers/app.go index 817373f2..e49144e2 100644 --- a/registry/app.go +++ b/registry/handlers/app.go @@ -1,4 +1,4 @@ -package registry +package handlers import ( "fmt" diff --git a/registry/app_test.go b/registry/handlers/app_test.go similarity index 99% rename from registry/app_test.go rename to registry/handlers/app_test.go index 9b106575..927f40a4 100644 --- a/registry/app_test.go +++ b/registry/handlers/app_test.go @@ -1,4 +1,4 @@ -package registry +package handlers import ( "encoding/json" diff --git a/registry/basicauth.go b/registry/handlers/basicauth.go similarity index 88% rename from registry/basicauth.go rename to registry/handlers/basicauth.go index 55794ee3..8727a3cd 100644 --- a/registry/basicauth.go +++ b/registry/handlers/basicauth.go @@ -1,6 +1,6 @@ // +build go1.4 -package registry +package handlers import ( "net/http" diff --git a/registry/basicauth_prego14.go b/registry/handlers/basicauth_prego14.go similarity index 98% rename from registry/basicauth_prego14.go rename to registry/handlers/basicauth_prego14.go index dc563135..6cf10a25 100644 --- a/registry/basicauth_prego14.go +++ b/registry/handlers/basicauth_prego14.go @@ -1,6 +1,6 @@ // +build !go1.4 -package registry +package handlers import ( "encoding/base64" diff --git a/registry/context.go b/registry/handlers/context.go similarity index 99% rename from registry/context.go rename to registry/handlers/context.go index 7c4dbb02..8f277595 100644 --- a/registry/context.go +++ b/registry/handlers/context.go @@ -1,4 +1,4 @@ -package registry +package handlers import ( "fmt" diff --git a/registry/helpers.go b/registry/handlers/helpers.go similarity index 97% rename from registry/helpers.go rename to registry/handlers/helpers.go index 6bcb4ae8..f2879137 100644 --- a/registry/helpers.go +++ b/registry/handlers/helpers.go @@ -1,4 +1,4 @@ -package registry +package handlers import ( "encoding/json" diff --git a/registry/hmac.go b/registry/handlers/hmac.go similarity index 99% rename from registry/hmac.go rename to registry/handlers/hmac.go index d2470087..e17ececa 100644 --- a/registry/hmac.go +++ b/registry/handlers/hmac.go @@ -1,4 +1,4 @@ -package registry +package handlers import ( "crypto/hmac" diff --git a/registry/hmac_test.go b/registry/handlers/hmac_test.go similarity index 99% rename from registry/hmac_test.go rename to registry/handlers/hmac_test.go index 5ad60f61..cce2cd49 100644 --- a/registry/hmac_test.go +++ b/registry/handlers/hmac_test.go @@ -1,4 +1,4 @@ -package registry +package handlers import "testing" diff --git a/registry/images.go b/registry/handlers/images.go similarity index 99% rename from registry/images.go rename to registry/handlers/images.go index c44b0b21..c26a2239 100644 --- a/registry/images.go +++ b/registry/handlers/images.go @@ -1,4 +1,4 @@ -package registry +package handlers import ( "encoding/json" diff --git a/registry/layer.go b/registry/handlers/layer.go similarity index 99% rename from registry/layer.go rename to registry/handlers/layer.go index 10569465..31d24b86 100644 --- a/registry/layer.go +++ b/registry/handlers/layer.go @@ -1,4 +1,4 @@ -package registry +package handlers import ( "net/http" diff --git a/registry/layerupload.go b/registry/handlers/layerupload.go similarity index 99% rename from registry/layerupload.go rename to registry/handlers/layerupload.go index f30bb3aa..a15e274a 100644 --- a/registry/layerupload.go +++ b/registry/handlers/layerupload.go @@ -1,4 +1,4 @@ -package registry +package handlers import ( "fmt" diff --git a/registry/tags.go b/registry/handlers/tags.go similarity index 98% rename from registry/tags.go rename to registry/handlers/tags.go index 1f745c6a..65ffacfc 100644 --- a/registry/tags.go +++ b/registry/handlers/tags.go @@ -1,4 +1,4 @@ -package registry +package handlers import ( "encoding/json"