Middleware!

Convert middleware in the config to be a map of type->[]Middleware

Add support for registry & repository middleware.

Some naming updates as well.

Signed-off-by: Andy Goldstein <agoldste@redhat.com>
This commit is contained in:
Andy Goldstein 2015-03-06 10:45:16 -05:00 committed by David Lawrence
parent 952f39edff
commit 30bcc17b85
5 changed files with 107 additions and 21 deletions

View file

@ -12,9 +12,9 @@ type InitFunc func(storageDriver storagedriver.StorageDriver, options map[string
var storageMiddlewares map[string]InitFunc
// RegisterStorageMiddleware is used to register an StorageMiddlewareInitFunc for
// Register is used to register an InitFunc for
// a StorageMiddleware backend with the given name.
func RegisterStorageMiddleware(name string, initFunc InitFunc) error {
func Register(name string, initFunc InitFunc) error {
if storageMiddlewares == nil {
storageMiddlewares = make(map[string]InitFunc)
}
@ -27,9 +27,8 @@ func RegisterStorageMiddleware(name string, initFunc InitFunc) error {
return nil
}
// GetStorageMiddleware constructs a StorageMiddleware
// with the given options using the named backend.
func GetStorageMiddleware(name string, options map[string]interface{}, storageDriver storagedriver.StorageDriver) (storagedriver.StorageDriver, error) {
// Get constructs a StorageMiddleware with the given options using the named backend.
func Get(name string, options map[string]interface{}, storageDriver storagedriver.StorageDriver) (storagedriver.StorageDriver, error) {
if storageMiddlewares != nil {
if initFunc, exists := storageMiddlewares[name]; exists {
return initFunc(storageDriver, options)