mirror of
https://tangled.org/evan.jarrett.net/at-container-registry
synced 2026-08-31 05:07:09 +00:00
code cleanup
This commit is contained in:
@@ -1,22 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/distribution/distribution/v3/registry"
|
||||
_ "github.com/distribution/distribution/v3/registry/auth/token"
|
||||
_ "github.com/distribution/distribution/v3/registry/storage/driver/filesystem"
|
||||
_ "github.com/distribution/distribution/v3/registry/storage/driver/inmemory"
|
||||
_ "github.com/distribution/distribution/v3/registry/storage/driver/s3-aws"
|
||||
|
||||
// Register our custom middleware
|
||||
_ "atcr.io/pkg/middleware"
|
||||
|
||||
"atcr.io/pkg/auth/oauth"
|
||||
"atcr.io/pkg/auth/token"
|
||||
"atcr.io/pkg/middleware"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -26,11 +18,3 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// Suppress unused import warnings
|
||||
var _ = fmt.Sprint
|
||||
var _ = os.Stdout
|
||||
var _ = time.Now
|
||||
var _ = oauth.NewRefresher
|
||||
var _ = token.NewIssuer
|
||||
var _ = middleware.SetGlobalRefresher
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/distribution/distribution/v3"
|
||||
"github.com/distribution/distribution/v3/registry/storage"
|
||||
"github.com/distribution/distribution/v3/registry/storage/driver"
|
||||
"github.com/distribution/reference"
|
||||
)
|
||||
|
||||
// S3BlobStore wraps distribution's blob store with S3 backend
|
||||
type S3BlobStore struct {
|
||||
distribution.BlobStore
|
||||
}
|
||||
|
||||
// NewS3BlobStore creates a new S3-backed blob store
|
||||
func NewS3BlobStore(ctx context.Context, storageDriver driver.StorageDriver, repoName string) (*S3BlobStore, error) {
|
||||
// Create a registry instance with the S3 driver
|
||||
reg, err := storage.NewRegistry(ctx, storageDriver)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Parse the repository name into a Named reference
|
||||
named, err := reference.ParseNamed(repoName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Get the repository
|
||||
repo, err := reg.Repository(ctx, named)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Get the blob store
|
||||
blobStore := repo.Blobs(ctx)
|
||||
|
||||
return &S3BlobStore{
|
||||
BlobStore: blobStore,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Note: S3BlobStore inherits all methods from distribution.BlobStore
|
||||
// including:
|
||||
// - Stat(ctx, dgst) - Check if blob exists
|
||||
// - Get(ctx, dgst) - Retrieve blob
|
||||
// - Open(ctx, dgst) - Open blob for reading
|
||||
// - Put(ctx, mediaType, payload) - Store blob
|
||||
// - Create(ctx, options...) - Create blob writer
|
||||
// - Resume(ctx, id) - Resume blob upload
|
||||
// - ServeBlob(ctx, w, r, dgst) - Serve blob over HTTP
|
||||
// - Delete(ctx, dgst) - Delete blob
|
||||
Reference in New Issue
Block a user