mirror of
https://github.com/project-zot/zot.git
synced 2024-12-16 21:56:37 -05:00
b80deb9927
unified both local and s3 ImageStore logic into a single ImageStore added a new driver interface for common file/dirs manipulations to be implemented by different storage types refactor(gc): drop umoci dependency, implemented internal gc added retentionDelay config option that specifies the garbage collect delay for images without tags this will also clean manifests which are part of an index image (multiarch) that no longer exist. fix(dedupe): skip blobs under .sync/ directory if startup dedupe is running while also syncing is running ignore blobs under sync's temporary storage fix(storage): do not allow image indexes modifications when deleting a manifest verify that it is not part of a multiarch image and throw a MethodNotAllowed error to the client if it is. we don't want to modify multiarch images Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>
70 lines
1.5 KiB
Go
70 lines
1.5 KiB
Go
package mocks
|
|
|
|
import godigest "github.com/opencontainers/go-digest"
|
|
|
|
type CacheMock struct {
|
|
// Returns the human-readable "name" of the driver.
|
|
NameFn func() string
|
|
|
|
// Retrieves the blob matching provided digest.
|
|
GetBlobFn func(digest godigest.Digest) (string, error)
|
|
|
|
// Uploads blob to cachedb.
|
|
PutBlobFn func(digest godigest.Digest, path string) error
|
|
|
|
// Check if blob exists in cachedb.
|
|
HasBlobFn func(digest godigest.Digest, path string) bool
|
|
|
|
// Delete a blob from the cachedb.
|
|
DeleteBlobFn func(digest godigest.Digest, path string) error
|
|
|
|
UsesRelativePathsFn func() bool
|
|
}
|
|
|
|
func (cacheMock CacheMock) UsesRelativePaths() bool {
|
|
if cacheMock.UsesRelativePathsFn != nil {
|
|
return cacheMock.UsesRelativePaths()
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
func (cacheMock CacheMock) Name() string {
|
|
if cacheMock.NameFn != nil {
|
|
return cacheMock.NameFn()
|
|
}
|
|
|
|
return "mock"
|
|
}
|
|
|
|
func (cacheMock CacheMock) GetBlob(digest godigest.Digest) (string, error) {
|
|
if cacheMock.GetBlobFn != nil {
|
|
return cacheMock.GetBlobFn(digest)
|
|
}
|
|
|
|
return "", nil
|
|
}
|
|
|
|
func (cacheMock CacheMock) PutBlob(digest godigest.Digest, path string) error {
|
|
if cacheMock.PutBlobFn != nil {
|
|
return cacheMock.PutBlobFn(digest, path)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (cacheMock CacheMock) HasBlob(digest godigest.Digest, path string) bool {
|
|
if cacheMock.HasBlobFn != nil {
|
|
return cacheMock.HasBlobFn(digest, path)
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
func (cacheMock CacheMock) DeleteBlob(digest godigest.Digest, path string) error {
|
|
if cacheMock.DeleteBlobFn != nil {
|
|
return cacheMock.DeleteBlobFn(digest, path)
|
|
}
|
|
|
|
return nil
|
|
}
|