github.com/samsalisbury/distribution@v2.2.1-0.20151123021722-54f974340220+incompatible/registry.go (about) 1 package distribution 2 3 import ( 4 "github.com/docker/distribution/context" 5 "github.com/docker/distribution/digest" 6 "github.com/docker/distribution/manifest/schema1" 7 ) 8 9 // Scope defines the set of items that match a namespace. 10 type Scope interface { 11 // Contains returns true if the name belongs to the namespace. 12 Contains(name string) bool 13 } 14 15 type fullScope struct{} 16 17 func (f fullScope) Contains(string) bool { 18 return true 19 } 20 21 // GlobalScope represents the full namespace scope which contains 22 // all other scopes. 23 var GlobalScope = Scope(fullScope{}) 24 25 // Namespace represents a collection of repositories, addressable by name. 26 // Generally, a namespace is backed by a set of one or more services, 27 // providing facilities such as registry access, trust, and indexing. 28 type Namespace interface { 29 // Scope describes the names that can be used with this Namespace. The 30 // global namespace will have a scope that matches all names. The scope 31 // effectively provides an identity for the namespace. 32 Scope() Scope 33 34 // Repository should return a reference to the named repository. The 35 // registry may or may not have the repository but should always return a 36 // reference. 37 Repository(ctx context.Context, name string) (Repository, error) 38 39 // Repositories fills 'repos' with a lexigraphically sorted catalog of repositories 40 // up to the size of 'repos' and returns the value 'n' for the number of entries 41 // which were filled. 'last' contains an offset in the catalog, and 'err' will be 42 // set to io.EOF if there are no more entries to obtain. 43 Repositories(ctx context.Context, repos []string, last string) (n int, err error) 44 } 45 46 // ManifestServiceOption is a function argument for Manifest Service methods 47 type ManifestServiceOption func(ManifestService) error 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 // Signatures returns a reference to this repository's signatures service. 66 Signatures() SignatureService 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. 72 73 // ManifestService provides operations on image manifests. 74 type ManifestService interface { 75 // Exists returns true if the manifest exists. 76 Exists(dgst digest.Digest) (bool, error) 77 78 // Get retrieves the identified by the digest, if it exists. 79 Get(dgst digest.Digest) (*schema1.SignedManifest, error) 80 81 // Delete removes the manifest, if it exists. 82 Delete(dgst digest.Digest) error 83 84 // Put creates or updates the manifest. 85 Put(manifest *schema1.SignedManifest) error 86 87 // TODO(stevvooe): The methods after this message should be moved to a 88 // discrete TagService, per active proposals. 89 90 // Tags lists the tags under the named repository. 91 Tags() ([]string, error) 92 93 // ExistsByTag returns true if the manifest exists. 94 ExistsByTag(tag string) (bool, error) 95 96 // GetByTag retrieves the named manifest, if it exists. 97 GetByTag(tag string, options ...ManifestServiceOption) (*schema1.SignedManifest, error) 98 99 // TODO(stevvooe): There are several changes that need to be done to this 100 // interface: 101 // 102 // 1. Allow explicit tagging with Tag(digest digest.Digest, tag string) 103 // 2. Support reading tags with a re-entrant reader to avoid large 104 // allocations in the registry. 105 // 3. Long-term: Provide All() method that lets one scroll through all of 106 // the manifest entries. 107 // 4. Long-term: break out concept of signing from manifests. This is 108 // really a part of the distribution sprint. 109 // 5. Long-term: Manifest should be an interface. This code shouldn't 110 // really be concerned with the storage format. 111 } 112 113 // SignatureService provides operations on signatures. 114 type SignatureService interface { 115 // Get retrieves all of the signature blobs for the specified digest. 116 Get(dgst digest.Digest) ([][]byte, error) 117 118 // Put stores the signature for the provided digest. 119 Put(dgst digest.Digest, signatures ...[]byte) error 120 }