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:
23
pkg/model/auth/user.go
Normal file
23
pkg/model/auth/user.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// User 用户模型
|
||||
type User struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
|
||||
Username string `gorm:"uniqueIndex;not null" json:"username"`
|
||||
Password string `gorm:"not null" json:"-"`
|
||||
Email string `gorm:"index" json:"email"`
|
||||
Nickname string `json:"nickname"`
|
||||
Role string `gorm:"default:'user'" json:"role"`
|
||||
Status string `gorm:"default:'active'" json:"status"`
|
||||
Permissions string `gorm:"type:text" json:"permissions"`
|
||||
}
|
||||
18
pkg/model/k8s/config.go
Normal file
18
pkg/model/k8s/config.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// ClusterConfig k8s cluster configuration
|
||||
type ClusterConfig struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
|
||||
Key string `gorm:"uniqueIndex;not null" json:"key"`
|
||||
Value string `gorm:"type:text" json:"value"`
|
||||
}
|
||||
20
pkg/model/registry/blob.go
Normal file
20
pkg/model/registry/blob.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package registry
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Blob blob ??
|
||||
type Blob struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
|
||||
Digest string `gorm:"uniqueIndex;not null" json:"digest"` // SHA256 digest
|
||||
Size int64 `gorm:"not null" json:"size"` // ??????
|
||||
MediaType string `json:"media_type"` // ????
|
||||
Repository string `gorm:"index" json:"repository"` // ???????????????
|
||||
}
|
||||
20
pkg/model/registry/blob_upload.go
Normal file
20
pkg/model/registry/blob_upload.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package registry
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// BlobUpload ????? blob ??
|
||||
type BlobUpload struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
|
||||
UUID string `gorm:"uniqueIndex;not null" json:"uuid"` // ???? UUID
|
||||
Repository string `gorm:"index;not null" json:"repository"` // ????
|
||||
Path string `gorm:"not null" json:"path"` // ??????
|
||||
Size int64 `gorm:"default:0" json:"size"` // ?????
|
||||
}
|
||||
18
pkg/model/registry/config.go
Normal file
18
pkg/model/registry/config.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package registry
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// RegistryConfig registry ?????
|
||||
type RegistryConfig struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
|
||||
Key string `gorm:"uniqueIndex;not null" json:"key"` // ???? key
|
||||
Value string `gorm:"type:text" json:"value"` // ???? value
|
||||
}
|
||||
22
pkg/model/registry/manifest.go
Normal file
22
pkg/model/registry/manifest.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package registry
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Manifest manifest ??
|
||||
type Manifest struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
|
||||
Repository string `gorm:"index;not null" json:"repository"` // ????
|
||||
Tag string `gorm:"index;not null" json:"tag"` // tag ??
|
||||
Digest string `gorm:"uniqueIndex;not null" json:"digest"` // manifest digest
|
||||
MediaType string `json:"media_type"` // ????
|
||||
Size int64 `gorm:"not null" json:"size"` // manifest ??
|
||||
Content []byte `gorm:"type:blob" json:"-"` // manifest ???JSON?
|
||||
}
|
||||
17
pkg/model/registry/repository.go
Normal file
17
pkg/model/registry/repository.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package registry
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Repository ????
|
||||
type Repository struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
|
||||
Name string `gorm:"uniqueIndex;not null" json:"name"` // ?????? "library/nginx"
|
||||
}
|
||||
19
pkg/model/registry/tag.go
Normal file
19
pkg/model/registry/tag.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package registry
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Tag tag ??????????
|
||||
type Tag struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
|
||||
Repository string `gorm:"index;not null" json:"repository"` // ????
|
||||
Tag string `gorm:"index;not null" json:"tag"` // tag ??
|
||||
Digest string `gorm:"not null" json:"digest"` // ??? manifest digest
|
||||
}
|
||||
Reference in New Issue
Block a user