Add new frontend pages for the multi-tenant OCDP platform: - Charts page (/charts): Browse Harbor OCI registries to list Helm chart repositories and versions, with deploy modal to launch charts on selected clusters - Monitoring page (/monitoring): Display cluster metrics (CPU/Memory/GPU usage) and per-node details with resource utilization bars - Chart References page (/chart-references): CRUD for chart metadata references - Values Templates page (/templates): CRUD for Helm values templates with version history and rollback support - Sidebar: Add Charts navigation, update Storage and Templates links - api.ts: Add all API client functions (clusterApi, registryApi, instanceApi, monitoringApi, storageApi, chartReferenceApi, valuesTemplateApi, workspaceApi, userApi) with full TypeScript types Note: deploy flow and values template rollback not yet end-to-end tested.
83 lines
2.0 KiB
Go
83 lines
2.0 KiB
Go
package entity
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// ValuesTemplate Values 模板实体(带版本管理)
|
|
type ValuesTemplate struct {
|
|
ID string
|
|
WorkspaceID string
|
|
OwnerID string
|
|
ChartReferenceID string
|
|
Name string
|
|
Description string
|
|
ValuesYAML string
|
|
Version int // 模板版本号
|
|
IsDefault bool
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
// NewValuesTemplate 创建新 Values 模板
|
|
func NewValuesTemplate(workspaceID, ownerID, chartReferenceID, name, valuesYAML string) *ValuesTemplate {
|
|
now := time.Now()
|
|
return &ValuesTemplate{
|
|
WorkspaceID: workspaceID,
|
|
OwnerID: ownerID,
|
|
ChartReferenceID: chartReferenceID,
|
|
Name: name,
|
|
ValuesYAML: valuesYAML,
|
|
Version: 1,
|
|
IsDefault: false,
|
|
CreatedAt: now,
|
|
UpdatedAt: now,
|
|
}
|
|
}
|
|
|
|
// Validate 验证 Values 模板数据
|
|
func (v *ValuesTemplate) Validate() error {
|
|
if v.Name == "" {
|
|
return ErrInvalidTemplateName
|
|
}
|
|
if v.ValuesYAML == "" {
|
|
return ErrInvalidTemplateName
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// IncrementVersion 递增版本号
|
|
func (v *ValuesTemplate) IncrementVersion() {
|
|
v.Version++
|
|
v.UpdatedAt = time.Now()
|
|
}
|
|
|
|
// UserConfigOverride 用户配置覆盖实体
|
|
type UserConfigOverride struct {
|
|
ID string
|
|
WorkspaceID string
|
|
UserID string
|
|
TargetType string // 'storage', 'template', 'global'
|
|
TargetID string
|
|
Config map[string]interface{}
|
|
Priority int
|
|
IsActive bool
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
// NewUserConfigOverride 创建新用户配置覆盖
|
|
func NewUserConfigOverride(workspaceID, userID, targetType, targetID string, config map[string]interface{}) *UserConfigOverride {
|
|
now := time.Now()
|
|
return &UserConfigOverride{
|
|
WorkspaceID: workspaceID,
|
|
UserID: userID,
|
|
TargetType: targetType,
|
|
TargetID: targetID,
|
|
Config: config,
|
|
Priority: 0,
|
|
IsActive: true,
|
|
CreatedAt: now,
|
|
UpdatedAt: now,
|
|
}
|
|
} |