-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathregistry.go
51 lines (42 loc) · 1.24 KB
/
registry.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package supermiddleware
import (
"github.com/docker/distribution"
"github.com/docker/distribution/context"
"github.com/docker/distribution/reference"
"github.com/docker/distribution/registry/storage"
storagedriver "github.com/docker/distribution/registry/storage/driver"
)
type registry struct {
distribution.Namespace
inst *instance
}
func (reg *registry) Repository(ctx context.Context, named reference.Named) (distribution.Repository, error) {
repo, err := reg.Namespace.Repository(ctx, named)
if err != nil {
return repo, err
}
return reg.inst.Repository(ctx, repo, false)
}
// NewRegistry constructs a registry object that uses app middlewares.
func NewRegistry(ctx context.Context, app App, driver storagedriver.StorageDriver, options ...storage.RegistryOption) (distribution.Namespace, error) {
options = append(options, storage.BlobDescriptorServiceFactory(&blobDescriptorServiceFactory{}))
inst := &instance{
App: app,
}
driver, err := inst.Storage(driver, nil)
if err != nil {
return nil, err
}
reg, err := storage.NewRegistry(ctx, driver, options...)
if err != nil {
return reg, err
}
reg, err = inst.Registry(reg, nil)
if err != nil {
return reg, err
}
return ®istry{
Namespace: reg,
inst: inst,
}, nil
}