add support for repo deleted event also

by having another interface RepositoryRemover that is implemented by
registry instance and is injected in app context for event tracking

Signed-off-by: Manish Tomar <manish.tomar@docker.com>
This commit is contained in:
Manish Tomar
2018-08-02 22:58:52 -07:00
parent 0d8f4ac7b8
commit 328069bb4d
7 changed files with 76 additions and 7 deletions

View File

@@ -7,6 +7,7 @@ import (
"path"
"strings"
"github.com/docker/distribution/reference"
"github.com/docker/distribution/registry/storage/driver"
)
@@ -70,6 +71,16 @@ func (reg *registry) Enumerate(ctx context.Context, ingester func(string) error)
return err
}
// Remove removes a repository from storage
func (r *registry) Remove(ctx context.Context, name reference.Named) error {
root, err := pathFor(repositoriesRootPathSpec{})
if err != nil {
return err
}
repoDir := path.Join(root, name.Name())
return r.driver.Delete(ctx, repoDir)
}
// lessPath returns true if one path a is less than path b.
//
// A component-wise comparison is done, rather than the lexical comparison of