github.com/mika/distribution@v2.2.2-0.20160108133430-a75790e3d8e0+incompatible/registry.go (about) 1 package distribution 2 3 import ( 4 "github.com/docker/distribution/context" 5 ) 6 7 // Scope defines the set of items that match a namespace. 8 type Scope interface { 9 // Contains returns true if the name belongs to the namespace. 10 Contains(name string) bool 11 } 12 13 type fullScope struct{} 14 15 func (f fullScope) Contains(string) bool { 16 return true 17 } 18 19 // GlobalScope represents the full namespace scope which contains 20 // all other scopes. 21 var GlobalScope = Scope(fullScope{}) 22 23 // Namespace represents a collection of repositories, addressable by name. 24 // Generally, a namespace is backed by a set of one or more services, 25 // providing facilities such as registry access, trust, and indexing. 26 type Namespace interface { 27 // Scope describes the names that can be used with this Namespace. The 28 // global namespace will have a scope that matches all names. The scope 29 // effectively provides an identity for the namespace. 30 Scope() Scope 31 32 // Repository should return a reference to the named repository. The 33 // registry may or may not have the repository but should always return a 34 // reference. 35 Repository(ctx context.Context, name string) (Repository, error) 36 37 // Repositories fills 'repos' with a lexigraphically sorted catalog of repositories 38 // up to the size of 'repos' and returns the value 'n' for the number of entries 39 // which were filled. 'last' contains an offset in the catalog, and 'err' will be 40 // set to io.EOF if there are no more entries to obtain. 41 Repositories(ctx context.Context, repos []string, last string) (n int, err error) 42 } 43 44 // ManifestServiceOption is a function argument for Manifest Service methods 45 type ManifestServiceOption interface { 46 Apply(ManifestService) error 47 } 48 49 // Repository is a named collection of manifests and layers. 50 type Repository interface { 51 // Name returns the name of the repository. 52 Name() string 53 54 // Manifests returns a reference to this repository's manifest service. 55 // with the supplied options applied. 56 Manifests(ctx context.Context, options ...ManifestServiceOption) (ManifestService, error) 57 58 // Blobs returns a reference to this repository's blob service. 59 Blobs(ctx context.Context) BlobStore 60 61 // TODO(stevvooe): The above BlobStore return can probably be relaxed to 62 // be a BlobService for use with clients. This will allow such 63 // implementations to avoid implementing ServeBlob. 64 65 // Tags returns a reference to this repositories tag service 66 Tags(ctx context.Context) TagService 67 } 68 69 // TODO(stevvooe): Must add close methods to all these. May want to change the 70 // way instances are created to better reflect internal dependency 71 // relationships.