wip: oci image management
This commit is contained in:
37
handler/blob_handler.go
Normal file
37
handler/blob_handler.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
|
||||
"gitea.loveuer.com/loveuer/cluster/internal/model"
|
||||
"gitea.loveuer.com/loveuer/cluster/internal/registry/storage"
|
||||
)
|
||||
|
||||
type blobHandlerImpl struct {
|
||||
store storage.Storage
|
||||
}
|
||||
|
||||
// NewBlobHandler creates a new blob handler
|
||||
func NewBlobHandler(store storage.Storage) BlobHandler {
|
||||
return &blobHandlerImpl{store: store}
|
||||
}
|
||||
|
||||
func (b *blobHandlerImpl) Get(ctx context.Context, repo string, h model.Hash) (io.ReadCloser, error) {
|
||||
reader, _, err := b.store.GetBlob(repo, h.String())
|
||||
return reader, err
|
||||
}
|
||||
|
||||
func (b *blobHandlerImpl) Put(ctx context.Context, repo string, h model.Hash, rc io.ReadCloser) error {
|
||||
defer rc.Close()
|
||||
return b.store.PutBlob(repo, h.String(), rc)
|
||||
}
|
||||
|
||||
func (b *blobHandlerImpl) Stat(ctx context.Context, repo string, h model.Hash) (int64, error) {
|
||||
return b.store.GetBlobSize(repo, h.String())
|
||||
}
|
||||
|
||||
func (b *blobHandlerImpl) Delete(ctx context.Context, repo string, h model.Hash) error {
|
||||
// TODO: implement delete
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user