wip: oci image management

This commit is contained in:
loveuer
2025-11-09 15:19:11 +08:00
commit 8de8234372
58 changed files with 6142 additions and 0 deletions

37
handler/blob_handler.go Normal file
View 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
}