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

@@ -12,7 +12,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"
@@ -39,7 +39,7 @@ func RegistryImageDownload(ctx context.Context, db *gorm.DB, store store.Store)
log.Printf("[Download] Start downloading: %s", fullImageName)
// Get current registry_address to strip it from the request
var registryConfig model.RegistryConfig
var registryConfig registry.RegistryConfig
registryAddress := ""
if err := db.Where("key = ?", "registry_address").First(&registryConfig).Error; err == nil {
registryAddress = registryConfig.Value
@@ -71,7 +71,7 @@ func RegistryImageDownload(ctx context.Context, db *gorm.DB, store store.Store)
// Find the repository
t1 := time.Now()
var repositoryModel model.Repository
var repositoryModel registry.Repository
if err := db.Where("name = ?", repository).First(&repositoryModel).Error; err != nil {
if err == gorm.ErrRecordNotFound {
return resp.R404(c, "IMAGE_NOT_FOUND", nil, fmt.Sprintf("image %s not found", repository))
@@ -82,7 +82,7 @@ func RegistryImageDownload(ctx context.Context, db *gorm.DB, store store.Store)
// Find the tag record
t2 := time.Now()
var tagRecord model.Tag
var tagRecord registry.Tag
if err := db.Where("repository = ? AND tag = ?", repository, tag).First(&tagRecord).Error; err != nil {
if err == gorm.ErrRecordNotFound {
// Try to get the first available tag
@@ -102,7 +102,7 @@ func RegistryImageDownload(ctx context.Context, db *gorm.DB, store store.Store)
// Get the manifest
t3 := time.Now()
var manifest model.Manifest
var manifest registry.Manifest
if err := db.Where("digest = ?", tagRecord.Digest).First(&manifest).Error; err != nil {
if err == gorm.ErrRecordNotFound {
return resp.R404(c, "MANIFEST_NOT_FOUND", nil, "manifest not found")