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:
27
backend/internal/domain/repository/audit_log_repository.go
Normal file
27
backend/internal/domain/repository/audit_log_repository.go
Normal file
@ -0,0 +1,27 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/ocdp/cluster-service/internal/domain/entity"
|
||||
)
|
||||
|
||||
// AuditLogRepository 审计日志仓储接口
|
||||
type AuditLogRepository interface {
|
||||
// Create 创建审计日志
|
||||
Create(ctx context.Context, log *entity.AuditLog) error
|
||||
|
||||
// GetByWorkspace 获取 workspace 的审计日志
|
||||
GetByWorkspace(ctx context.Context, workspaceID string, limit int) ([]*entity.AuditLog, error)
|
||||
|
||||
// GetByUser 获取用户的审计日志
|
||||
GetByUser(ctx context.Context, userID string, limit int) ([]*entity.AuditLog, error)
|
||||
|
||||
// GetByResource 获取资源的审计日志
|
||||
GetByResource(ctx context.Context, resourceType entity.AuditResourceType, resourceID string, limit int) ([]*entity.AuditLog, error)
|
||||
|
||||
// List 列出审计日志(分页)
|
||||
List(ctx context.Context, limit, offset int) ([]*entity.AuditLog, error)
|
||||
|
||||
// DeleteByWorkspace 删除 workspace 的审计日志
|
||||
DeleteByWorkspace(ctx context.Context, workspaceID string) error
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/ocdp/cluster-service/internal/domain/entity"
|
||||
)
|
||||
|
||||
// ChartReferenceRepository Chart 引用仓储接口
|
||||
type ChartReferenceRepository interface {
|
||||
// Create 创建 Chart 引用
|
||||
Create(ctx context.Context, chartRef *entity.ChartReference) error
|
||||
|
||||
// GetByID 根据 ID 获取 Chart 引用
|
||||
GetByID(ctx context.Context, id string) (*entity.ChartReference, error)
|
||||
|
||||
// GetByWorkspace 获取 workspace 的所有 Chart 引用
|
||||
GetByWorkspace(ctx context.Context, workspaceID string) ([]*entity.ChartReference, error)
|
||||
|
||||
// GetByRegistry 获取 registry 的所有 Chart 引用
|
||||
GetByRegistry(ctx context.Context, registryID string) ([]*entity.ChartReference, error)
|
||||
|
||||
// GetByName 根据名称获取 Chart 引用
|
||||
GetByName(ctx context.Context, workspaceID, chartName string) (*entity.ChartReference, error)
|
||||
|
||||
// Update 更新 Chart 引用
|
||||
Update(ctx context.Context, chartRef *entity.ChartReference) error
|
||||
|
||||
// Delete 删除 Chart 引用
|
||||
Delete(ctx context.Context, id string) error
|
||||
|
||||
// List 列出所有 Chart 引用(管理员用)
|
||||
List(ctx context.Context) ([]*entity.ChartReference, error)
|
||||
}
|
||||
@ -9,20 +9,26 @@ import (
|
||||
type ClusterRepository interface {
|
||||
// Create 创建集群
|
||||
Create(ctx context.Context, cluster *entity.Cluster) error
|
||||
|
||||
|
||||
// GetByID 根据 ID 获取集群
|
||||
GetByID(ctx context.Context, id string) (*entity.Cluster, error)
|
||||
|
||||
|
||||
// GetByName 根据名称获取集群
|
||||
GetByName(ctx context.Context, name string) (*entity.Cluster, error)
|
||||
|
||||
|
||||
// Update 更新集群
|
||||
Update(ctx context.Context, cluster *entity.Cluster) error
|
||||
|
||||
|
||||
// Delete 删除集群
|
||||
Delete(ctx context.Context, id string) error
|
||||
|
||||
|
||||
// List 列出所有集群
|
||||
List(ctx context.Context) ([]*entity.Cluster, error)
|
||||
|
||||
// GetByWorkspace 获取 workspace 的所有集群(包括共享集群)
|
||||
GetByWorkspace(ctx context.Context, workspaceID string) ([]*entity.Cluster, error)
|
||||
|
||||
// GetShared 获取所有共享集群
|
||||
GetShared(ctx context.Context) ([]*entity.Cluster, error)
|
||||
}
|
||||
|
||||
|
||||
@ -9,23 +9,26 @@ import (
|
||||
type InstanceRepository interface {
|
||||
// Create 创建实例
|
||||
Create(ctx context.Context, instance *entity.Instance) error
|
||||
|
||||
|
||||
// GetByID 根据 ID 获取实例
|
||||
GetByID(ctx context.Context, id string) (*entity.Instance, error)
|
||||
|
||||
|
||||
// GetByClusterAndName 根据集群 ID 和名称获取实例
|
||||
GetByClusterAndName(ctx context.Context, clusterID, name string) (*entity.Instance, error)
|
||||
|
||||
|
||||
// Update 更新实例
|
||||
Update(ctx context.Context, instance *entity.Instance) error
|
||||
|
||||
|
||||
// Delete 删除实例
|
||||
Delete(ctx context.Context, id string) error
|
||||
|
||||
|
||||
// ListByCluster 列出指定集群的所有实例
|
||||
ListByCluster(ctx context.Context, clusterID string) ([]*entity.Instance, error)
|
||||
|
||||
|
||||
// List 列出所有实例
|
||||
List(ctx context.Context) ([]*entity.Instance, error)
|
||||
|
||||
// GetByWorkspace 列出指定工作空间的所有实例(用于配额检查)
|
||||
GetByWorkspace(ctx context.Context, workspaceID string) ([]*entity.Instance, error)
|
||||
}
|
||||
|
||||
|
||||
@ -19,7 +19,10 @@ type OCIClient interface {
|
||||
|
||||
// GetValuesSchema 获取 Helm Chart 的 values schema
|
||||
GetValuesSchema(ctx context.Context, registry *entity.Registry, repository, reference string) (string, error)
|
||||
|
||||
|
||||
// GetValues 获取 Helm Chart 的 values.yaml
|
||||
GetValues(ctx context.Context, registry *entity.Registry, repository, reference string) (string, error)
|
||||
|
||||
// PullArtifact 下载 artifact 到本地
|
||||
PullArtifact(ctx context.Context, registry *entity.Registry, repository, reference, destPath string) error
|
||||
|
||||
|
||||
30
backend/internal/domain/repository/quota_repository.go
Normal file
30
backend/internal/domain/repository/quota_repository.go
Normal file
@ -0,0 +1,30 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/ocdp/cluster-service/internal/domain/entity"
|
||||
)
|
||||
|
||||
// QuotaRepository 配额仓储接口
|
||||
type QuotaRepository interface {
|
||||
// Create 创建配额
|
||||
Create(ctx context.Context, quota *entity.WorkspaceQuota) error
|
||||
|
||||
// GetByID 根据 ID 获取配额
|
||||
GetByID(ctx context.Context, id string) (*entity.WorkspaceQuota, error)
|
||||
|
||||
// GetByWorkspaceAndType 根据 workspace 和资源类型获取配额
|
||||
GetByWorkspaceAndType(ctx context.Context, workspaceID string, resourceType entity.ResourceType) (*entity.WorkspaceQuota, error)
|
||||
|
||||
// GetByWorkspace 获取 workspace 的所有配额
|
||||
GetByWorkspace(ctx context.Context, workspaceID string) ([]*entity.WorkspaceQuota, error)
|
||||
|
||||
// Update 更新配额
|
||||
Update(ctx context.Context, quota *entity.WorkspaceQuota) error
|
||||
|
||||
// Delete 删除配额
|
||||
Delete(ctx context.Context, id string) error
|
||||
|
||||
// DeleteByWorkspace 删除 workspace 的所有配额
|
||||
DeleteByWorkspace(ctx context.Context, workspaceID string) error
|
||||
}
|
||||
36
backend/internal/domain/repository/storage_repository.go
Normal file
36
backend/internal/domain/repository/storage_repository.go
Normal file
@ -0,0 +1,36 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/ocdp/cluster-service/internal/domain/entity"
|
||||
)
|
||||
|
||||
// StorageRepository 存储后端仓储接口
|
||||
type StorageRepository interface {
|
||||
// Create 创建存储后端
|
||||
Create(ctx context.Context, storage *entity.StorageBackend) error
|
||||
|
||||
// GetByID 根据 ID 获取存储后端
|
||||
GetByID(ctx context.Context, id string) (*entity.StorageBackend, error)
|
||||
|
||||
// GetByName 根据名称获取存储后端
|
||||
GetByName(ctx context.Context, workspaceID, name string) (*entity.StorageBackend, error)
|
||||
|
||||
// GetByWorkspace 获取 workspace 的所有存储后端
|
||||
GetByWorkspace(ctx context.Context, workspaceID string) ([]*entity.StorageBackend, error)
|
||||
|
||||
// GetShared 获取所有共享存储后端
|
||||
GetShared(ctx context.Context) ([]*entity.StorageBackend, error)
|
||||
|
||||
// GetDefault 获取 workspace 的默认存储后端
|
||||
GetDefault(ctx context.Context, workspaceID string) (*entity.StorageBackend, error)
|
||||
|
||||
// Update 更新存储后端
|
||||
Update(ctx context.Context, storage *entity.StorageBackend) error
|
||||
|
||||
// Delete 删除存储后端
|
||||
Delete(ctx context.Context, id string) error
|
||||
|
||||
// List 列出所有存储后端(管理员用)
|
||||
List(ctx context.Context) ([]*entity.StorageBackend, error)
|
||||
}
|
||||
@ -9,20 +9,26 @@ import (
|
||||
type UserRepository interface {
|
||||
// Create 创建用户
|
||||
Create(ctx context.Context, user *entity.User) error
|
||||
|
||||
|
||||
// GetByID 根据 ID 获取用户
|
||||
GetByID(ctx context.Context, id string) (*entity.User, error)
|
||||
|
||||
|
||||
// GetByUsername 根据用户名获取用户
|
||||
GetByUsername(ctx context.Context, username string) (*entity.User, error)
|
||||
|
||||
|
||||
// Update 更新用户
|
||||
Update(ctx context.Context, user *entity.User) error
|
||||
|
||||
|
||||
// Delete 删除用户
|
||||
Delete(ctx context.Context, id string) error
|
||||
|
||||
|
||||
// List 列出所有用户
|
||||
List(ctx context.Context) ([]*entity.User, error)
|
||||
|
||||
// ListByWorkspace 列出指定 workspace 的用户
|
||||
ListByWorkspace(ctx context.Context, workspaceID string) ([]*entity.User, error)
|
||||
|
||||
// ListActive 仅列出活跃用户
|
||||
ListActive(ctx context.Context) ([]*entity.User, error)
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/ocdp/cluster-service/internal/domain/entity"
|
||||
)
|
||||
|
||||
// ValuesTemplateRepository Values 模板仓储接口
|
||||
type ValuesTemplateRepository interface {
|
||||
// Create 创建 Values 模板
|
||||
Create(ctx context.Context, template *entity.ValuesTemplate) error
|
||||
|
||||
// GetByID 根据 ID 获取 Values 模板
|
||||
GetByID(ctx context.Context, id string) (*entity.ValuesTemplate, error)
|
||||
|
||||
// GetByWorkspace 获取 workspace 的所有 Values 模板
|
||||
GetByWorkspace(ctx context.Context, workspaceID string) ([]*entity.ValuesTemplate, error)
|
||||
|
||||
// GetByChartReference 获取 Chart Reference 的所有 Values 模板
|
||||
GetByChartReference(ctx context.Context, chartRefID string) ([]*entity.ValuesTemplate, error)
|
||||
|
||||
// GetByName 根据名称获取 Values 模板
|
||||
GetByName(ctx context.Context, workspaceID, chartRefID, name string) (*entity.ValuesTemplate, error)
|
||||
|
||||
// GetHistory 获取模板的版本历史
|
||||
GetHistory(ctx context.Context, chartRefID, name string) ([]*entity.ValuesTemplate, error)
|
||||
|
||||
// Update 更新 Values 模板(自动递增版本)
|
||||
Update(ctx context.Context, template *entity.ValuesTemplate) error
|
||||
|
||||
// Delete 删除 Values 模板
|
||||
Delete(ctx context.Context, id string) error
|
||||
|
||||
// List 列出所有 Values 模板(管理员用)
|
||||
List(ctx context.Context) ([]*entity.ValuesTemplate, error)
|
||||
}
|
||||
27
backend/internal/domain/repository/workspace_repository.go
Normal file
27
backend/internal/domain/repository/workspace_repository.go
Normal file
@ -0,0 +1,27 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/ocdp/cluster-service/internal/domain/entity"
|
||||
)
|
||||
|
||||
// WorkspaceRepository Workspace 仓储接口
|
||||
type WorkspaceRepository interface {
|
||||
// Create 创建 Workspace
|
||||
Create(ctx context.Context, workspace *entity.Workspace) error
|
||||
|
||||
// GetByID 根据 ID 获取 Workspace
|
||||
GetByID(ctx context.Context, id string) (*entity.Workspace, error)
|
||||
|
||||
// GetByName 根据名称获取 Workspace
|
||||
GetByName(ctx context.Context, name string) (*entity.Workspace, error)
|
||||
|
||||
// Update 更新 Workspace
|
||||
Update(ctx context.Context, workspace *entity.Workspace) error
|
||||
|
||||
// Delete 删除 Workspace
|
||||
Delete(ctx context.Context, id string) error
|
||||
|
||||
// List 列出所有 Workspace
|
||||
List(ctx context.Context) ([]*entity.Workspace, error)
|
||||
}
|
||||
Reference in New Issue
Block a user