refactor: reorganize models to pkg/model and add authentication module

- Move ORM models from internal/model to pkg/model organized by module (auth/k8s/registry)
- Add authentication module with login, user management handlers
- Update all import paths to use new model locations
- Add frontend auth pages (Login, UserManagement) and authStore
- Remove deprecated internal/model/model.go
This commit is contained in:
loveuer
2025-11-20 14:55:48 +08:00
parent a80744c533
commit 8b655d3496
34 changed files with 1410 additions and 191 deletions

View File

@@ -14,7 +14,7 @@ import (
"strings"
"time"
"gitea.loveuer.com/loveuer/cluster/internal/model"
"gitea.loveuer.com/loveuer/cluster/pkg/model/registry"
"gitea.loveuer.com/loveuer/cluster/pkg/resp"
"gitea.loveuer.com/loveuer/cluster/pkg/store"
"github.com/gofiber/fiber/v3"
@@ -161,7 +161,7 @@ func pullImage(ctx context.Context, db *gorm.DB, store store.Store, repo string,
log.Printf("[PullImage] Got manifest with %d layers", len(manifest.Layers))
// Create repository
if err := db.FirstOrCreate(&model.Repository{}, model.Repository{Name: repo}).Error; err != nil {
if err := db.FirstOrCreate(&registry.Repository{}, registry.Repository{Name: repo}).Error; err != nil {
return nil, fmt.Errorf("failed to create repository: %w", err)
}
@@ -195,7 +195,7 @@ func pullImage(ctx context.Context, db *gorm.DB, store store.Store, repo string,
return nil, fmt.Errorf("failed to write config blob: %w", err)
}
if err := db.Create(&model.Blob{
if err := db.Create(&registry.Blob{
Digest: digest,
Size: manifest.Config.Size,
MediaType: "application/vnd.docker.container.image.v1+json",
@@ -229,7 +229,7 @@ func pullImage(ctx context.Context, db *gorm.DB, store store.Store, repo string,
return nil, fmt.Errorf("failed to write layer blob %d: %w", idx, err)
}
if err := db.Create(&model.Blob{
if err := db.Create(&registry.Blob{
Digest: layerDigest,
Size: layerDesc.Size,
MediaType: string(layerDesc.MediaType),
@@ -275,7 +275,7 @@ func pullImage(ctx context.Context, db *gorm.DB, store store.Store, repo string,
return nil, fmt.Errorf("failed to write manifest: %w", err)
}
if err := db.Create(&model.Manifest{
if err := db.Create(&registry.Manifest{
Repository: repo,
Tag: tag,
Digest: manifestDigest,
@@ -286,7 +286,7 @@ func pullImage(ctx context.Context, db *gorm.DB, store store.Store, repo string,
return nil, fmt.Errorf("failed to save manifest: %w", err)
}
if err := db.Create(&model.Tag{
if err := db.Create(&registry.Tag{
Repository: repo,
Tag: tag,
Digest: manifestDigest,