mirror of
https://github.com/distribution/distribution.git
synced 2025-09-17 15:50:20 +00:00
Add registry middleware access to storage drivers
Signed-off-by: David Wu <dwu7401@gmail.com>
This commit is contained in:
@@ -6,11 +6,12 @@ import (
|
||||
|
||||
"github.com/distribution/distribution/v3"
|
||||
"github.com/distribution/distribution/v3/registry/storage"
|
||||
storagedriver "github.com/distribution/distribution/v3/registry/storage/driver"
|
||||
)
|
||||
|
||||
// InitFunc is the type of a RegistryMiddleware factory function and is
|
||||
// used to register the constructor for different RegistryMiddleware backends.
|
||||
type InitFunc func(ctx context.Context, registry distribution.Namespace, options map[string]interface{}) (distribution.Namespace, error)
|
||||
type InitFunc func(ctx context.Context, registry distribution.Namespace, driver storagedriver.StorageDriver, options map[string]interface{}) (distribution.Namespace, error)
|
||||
|
||||
var middlewares map[string]InitFunc
|
||||
var registryoptions []storage.RegistryOption
|
||||
@@ -31,10 +32,10 @@ func Register(name string, initFunc InitFunc) error {
|
||||
}
|
||||
|
||||
// Get constructs a RegistryMiddleware with the given options using the named backend.
|
||||
func Get(ctx context.Context, name string, options map[string]interface{}, registry distribution.Namespace) (distribution.Namespace, error) {
|
||||
func Get(ctx context.Context, name string, options map[string]interface{}, registry distribution.Namespace, driver storagedriver.StorageDriver) (distribution.Namespace, error) {
|
||||
if middlewares != nil {
|
||||
if initFunc, exists := middlewares[name]; exists {
|
||||
return initFunc(ctx, registry, options)
|
||||
return initFunc(ctx, registry, driver, options)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user