Documentation
¶
Index ¶
- Constants
- Variables
- func FillDefaultLimigrange(env *Environment) []byte
- func GetErrMessage(err error) string
- func IsNotFound(err error) bool
- func MigrateDatabaseAndInitData(opts *database.Options, initData bool) error
- func SetKubeClient(c KubeClient)
- type AlertInfo
- type AlertMessage
- type Application
- type AuditLog
- type AuthSource
- type AuthSourceConfig
- type AuthSourceSimple
- type CPUMemoryStatus
- type ChartRepo
- type Cluster
- type CommonUserIface
- type Condition
- type Container
- type EdgeData
- type EdgeWrapper
- type Elements
- type Environment
- type EnvironmentResource
- type EnvironmentUserRels
- type Graph
- type KubeClient
- type LogQueryHistory
- type LogQueryHistoryWithCount
- type LogQuerySnapshot
- type Message
- type MetricGraph
- type MetricRow
- type MetricTable
- type MonitorDashboard
- type MonitorGraphs
- type NodeData
- type NodeType
- type NodeWrapper
- type Notice
- type OnlineConfig
- type Project
- type ProjectUserRels
- type Registry
- type SystemRole
- type Tenant
- type TenantResourceQuota
- type TenantResourceQuotaApply
- type TenantUserRels
- type User
- func (u *User) GetEmail() string
- func (u *User) GetID() uint
- func (u *User) GetMail() string
- func (u *User) GetSource() string
- func (u *User) GetSystemRoleID() uint
- func (u *User) GetUserKind() string
- func (u *User) GetUsername() string
- func (u User) MarshalBinary() ([]byte, error)
- func (u *User) SetLastLogin(t *time.Time)
- func (u *User) UnmarshalBinary(data []byte) error
- type UserCreate
- type UserMessageStatus
- type UserSel
- type VirtualDomain
- type VirtualSpace
- type VirtualSpaceUserRels
- type Workload
Constants ¶
View Source
const (
SyncStatusRunning = "running"
SyncStatusError = "error"
SyncStatusSuccess = "success"
)
View Source
const (
EnvironmentRoleReader = "reader"
EnvironmentRoleOperator = "operator"
ResEnvironment = "environment"
)
View Source
const (
ProjectRoleAdmin = "admin"
ProjectRoleDev = "dev"
ProjectRoleTest = "test"
ProjectRoleOps = "ops"
ResProject = "project"
)
View Source
const (
SystemRoleAdmin = "sysadmin"
SystemRoleOrdinary = "ordinary"
ResSystemRole = "systemrole"
)
View Source
const (
TenantRoleAdmin = "admin"
TenantRoleOrdinary = "ordinary"
ResTenant = "tenant"
)
View Source
const (
QuotaStatusApproved = "approved"
QuotaStatusRejected = "rejected"
QuotaStatusPending = "pending"
)
View Source
const (
ResVirtualSpace = "virtualSpace"
VirtualSpaceRoleAdmin = "admin"
VirtualSpaceRoleNormal = "normal"
)
View Source
const (
StatusVeryHigh = "very_high" // 非常高,要扩容
StatusHigh = "high" // 高,要扩容
StatusLow = "low" // 低,要缩容
ColorYellow = "yellow"
ColorRed = "red"
Ki = 1 << 10 // 1024
Mi = 1 << 20
Gi = 1 << 30
)
View Source
const (
ResUser = "user"
)
View Source
const (
ResVirtualDomain = "virtualDomain"
)
Variables ¶
View Source
var ResChartRepo = "chartrepo"
Functions ¶
func FillDefaultLimigrange ¶
func FillDefaultLimigrange(env *Environment) []byte
func GetErrMessage ¶
func GetErrMessage(err error) string
func IsNotFound ¶
func IsNotFound(err error) bool
func MigrateDatabaseAndInitData ¶
func MigrateDatabaseAndInitData(opts *database.Options, initData bool) error
func SetKubeClient ¶
func SetKubeClient(c KubeClient)
Types ¶
type AlertInfo ¶
type AlertInfo struct {
Fingerprint string `gorm:"type:varchar(50);primaryKey"` // 指纹作为主键
Name string `gorm:"type:varchar(50);"`
Namespace string `gorm:"type:varchar(50);"`
ClusterName string `gorm:"type:varchar(50);"`
TenantName string `gorm:"type:varchar(50);index"`
ProjectName string `gorm:"type:varchar(50);index"`
EnvironmentName string `gorm:"type:varchar(50);index"`
Labels datatypes.JSON
LabelMap map[string]string `gorm:"-" json:"-"`
SilenceStartsAt *time.Time
SilenceUpdatedAt *time.Time
SilenceEndsAt *time.Time
SilenceCreator string `gorm:"type:varchar(50);"`
Summary string `gorm:"-"` // 黑名单概要
}
type AlertMessage ¶
type AlertMessage struct {
ID uint
// 级联删除
Fingerprint string `gorm:"type:varchar(50);"`
AlertInfo *AlertInfo `gorm:"foreignKey:Fingerprint;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
Value string
Message string
StartsAt *time.Time `gorm:"index"` // 告警开始时间
EndsAt *time.Time // 告警结束时间
CreatedAt *time.Time `gorm:"index"` // 本次告警产生时间
Status string // firing or resolved
}
func (*AlertMessage) ColumnSlice ¶
func (a *AlertMessage) ColumnSlice() []string
func (*AlertMessage) ToNormalMessage ¶
func (a *AlertMessage) ToNormalMessage() Message
func (*AlertMessage) ValueSlice ¶
func (a *AlertMessage) ValueSlice() []string
type Application ¶
type Application struct {
ID uint `gorm:"primarykey"`
ApplicationName string `gorm:"type:varchar(50);uniqueIndex:uniq_idx_project_applicationname;<-:create"` // 应用名字
Environment *Environment `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"` // 关联的环境
EnvironmentID *uint `gorm:"uniqueIndex:uniq_idx_project_applicationname;"` // 关联的环境
Project *Project `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"` // 所属项
ProjectID uint `gorm:"uniqueIndex:uniq_idx_project_applicationname"` // 所属项目ID
Remark string // 备注
Kind string // 类型
Images datatypes.JSON // 镜像,逗号分割
Labels datatypes.JSON // Label
Creator string // 创建人
CreatedAt time.Time `sql:"DEFAULT:'current_timestamp'"` // 创建时间
}
Application 应用表
type AuditLog ¶
type AuditLog struct {
ID uint `gorm:"primarykey"`
CreatedAt time.Time `gorm:"index"`
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
// 操作用户
Username string `gorm:"type:varchar(50)"`
// 所属租户
Tenant string `gorm:"type:varchar(50)"`
// 操作模块 (资源类型,租户,项目,环境,报警规则等等)
Module string `gorm:"type:varchar(512)"`
// 模块名字
Name string `gorm:"type:varchar(512)"`
// 动作名字 (启用,禁用,开启,关闭,添加,删除,修改等)
Action string `gorm:"type:varchar(255)"`
// 是否成功 请求是否成功
Success bool
// 客户端ip 发起请求的客户端IP
ClientIP string `gorm:"type:varchar(255)"`
// 标签 记录一些额外的环境租户等数据信息
Labels datatypes.JSON
// 原始数据 记录的是request和response以及http_code
RawData datatypes.JSON
}
审计日志的描述格式为:
{用户名} {时间} {操作}
操作:
{动作,增删查改} {资源类型} {资源名字}
AuditLog 审计日志表
type AuthSource ¶
type AuthSource struct {
ID uint `json:"id"`
Name string `gorm:"unique" json:"name"`
Kind string `json:"kind" binding:"oneof=LDAP OAUTH"`
Vendor string `gorm:"type:varchar(30)" json:"vendor" binding:"omitempty,oneof=github gitlab oauth ldap"`
Config AuthSourceConfig `json:"config" binding:"required,json"`
TokenType string `json:"tokenType" binding:"required,oneof=Bearer"`
Enabled bool `json:"enabled"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
}
type AuthSourceConfig ¶
type AuthSourceConfig struct {
AuthURL string `json:"authURL,omitempty" binding:"omitempty,url,required_with=TokenURL UserInfoURL RedirectURL AppID AppSecret"`
TokenURL string `json:"tokenURL,omitempty" binding:"omitempty,url,required_with=AuthURL UserInfoURL RedirectURL AppID AppSecret"`
UserInfoURL string `json:"userInfoURL,omitempty" binding:"omitempty,url,required_with=AuthURL TokenURL RedirectURL AppID AppSecret"`
RedirectURL string `json:"redirectURL,omitempty" binding:"omitempty,url,required_with=AuthURL TokenURL UserInfoURL AppID AppSecret"`
AppID string `json:"appID,omitempty" binding:"required_with=AuthURL TokenURL UserInfoURL RedirectURL AppSecret"`
AppSecret string `json:"appSecret,omitempty" binding:"required_with=AuthURL TokenURL UserInfoURL RedirectURL AppID"`
Scopes []string `json:"scopes,omitempty"`
// ldap
Name string `json:"name,omitempty"`
LdapAddr string `json:"ldapaddr,omitempty" binding:"omitempty,hostname_port,required_with=BaseDN BindUsername BindPassword"`
BaseDN string `json:"basedn,omitempty" binding:"required_with=LdapAddr BindUsername BindPassword"`
EnableTLS bool `json:"enableTLS,omitempty"`
Filter string `json:"filter,omitempty"`
BindUsername string `json:"binduser,omitempty" binding:"required_with=LdapAddr BaseDN BindPassword"`
BindPassword string `json:"password,omitempty" binding:"required_with=LdapAddr BaseDN BindUsername"`
}
type AuthSourceSimple ¶
type AuthSourceSimple struct {
ID uint `json:"id"`
Name string `gorm:"unique" json:"name"`
Kind string `json:"kind"`
Enabled bool `json:"enabled"`
Vendor string `json:"vendor"`
}
type CPUMemoryStatus ¶
type CPUMemoryStatus struct {
CurrentRate float64
CurrentLimit string // 带单位
Status string // 扩容或缩容
SuggestLimit string // 带单位
SuggestMinLimit string // 带单位
SuggestMaxLimit string // 带单位
}
func (*CPUMemoryStatus) AddSuggest ¶
func (status *CPUMemoryStatus) AddSuggest(SuggestType string, currentUsage float64) *CPUMemoryStatus
type ChartRepo ¶
type ChartRepo struct {
ID uint `gorm:"primarykey"`
ChartRepoName string `gorm:"type:varchar(50);uniqueIndex" binding:"required"`
URL string `gorm:"type:varchar(255)"`
LastSync *time.Time
SyncStatus string
SyncMessage string
}
type Cluster ¶
type Cluster struct {
ID uint `gorm:"primarykey"`
ClusterName string `gorm:"type:varchar(50);uniqueIndex" binding:"required"`
APIServer string `gorm:"type:varchar(250);uniqueIndex"` // APIServer地址 根据kubeconfig添加后,自动填充
KubeConfig datatypes.JSON `binding:"required"`
// Vendor 集群提供商(gke tke ack selfhosted)
Vendor string `gorm:"type:varchar(50);default:selfhosted" binding:"required,oneof=selfhosted gke ack tke"`
// ImageRepo 安装kubegems核心组件时使用的镜像仓库
ImageRepo string `gorm:"type:varchar(255);default:docker.io/kubegems" binding:"required"`
// DefaultStorageClass 默认storageclass, 默认local-path
DefaultStorageClass string `gorm:"type:varchar(255);default:local-path" binding:"required"`
InstallNamespace string // agent service namespace
Version string // apiserver version
AgentAddr string // if empty, using apiserver proxy
AgentCA string `json:"-"`
AgentCert string `json:"-"`
AgentKey string `json:"-"`
Runtime string // docker or containerd
Primary bool // 是否主集群
OversoldConfig datatypes.JSON // 集群资源超卖设置
Environments []*Environment
TenantResourceQuotas []*TenantResourceQuota
ClusterResourceQuota datatypes.JSON
DeletedAt gorm.DeletedAt // soft delete
}
Cluster 集群表
type CommonUserIface ¶
type CommonUserIface interface {
GetID() uint
GetSystemRoleID() uint
GetUsername() string
GetUserKind() string
GetEmail() string
GetSource() string
SetLastLogin(*time.Time)
UnmarshalBinary(data []byte) error
MarshalBinary() (data []byte, err error)
}
type Condition ¶
type Condition struct {
Pods []string
CPUStatus *CPUMemoryStatus `json:"CPUStatus"`
MemoryStatus *CPUMemoryStatus `json:"MemoryStatus"`
MaxCPUContainer *Container `json:"-"`
MaxMemoryContainer *Container `json:"-"`
CPULimitCore float64 `json:"-"`
MemoryLimitBytes int64 `json:"-"`
}
type Container ¶
type Container struct {
ID uint `gorm:"primarykey"`
Name string
PodName string
CPULimitCore float64
MemoryLimitBytes int64 // 限制
CPUUsageCore float64
CPUPercent float64 // 使用率
MemoryUsageBytes float64
MemoryPercent float64 // 使用率
WorkloadID uint
Workload *Workload `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
}
Container 不注册为gorm model
type EdgeData ¶
type EdgeData struct {
// Cytoscape Fields
ID string `json:"id"` // unique internal edge ID (e0, e1...)
Source string `json:"source"` // parent node ID
Target string `json:"target"` // child node ID
}
type EdgeWrapper ¶
type EdgeWrapper struct {
Data *EdgeData `json:"data"`
}
type Elements ¶
type Elements struct {
Nodes []*NodeWrapper `json:"nodes"`
Edges []*EdgeWrapper `json:"edges"`
}
type Environment ¶
type Environment struct {
ID uint `gorm:"primarykey"`
// 环境名字
EnvironmentName string `gorm:"type:varchar(50);uniqueIndex:uniq_idx_project_env;index:environment_uniq,unique"`
// 环境关联的namespace
Namespace string `gorm:"type:varchar(50)"`
// 备注
Remark string
// 元类型(开发(dev),测试(test),生产(prod))等选项之一
MetaType string
// 删除策略(delNamespace删除namespace,delLabels仅删除关联LABEL)
DeletePolicy string `sql:"DEFAULT:'delNamespace'"`
// 创建者
Creator *User
// 关联的集群
Cluster *Cluster `gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
// 所属项目
Project *Project `gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
// 环境资源限制(这个会和namespace下的ResourceQuota对等)
ResourceQuota datatypes.JSON
// 环境下的limitrage
LimitRange datatypes.JSON
// 所属项目ID
ProjectID uint `gorm:"uniqueIndex:uniq_idx_project_env"`
// 所属集群ID
ClusterID uint
// 创建人ID
CreatorID uint
// 关联的应用
Applications []*Application `gorm:"many2many:application_environment_rels;"`
// 关联的用户
Users []*User `gorm:"many2many:environment_user_rels;"`
// 虚拟空间
VirtualSpaceID *uint
VirtualSpace *VirtualSpace `gorm:"constraint:OnUpdate:RESTRICT,OnDelete:SET NULL;"`
NSLabels map[string]string `gorm:"-"`
}
Environment 环境表 环境属于项目,项目id-环境名字 唯一索引
type EnvironmentResource ¶
type EnvironmentResource struct {
ID uint `gorm:"primarykey"`
CreatedAt time.Time `sql:"DEFAULT:'current_timestamp'"`
ClusterName string
TenantName string
ProjectName string
EnvironmentName string
MaxCPUUsageCore float64
MaxMemoryUsageByte float64
MinCPUUsageCore float64
MinMemoryUsageByte float64
AvgCPUUsageCore float64
AvgMemoryUsageByte float64
NetworkReceiveByte float64
NetworkSendByte float64
MaxPVCUsageByte float64
MinPVCUsageByte float64
AvgPVCUsageByte float64
}
EnvironmentResource Project资源使用清单
type EnvironmentUserRels ¶
type EnvironmentUserRels struct {
ID uint `gorm:"primarykey"`
User *User `json:",omitempty" gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
Environment *Environment `json:"omitempty" gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
// 用户ID
UserID uint `gorm:"uniqueIndex:uniq_idx_env_user_rel" binding:"required"`
// EnvironmentID
EnvironmentID uint `gorm:"uniqueIndex:uniq_idx_env_user_rel" binding:"required"`
// 环境级角色("reader", "operator")
Role string `binding:"required,eq=reader|eq=operator"`
}
EnvironmentUserRels
type Graph ¶
type Graph struct {
GraphType string `json:"graphType"`
Elements Elements `json:"elements"`
}
type KubeClient ¶
type KubeClient interface {
GetEnvironment(cluster, name string, _ map[string]string) (*v1beta1.Environment, error)
PatchEnvironment(cluster, name string, data *v1beta1.Environment) (*v1beta1.Environment, error)
DeleteEnvironment(clustername, environment string) error
CreateOrUpdateEnvironment(clustername, environment string, spec v1beta1.EnvironmentSpec) error
CreateOrUpdateTenant(clustername, tenantname string, admins, members []string) error
CreateOrUpdateTenantResourceQuota(clustername, tenantname string, content []byte) error
CreateOrUpdateSecret(clustername, namespace, name string, data map[string][]byte) error
DeleteSecretIfExist(clustername, namespace, name string) error
DeleteTenant(clustername, tenantname string) error
}
func GetKubeClient ¶
func GetKubeClient() KubeClient
type LogQueryHistory ¶
type LogQueryHistory struct {
ID uint `gorm:"primarykey"`
// 关联的集群
Cluster *Cluster `gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
// 所属集群ID
ClusterID uint
// 标签
LabelJSON string `gorm:"type:varchar(1024)"`
// 正则标签
FilterJSON string `gorm:"type:varchar(1024)"`
// logql
LogQL string `gorm:"type:varchar(1024)"`
// 创建时间
CreateAt time.Time `sql:"DEFAULT:'current_timestamp'"`
// 创建者
Creator *User
CreatorID uint
}
LogQueryHistory 日志查询历史
type LogQueryHistoryWithCount ¶
type LogQueryHistoryWithCount struct {
ID uint
Ids string
Cluster *Cluster
ClusterID uint
LabelJSON string
FilterJSON string
LogQL string
CreateAt time.Time
Creator *User
CreatorID uint
Total string
}
type LogQuerySnapshot ¶
type LogQuerySnapshot struct {
ID uint `gorm:"primarykey"`
// 关联的集群
Cluster *Cluster `gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
// 所属集群ID
ClusterID uint
// 名称
SnapshotName string `gorm:"type:varchar(128)"`
SourceFile string `gorm:"type:varchar(128)"`
// 行数
SnapshotCount int
// 下载地址
DownloadURL string `gorm:"type:varchar(512)"`
StartTime time.Time
EndTime time.Time
// 创建时间
CreateAt time.Time `sql:"DEFAULT:'current_timestamp'"`
// 创建者
Creator *User
CreatorID uint
}
LogQuerySnapshot 日志查询快照
func (*LogQuerySnapshot) BeforeCreate ¶
func (snapshot *LogQuerySnapshot) BeforeCreate(tx *gorm.DB) error
func (*LogQuerySnapshot) BeforeDelete ¶
func (snapshot *LogQuerySnapshot) BeforeDelete(tx *gorm.DB) error
type Message ¶
type Message struct {
ID uint `gorm:"primarykey"`
MessageType string `gorm:"type:varchar(50);"`
Title string `gorm:"type:varchar(255);"`
Content datatypes.JSON
CreatedAt time.Time `gorm:"index" sql:"DEFAULT:'current_timestamp'"`
ToUsers map[uint]struct{} `gorm:"-" json:"-"`
IsRead bool `gorm:"-"` // 给前端用,不入库
}
func (*Message) ColumnSlice ¶
func (msg *Message) ColumnSlice() []string
func (*Message) ValueSlice ¶
func (msg *Message) ValueSlice() []string
type MetricGraph ¶
type MetricGraph struct {
// graph名
Name string `json:"name"`
// 查询目标
*prometheus.PromqlGenerator `json:"promqlGenerator"`
Expr string `json:"expr"`
Unit string `json:"unit"`
}
type MetricRow ¶
type MetricRow struct {
AppName string `json:"appName"`
RealTimeRate float64 `json:"realTimeRate"`
AvgOfHour float64 `json:"avgOfHour"`
AvgOfDay float64 `json:"avgOfDay"`
}
type MetricTable ¶
type MetricTable struct {
Rows []MetricRow `json:"rows"`
}
type MonitorDashboard ¶
type MonitorDashboard struct {
ID uint `gorm:"primarykey" json:"id"`
// 面板名
Name string `gorm:"type:varchar(50);uniqueIndex" binding:"required" json:"name"`
Step string `gorm:"type:varchar(50);" json:"step"` // 样本间隔,单位秒
Refresh string `json:"refresh"` // 刷新间隔,eg. 30s, 1m
Start string `json:"start"` // 开始时间,eg. 2022-04-24 06:00:45.241, now, now-30m
End string `json:"end"` // 结束时间
CreatedAt *time.Time `json:"createdAt"`
Creator string `gorm:"type:varchar(50);" json:"creator"` // 创建者
Graphs MonitorGraphs `json:"graphs"` // 图表
Template string `gorm:"type:varchar(50);" json:"template"` // 模板名
EnvironmentID *uint
Environment *Environment `gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
}
MonitorDashboard 监控面板
type MonitorGraphs ¶
type MonitorGraphs []MetricGraph
func (MonitorGraphs) GormDataType ¶
func (g MonitorGraphs) GormDataType() string
func (*MonitorGraphs) Scan ¶
func (g *MonitorGraphs) Scan(src interface{}) error
实现几个自定义数据类型的接口 https://gorm.io/zh_CN/docs/data_types.html
type NodeData ¶
type NodeData struct {
// Cytoscape Fields
ID string `json:"id"` // unique internal node ID (n0, n1...)
Parent string `json:"parent,omitempty"` // Compound Node parent ID
// NOTE: add new custom field
NodeType string `json:"nodeType"`
}
type NodeType ¶
type NodeType string
const (
Matcher NodeType = "matcher"
Filter NodeType = "filter"
Output NodeType = "output"
GlobalOutput NodeType = "globaloutput"
)
type NodeWrapper ¶
type NodeWrapper struct {
Data *NodeData `json:"data"`
}
type Notice ¶
type Notice struct {
Color string // eg, yellow
Conditions map[string]Condition // 按容器名分组
}
type OnlineConfig ¶
type OnlineConfig struct {
Name string `gorm:"type:varchar(50);primaryKey" binding:"required" json:"name"` // 配置名
Content datatypes.JSON `json:"content"` // 配置内容
CreatedAt *time.Time
UpdatedAt *time.Time
}
OnlineConfig 系统配置
type Project ¶
type Project struct {
ID uint `gorm:"primarykey"`
// 创建时间
CreatedAt time.Time `sql:"DEFAULT:'current_timestamp'"`
// 项目名字
ProjectName string `gorm:"type:varchar(50);uniqueIndex:uniq_idx_tenant_project_name"`
// 项目别名
ProjectAlias string `gorm:"type:varchar(50)"`
// 项目备注
Remark string
// 项目资源限制
ResourceQuota datatypes.JSON
Applications []*Application
Environments []*Environment
Registries []*Registry
Users []*User `gorm:"many2many:project_user_rels;"`
Tenant *Tenant `gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
// 所属的租户ID
TenantID uint `gorm:"uniqueIndex:uniq_idx_tenant_project_name"`
}
Project 项目表
type ProjectUserRels ¶
type ProjectUserRels struct {
ID uint `gorm:"primarykey"`
User *User `json:",omitempty" gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
Project *Project `json:",omitempty" gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
// 用户ID
UserID uint `gorm:"uniqueIndex:uniq_idx_project_user_rel" binding:"required"`
// ProjectID
ProjectID uint `gorm:"uniqueIndex:uniq_idx_project_user_rel" binding:"required"`
// 项目级角色(管理员admin, 开发dev, 测试test, 运维ops)
Role string `gorm:"type:varchar(30)" binding:"required,eq=admin|eq=test|eq=dev|eq=ops"`
}
ProjectUserRels
type Registry ¶
type Registry struct {
ID uint `gorm:"primarykey"`
// 仓库名称
RegistryName string `gorm:"type:varchar(50);uniqueIndex:uniq_idx_project_registry;"`
// 仓库地址
RegistryAddress string `gorm:"type:varchar(512)"`
// 用户名
Username string `gorm:"type:varchar(50)"`
// 密码
Password string `gorm:"type:varchar(512)"`
// 创建者
Creator *User
// 更新时间
UpdateTime time.Time
CreatorID uint
Project *Project `gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
// 项目ID
ProjectID uint `grom:"uniqueIndex:uniq_idx_project_registry;"`
IsDefault bool
EnableExtends bool // 是否启用扩展功能,支持harbor等高级仓库
}
Registry 镜像仓库表
type SystemRole ¶
type SystemRole struct {
ID uint `gorm:"primarykey"`
// 角色名字
RoleName string
// 系统级角色Code(管理员admin, 普通用户ordinary)
RoleCode string `gorm:"type:varchar(30)" binding:"required,eq=sysadmin|eq=normal"`
Users []*User
}
SystemRole 系统角色
type Tenant ¶
type Tenant struct {
ID uint `gorm:"primarykey"`
// 租户名字
TenantName string `gorm:"type:varchar(50);uniqueIndex"`
// 备注
Remark string
// 是否激活
IsActive bool
CreatedAt time.Time `sql:"DEFAULT:'current_timestamp'"`
UpdatedAt time.Time `sql:"DEFAULT:'current_timestamp'"`
ResourceQuotas []*TenantResourceQuota
Users []*User `gorm:"many2many:tenant_user_rels;"`
Projects []*Project
AllocatedResourcequota v1.ResourceList `gorm:"-"`
}
Tenant 租户表
type TenantResourceQuota ¶
type TenantResourceQuota struct {
ID uint
Content datatypes.JSON
TenantID uint `gorm:"uniqueIndex:uniq_tenant_cluster" binding:"required"`
ClusterID uint `gorm:"uniqueIndex:uniq_tenant_cluster" binding:"required"`
Tenant *Tenant `gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
Cluster *Cluster `gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
TenantResourceQuotaApply *TenantResourceQuotaApply `gorm:"constraint:OnUpdate:RESTRICT,OnDelete:SET NULL;"`
TenantResourceQuotaApplyID *uint
}
type TenantResourceQuotaApply ¶
type TenantResourceQuotaApply struct {
ID uint
Content datatypes.JSON
Status string `gorm:"type:varchar(30);"`
Username string `gorm:"type:varchar(255);"`
UpdatedAt time.Time `sql:"DEFAULT:'current_timestamp'"`
}
TenantResourceQuotaApply 集群资源申请
type TenantUserRels ¶
type TenantUserRels struct {
ID uint `gorm:"primarykey"`
Tenant *Tenant `json:",omitempty" gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
// 租户ID
TenantID uint `gorm:"uniqueIndex:uniq_idx_tenant_user_rel"`
User *User `json:",omitempty" gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
// 用户ID
UserID uint `gorm:"uniqueIndex:uniq_idx_tenant_user_rel"`
// 租户级角色(管理员admin, 普通用户ordinary)
Role string `gorm:"type:varchar(30)" binding:"required"`
}
TenantUserRels 租户-用户-关系表 租户id-用户id-类型 唯一索引
type User ¶
type User struct {
ID uint `gorm:"primarykey"`
// 用户名
Username string `gorm:"type:varchar(50);uniqueIndex" binding:"required"`
// 邮箱
Email string `gorm:"type:varchar(50)" binding:"required"`
// 电话
Phone string `gorm:"type:varchar(255)"`
Password string `gorm:"type:varchar(255)" json:"-"`
// 是否激活
IsActive *bool `sql:"DEFAULT:true"`
// 加入时间
CreatedAt *time.Time `sql:"DEFAULT:'current_timestamp'"`
// 最后登录时间
LastLoginAt *time.Time `sql:"DEFAULT:'current_timestamp'"`
Source string `gorm:"type:varchar(50)"`
SourceVendor string `gorm:"type:varchar(50)"`
Tenants []*Tenant `gorm:"many2many:tenant_user_rels;"`
SystemRole *SystemRole
SystemRoleID uint
// 角色,不同关联对象下表示的角色不同, 用来做join查询的时候处理角色字段的(请勿删除)
Role string `sql:"-" json:",omitempty"`
}
User 用户表
func (*User) GetSystemRoleID ¶
func (u *User) GetSystemRoleID() uint
func (*User) GetUserKind ¶
func (u *User) GetUserKind() string
func (*User) GetUsername ¶
func (u *User) GetUsername() string
func (*User) SetLastLogin ¶
func (u *User) SetLastLogin(t *time.Time)
func (*User) UnmarshalBinary ¶
func (u *User) UnmarshalBinary(data []byte) error
type UserCreate ¶
type UserCreate struct {
ID uint `json:"id"`
Username string `json:"username" binding:"required"`
Email string `json:"email" binding:"required,email"`
Password string `json:"password" binding:"min=8"`
}
type UserMessageStatus ¶
type UserMessageStatus struct {
ID uint
UserID uint
User *User `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
MessageID *uint
Message *Message `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
IsRead bool `gorm:"index"`
AlertMessageID *uint
AlertMessage *AlertMessage `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}
func (*UserMessageStatus) ColumnSlice ¶
func (status *UserMessageStatus) ColumnSlice() []string
func (*UserMessageStatus) ValueSlice ¶
func (status *UserMessageStatus) ValueSlice() []string
type VirtualDomain ¶
type VirtualDomain struct {
ID uint `gorm:"primarykey"`
VirtualDomainName string `gorm:"type:varchar(50);uniqueIndex"`
CreatedAt time.Time `sql:"DEFAULT:'current_timestamp'"`
UpdatedAt time.Time `sql:"DEFAULT:'current_timestamp'"`
IsActive bool // 是否激活
CreatedBy string
}
type VirtualSpace ¶
type VirtualSpace struct {
ID uint `gorm:"primarykey"`
VirtualSpaceName string `gorm:"type:varchar(50);uniqueIndex"`
CreatedAt time.Time `sql:"DEFAULT:'current_timestamp'"`
UpdatedAt time.Time `sql:"DEFAULT:'current_timestamp'"`
IsActive bool
CreatedBy string
Users []*User `gorm:"many2many:virtual_space_user_rels;"`
Environments []*Environment
}
type VirtualSpaceUserRels ¶
type VirtualSpaceUserRels struct {
ID uint `gorm:"primarykey"`
VirtualSpaceID uint `gorm:"uniqueIndex:uniq_idx_virtual_space_user_rel"`
VirtualSpace *VirtualSpace `json:",omitempty" gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
UserID uint `gorm:"uniqueIndex:uniq_idx_virtual_space_user_rel;constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
User *User `json:",omitempty" gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
// 虚拟空间角色(管理员admin, 普通用户normal)
Role string `gorm:"type:varchar(30)" binding:"required,eq=admin|eq=normal"`
}
type Workload ¶
type Workload struct {
ID uint `gorm:"primarykey"`
CreatedAt time.Time `sql:"DEFAULT:'current_timestamp'"`
ClusterName string
Namespace string
Type string
Name string
CPULimitStdvar float64
MemoryLimitStdvar float64
Containers []*Container `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"-"`
*Notice `gorm:"-"`
}
Workload workload资源使用清单
Source Files
¶
- base.go
- kubeclient.go
- model_alert.go
- model_application.go
- model_auditlogs.go
- model_auth.go
- model_chartrepo.go
- model_cluster.go
- model_config.go
- model_environment.go
- model_environment_resource.go
- model_log.go
- model_logging.go
- model_message.go
- model_monitor_dashboard.go
- model_project.go
- model_registry.go
- model_systemrole.go
- model_tenant.go
- model_user.go
- model_virtual_domain.go
- model_virtual_space.go
- model_workload.go
- useriface.go
Click to show internal directories.
Click to hide internal directories.