feat(frontend): add Helm chart browser, monitoring, chart-references and values templates pages
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.
This commit is contained in:
98
backend/internal/domain/entity/storage.go
Normal file
98
backend/internal/domain/entity/storage.go
Normal file
@ -0,0 +1,98 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
// StorageType 存储类型
|
||||
type StorageType string
|
||||
|
||||
const (
|
||||
StorageTypeNFS StorageType = "nfs"
|
||||
StorageTypePV StorageType = "pv"
|
||||
StorageTypeHostPath StorageType = "hostPath"
|
||||
)
|
||||
|
||||
// StorageConfig 存储配置
|
||||
type StorageConfig struct {
|
||||
NFS *NFSConfig `json:"nfs,omitempty"`
|
||||
PV *PVConfig `json:"pv,omitempty"`
|
||||
HostPath *HostPathConfig `json:"hostPath,omitempty"`
|
||||
}
|
||||
|
||||
// NFSConfig NFS 配置
|
||||
type NFSConfig struct {
|
||||
Server string `json:"server"`
|
||||
Path string `json:"path"`
|
||||
}
|
||||
|
||||
// PVConfig PV 配置
|
||||
type PVConfig struct {
|
||||
StorageClassName string `json:"storageClassName"`
|
||||
Capacity string `json:"capacity"`
|
||||
AccessModes []string `json:"accessModes"`
|
||||
}
|
||||
|
||||
// HostPathConfig HostPath 配置
|
||||
type HostPathConfig struct {
|
||||
Path string `json:"path"`
|
||||
}
|
||||
|
||||
// StorageBackend 存储后端实体
|
||||
type StorageBackend struct {
|
||||
ID string
|
||||
WorkspaceID string
|
||||
OwnerID string
|
||||
Name string
|
||||
Type StorageType
|
||||
Config StorageConfig
|
||||
Description string
|
||||
IsDefault bool
|
||||
IsShared bool
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
// NewStorageBackend 创建新存储后端
|
||||
func NewStorageBackend(workspaceID, ownerID, name string, storageType StorageType, config StorageConfig) *StorageBackend {
|
||||
now := time.Now()
|
||||
return &StorageBackend{
|
||||
WorkspaceID: workspaceID,
|
||||
OwnerID: ownerID,
|
||||
Name: name,
|
||||
Type: storageType,
|
||||
Config: config,
|
||||
IsDefault: false,
|
||||
IsShared: false,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
}
|
||||
|
||||
// Validate 验证存储后端数据
|
||||
func (s *StorageBackend) Validate() error {
|
||||
if s.Name == "" {
|
||||
return ErrInvalidStorageName
|
||||
}
|
||||
if s.Type == "" {
|
||||
return ErrInvalidStorageName
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ConfigJSON 将配置转为 JSON 字符串
|
||||
func (s *StorageBackend) ConfigJSON() (string, error) {
|
||||
data, err := json.Marshal(s.Config)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(data), nil
|
||||
}
|
||||
|
||||
// ParseConfigJSON 从 JSON 解析配置
|
||||
func ParseConfigJSON(jsonStr string) (*StorageConfig, error) {
|
||||
var config StorageConfig
|
||||
err := json.Unmarshal([]byte(jsonStr), &config)
|
||||
return &config, err
|
||||
}
|
||||
Reference in New Issue
Block a user