- 品牌: Go 模块/数据文件/二进制/构建部署资产全部 opsx→lokistack;前端 localStorage 命名空间迁移(读旧写新,含按用户 id 前缀迁移);修复 nginx upstream 与 Makefile 引用已改名服务的断裂 - i18n: react-i18next 落地,common + 11 个页面域命名空间全站中英(菜单/顶栏/登录/列表页/表单/确认弹窗/状态徽章);设置页语言即时切换;修复词典自注册导致的循环导入白屏 - 用户管理: 批量删除(POST /users/batch-delete,不删自己/最后管理员,部分失败不阻断)+ 行复选/全选/批量工具条 - 主题: 浅色侧栏(中性灰激活态)、四态模式(浅色/深色/跟随系统/定时切换,按时区判定)、顶栏太阳月亮二态、设置页紧凑分段选择器 - UI: 登录记住用户名、CardActionButton 统一五页卡片操作钮、shadcn Badge 替换手写徽章、语义色修正 - 清理: 移除主机 Web 终端(前后端)、k8s-helm/Helm 遗留代码与字段、README 重写精简 - 修复: 侧栏与日志告警 order 重复、路由标题 i18n key 未翻译、词典双逗号等
95 lines
3.3 KiB
Go
95 lines
3.3 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type LokiDeployment struct {
|
|
ID uint `json:"id"`
|
|
UUID string `json:"uuid"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
Version string `json:"version"`
|
|
Mode string `json:"mode"`
|
|
ClusterID *uint `json:"clusterID,omitempty"`
|
|
Cluster *Cluster `json:"cluster,omitempty"`
|
|
HostID *uint `json:"hostID,omitempty"`
|
|
Host *Host `json:"host,omitempty"`
|
|
ListenIP string `json:"listenIP,omitempty"`
|
|
ListenPort int `json:"listenPort,omitempty"`
|
|
Namespace string `json:"namespace"`
|
|
StorageConfigID uint `json:"storageConfigID"`
|
|
StorageConfig *StorageConfig `json:"storageConfig,omitempty"`
|
|
AuthEnabled bool `json:"authEnabled"`
|
|
RetentionDays int `json:"retentionDays"`
|
|
Replicas int `json:"replicas"`
|
|
ResourcesCPU string `json:"resourcesCPU"`
|
|
ResourcesMem string `json:"resourcesMem"`
|
|
StorageSize string `json:"storageSize"`
|
|
GrafanaEnabled bool `json:"grafanaEnabled"`
|
|
GrafanaVersion string `json:"grafanaVersion"`
|
|
GrafanaPort int `json:"grafanaPort"`
|
|
GrafanaEndpoint string `json:"grafanaEndpoint"`
|
|
Status string `json:"status"`
|
|
StatusMessage string `json:"statusMessage"`
|
|
Endpoint string `json:"endpoint"`
|
|
AdminUser string `json:"adminUser"`
|
|
AdminPassword string `json:"adminPassword"`
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
UpdatedAt time.Time `json:"updatedAt"`
|
|
}
|
|
|
|
func (d *LokiDeployment) BeforeCreate() {
|
|
if d.UUID == "" {
|
|
d.UUID = uuid.New().String()
|
|
}
|
|
}
|
|
|
|
// Sanitized 返回去除敏感字段(AdminPassword)的部署视图,并对嵌套的
|
|
// Cluster/Host/StorageConfig 一并做脱敏,避免经部署接口泄漏各自凭证。
|
|
func (d *LokiDeployment) Sanitized() map[string]interface{} {
|
|
out := map[string]interface{}{
|
|
"id": d.ID,
|
|
"uuid": d.UUID,
|
|
"name": d.Name,
|
|
"description": d.Description,
|
|
"version": d.Version,
|
|
"mode": d.Mode,
|
|
"clusterID": d.ClusterID,
|
|
"hostID": d.HostID,
|
|
"listenIP": d.ListenIP,
|
|
"listenPort": d.ListenPort,
|
|
"namespace": d.Namespace,
|
|
"storageConfigID": d.StorageConfigID,
|
|
"authEnabled": d.AuthEnabled,
|
|
"retentionDays": d.RetentionDays,
|
|
"replicas": d.Replicas,
|
|
"resourcesCPU": d.ResourcesCPU,
|
|
"resourcesMem": d.ResourcesMem,
|
|
"storageSize": d.StorageSize,
|
|
"grafanaEnabled": d.GrafanaEnabled,
|
|
"grafanaVersion": d.GrafanaVersion,
|
|
"grafanaPort": d.GrafanaPort,
|
|
"grafanaEndpoint": d.GrafanaEndpoint,
|
|
"status": d.Status,
|
|
"statusMessage": d.StatusMessage,
|
|
"endpoint": d.Endpoint,
|
|
"adminUser": d.AdminUser,
|
|
// AdminPassword 故意省略
|
|
"createdAt": d.CreatedAt,
|
|
"updatedAt": d.UpdatedAt,
|
|
}
|
|
if d.Cluster != nil {
|
|
out["cluster"] = d.Cluster.Sanitized()
|
|
}
|
|
if d.Host != nil {
|
|
out["host"] = d.Host.Sanitized()
|
|
}
|
|
if d.StorageConfig != nil {
|
|
out["storageConfig"] = d.StorageConfig.Sanitized()
|
|
}
|
|
return out
|
|
}
|