Go(Gin) + React(Vite + shadcn/ui + Tailwind) 前后端分离,全中文 UI - 集群管理:Kubeconfig / Token 双接入,kubectl + helm 部署 - 主机管理:SSH 密钥 / 密码双认证,CPU/内存/磁盘使用率监控,SSH 错误中文友好提示 - 存储配置、部署管理、系统设置 - Docker 镜像内置 kubectl + helm,开箱即用 - run.sh 一键启停(start/stop/restart/status) Co-Authored-By: Claude <noreply@anthropic.com>
69 lines
1.4 KiB
Go
69 lines
1.4 KiB
Go
package models
|
|
|
|
// Sanitizer interface for models that can sanitize themselves
|
|
type Sanitizer interface {
|
|
Sanitized() map[string]interface{}
|
|
}
|
|
|
|
// SanitizedJSON sanitizes a single model or a slice of models
|
|
func SanitizedJSON(v any) any {
|
|
switch val := v.(type) {
|
|
// Single objects
|
|
case User:
|
|
return val.Sanitized()
|
|
case *User:
|
|
if val == nil {
|
|
return nil
|
|
}
|
|
return val.Sanitized()
|
|
case Cluster:
|
|
return val.Sanitized()
|
|
case *Cluster:
|
|
if val == nil {
|
|
return nil
|
|
}
|
|
return val.Sanitized()
|
|
case Host:
|
|
return val.Sanitized()
|
|
case *Host:
|
|
if val == nil {
|
|
return nil
|
|
}
|
|
return val.Sanitized()
|
|
case StorageConfig:
|
|
return val.Sanitized()
|
|
case *StorageConfig:
|
|
if val == nil {
|
|
return nil
|
|
}
|
|
return val.Sanitized()
|
|
// Slices
|
|
case []User:
|
|
result := make([]map[string]interface{}, len(val))
|
|
for i, item := range val {
|
|
result[i] = item.Sanitized()
|
|
}
|
|
return result
|
|
case []Cluster:
|
|
result := make([]map[string]interface{}, len(val))
|
|
for i, item := range val {
|
|
result[i] = item.Sanitized()
|
|
}
|
|
return result
|
|
case []Host:
|
|
result := make([]map[string]interface{}, len(val))
|
|
for i, item := range val {
|
|
result[i] = item.Sanitized()
|
|
}
|
|
return result
|
|
case []StorageConfig:
|
|
result := make([]map[string]interface{}, len(val))
|
|
for i, item := range val {
|
|
result[i] = item.Sanitized()
|
|
}
|
|
return result
|
|
default:
|
|
return v
|
|
}
|
|
}
|