registry.go 3.3 KB

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