models

package
v1.21.0-rc.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SyncStatusRunning = "running"
	SyncStatusError   = "error"
	SyncStatusSuccess = "success"
)
View Source
const (
	ClusterModeProxy   = "apiServerProxy"
	ClusterModeService = "service"
	ResCluster         = "cluster"

	ClusterTableName = "clusters"
)
View Source
const (
	EnvironmentRoleReader   = "reader"
	EnvironmentRoleOperator = "operator"

	ResEnvironment = "environment"

	EnvironmentMetaTypeDev  = "dev"
	EnvironmentMetaTypeTest = "test"
	EnvironmentMetaTypeProd = "prod"
)
View Source
const (
	ProjectRoleAdmin = "admin"
	ProjectRoleDev   = "dev"
	ProjectRoleTest  = "test"
	ProjectRoleOps   = "ops"

	ResProject       = "project"
	ProjectTableName = "projects"
)
View Source
const (
	SystemRoleAdmin    = "sysadmin"
	SystemRoleOrdinary = "ordinary"

	ResSystemRole = "systemrole"
)
View Source
const (
	TenantRoleAdmin    = "admin"
	TenantRoleOrdinary = "ordinary"
	ResTenant          = "tenant"

	TenantTableName     = "tenants"
	QuotaStatusApproved = "approved"
	QuotaStatusRejected = "rejected"
	QuotaStatusPending  = "pending"
)
View Source
const (
	ResUser = "user"

	UserTableName = "users"
)
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 (
	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

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);"`
	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"`
	Name          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"`
	Remark        string
	Kind          string
	Images        datatypes.JSON
	Labels        datatypes.JSON
	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
	Name      string `gorm:"unique"`
	Kind      string
	Config    datatypes.JSON
	TokenType string
	Enabled   bool
	CreatedAt *time.Time
	UpdatedAt *time.Time // 创建时间
}

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"`
	Name        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"`
	Name                 string         `gorm:"type:varchar(50);uniqueIndex" binding:"required"`
	APIServer            string         `gorm:"type:varchar(250);uniqueIndex"`
	KubeConfig           datatypes.JSON `binding:"required"`
	Version              string
	AgentAddr            string
	AgentCA              string `json:"-"`
	AgentCert            string `json:"-"`
	AgentKey             string `json:"-"`
	Mode                 string `json:"-"`
	Runtime              string // docker or containerd
	Primary              bool
	OversoldConfig       datatypes.JSON
	Environments         []*Environment
	TenantResourceQuotas []*TenantResourceQuota
	ClusterResourceQuota datatypes.JSON
}

Cluster 集群表

type ClusterGetter

type ClusterGetter struct {
	// contains filtered or unexported fields
}

func (ClusterGetter) GetByName

func (g ClusterGetter) GetByName(name string) (agentAddr, mode string, agentcert, agentkey, agentca, kubeconfig []byte, err error)

func (ClusterGetter) GetManagerCluster

func (g ClusterGetter) GetManagerCluster(_ context.Context) (string, error)

func (ClusterGetter) ListCluster

func (g ClusterGetter) ListCluster() []string

type ClusterSimple

type ClusterSimple struct {
	ID        uint
	Name      string
	APIServer string
	Version   string
}

func (ClusterSimple) TableName

func (ClusterSimple) TableName() string

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 Environment

type Environment struct {
	ID        uint   `gorm:"primarykey"`
	Name      string `gorm:"type:varchar(50);uniqueIndex:uniq_idx_project_env;index:environment_uniq,unique"`
	Remark    string
	Namespace string `gorm:"type:varchar(50)"`
	// MetaTpe (dev, prod, test, pub ...)
	MetaType       string
	DeletePolicy   string `sql:"DEFAULT:'delNamespace'"`
	Creator        *User
	CreatorID      uint
	Cluster        *Cluster `gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
	ClusterID      uint
	Project        *Project `gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
	ProjectID      uint     `gorm:"uniqueIndex:uniq_idx_project_env"`
	VirtualSpaceID *uint
	VirtualSpace   *VirtualSpace `gorm:"constraint:OnUpdate:RESTRICT,OnDelete:SET NULL;"`
	ResourceQuota  datatypes.JSON
	LimitRange     datatypes.JSON
	Applications   []*Application `gorm:"many2many:application_environment_rels;"`
	Users          []*User        `gorm:"many2many:environment_user_rels;"`
}

type EnvironmentCommon

type EnvironmentCommon struct {
	ID            uint           `json:"id,omitempty"`
	Name          string         `json:"name,omitempty"`
	Remark        string         `json:"remark,omitempty"`
	Namespace     string         `json:"namespace,omitempty"`
	MetaType      string         `json:"metaType,omitempty"`
	DeletePolicy  string         `json:"deletePolicy,omitempty"`
	Creator       *User          `json:"creator,omitempty"`
	Cluster       *ClusterSimple `json:"cluster,omitempty"`
	ResourceQuota datatypes.JSON `json:"resourceQuota,omitempty"`
	LimitRange    datatypes.JSON `json:"limitRange,omitempty"`
}

type EnvironmentResource

type EnvironmentResource struct {
	ID        uint      `gorm:"primarykey"`
	CreatedAt time.Time `sql:"DEFAULT:'current_timestamp'"`

	Cluster     string
	Tenant      string
	Project     string
	Environment 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"`
	Environment   *Environment `json:"omitempty" gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
	UserID        uint         `gorm:"uniqueIndex:uniq_idx_env_user_rel" binding:"required"`
	EnvironmentID uint         `gorm:"uniqueIndex:uniq_idx_env_user_rel" binding:"required"`
	Role          string       `binding:"required,eq=reader|eq=operator"`
}

EnvironmentUserRels

type LogQueryHistory

type LogQueryHistory struct {
	ID         uint     `gorm:"primarykey"`
	Cluster    *Cluster `gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
	ClusterID  uint
	LabelJSON  string    `gorm:"type:varchar(1024)"`
	FilterJSON string    `gorm:"type:varchar(1024)"`
	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;"`
	ClusterID    uint
	SnapshotName string `gorm:"type:varchar(128)"`
	SourceFile   string `gorm:"type:varchar(128)"`
	// line count
	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
}

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 MetricDashborad

type MetricDashborad struct {
	ID        uint   `gorm:"primarykey"`
	Name      string `gorm:"type:varchar(50);uniqueIndex" binding:"required"`
	Topk      int
	Step      string `gorm:"type:varchar(50);"`
	CreatedAt *time.Time
	Creator   string `gorm:"type:varchar(50);"` // 创建者
	Graphs    MetricGraphs
}

MetricDashborad 监控面板

type MetricGraph

type MetricGraph struct {
	// graph名
	Name string `json:"name"`

	// 查询范围
	Cluster       string `json:"cluster,omitempty"`
	Namespace     string `json:"namespace,omitempty"`
	EnvironmentID string `json:"environment_id,omitempty"`

	// 查询目标
	PromqlGenerator prometheus.PromqlGenerator `json:"promqlGenerator"`
}

type MetricGraphs

type MetricGraphs []MetricGraph

func (MetricGraphs) GormDataType

func (g MetricGraphs) GormDataType() string

func (*MetricGraphs) Scan

func (g *MetricGraphs) Scan(src interface{}) error

实现几个自定义数据类型的接口 https://gorm.io/zh_CN/docs/data_types.html

func (MetricGraphs) Value

func (g MetricGraphs) Value() (driver.Value, error)

注意这里不是指针,下同

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'"`
	Name          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;"`
	TenantID      uint    `gorm:"uniqueIndex:uniq_idx_tenant_project_name"`
}

type ProjectCommon

type ProjectCommon struct {
	ID            uint           `json:"id,omitempty"`
	CreatedAt     time.Time      `json:"createdAt,omitempty"`
	Name          string         `json:"name,omitempty"`
	ProjectAlias  string         `json:"projectAlias,omitempty"`
	Remark        string         `json:"remark,omitempty"`
	ResourceQuota datatypes.JSON `json:"resourceQuota,omitempty"`
}

func (ProjectCommon) TableName

func (ProjectCommon) TableName() string

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;"`
	UserID    uint     `gorm:"uniqueIndex:uniq_idx_project_user_rel" binding:"required"`
	ProjectID uint     `gorm:"uniqueIndex:uniq_idx_project_user_rel" binding:"required"`
	Role      string   `gorm:"type:varchar(30)" binding:"required,eq=admin|eq=test|eq=dev|eq=ops"`
}

type Registry

type Registry struct {
	ID         uint   `gorm:"primarykey"`
	Name       string `gorm:"type:varchar(50);uniqueIndex:uniq_idx_project_registry;"`
	Address    string `gorm:"type:varchar(512)"`
	Username   string `gorm:"type:varchar(50)"`
	Password   string `gorm:"type:varchar(512)"`
	Creator    *User
	CreatorID  uint
	UpdateTime time.Time
	Project    *Project `gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
	ProjectID  uint     `grom:"uniqueIndex:uniq_idx_project_registry;"`
	IsDefault  bool
}

Registry image registry

type SystemRole

type SystemRole struct {
	ID    uint `gorm:"primarykey"`
	Name  string
	Code  string `gorm:"type:varchar(30)" binding:"required,eq=sysadmin|eq=normal"`
	Users []*User
}

type Tenant

type Tenant struct {
	ID             uint   `gorm:"primarykey"`
	Name           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
}

type TenantCommon

type TenantCommon struct {
	ID        uint      `json:"id,omitempty"`
	Name      string    `json:"name,omitempty"`
	Remark    string    `json:"remark,omitempty"`
	IsActive  bool      `json:"isActive,omitempty"`
	CreatedAt time.Time `json:"createdAt,omitempty"`
	UpdatedAt time.Time `json:"updatedAt,omitempty"`
}

func (TenantCommon) TableName

func (TenantCommon) TableName() string

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;"`
}

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'"`
	CreateAt  time.Time `sql:"DEFAULT:'current_timestamp'"`
	Creator   *User
	CreatorID uint
	TenantID  uint     `gorm:"uniqueIndex:uniq_tenant_cluster_rq" binding:"required"`
	ClusterID uint     `gorm:"uniqueIndex:uniq_tenant_cluster_rq" binding:"required"`
	Tenant    *Tenant  `gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
	Cluster   *Cluster `gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
}

TenantResourceQuotaApply 集群资源申请

type TenantSimple

type TenantSimple struct {
	ID     uint   `json:"id,omitempty"`
	Name   string `validate:"required" json:"name,omitempty"`
	Remark string `validate:"required" json:"remark,omitempty"`
}

func (TenantSimple) TableName

func (TenantSimple) TableName() string

type TenantUserRels

type TenantUserRels struct {
	ID       uint    `gorm:"primarykey"`
	Tenant   *Tenant `json:",omitempty" gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
	TenantID uint    `gorm:"uniqueIndex:uniq_idx_tenant_user_rel"`
	User     *User   `json:",omitempty" gorm:"constraint:OnUpdate:RESTRICT,OnDelete:CASCADE;"`
	UserID   uint    `gorm:"uniqueIndex:uniq_idx_tenant_user_rel"`
	Role     string  `gorm:"type:varchar(30)" binding:"required"`
}

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)" binding:"required"`
	Password     string     `gorm:"type:varchar(255)" json:"-"`
	IsActive     *bool      `sql:"DEFAULT:true"`
	Source       string     `gorm:"type:varchar(255)" json:"-"`
	CreatedAt    *time.Time `sql:"DEFAULT:'current_timestamp'"`
	LastLoginAt  *time.Time `sql:"DEFAULT:'current_timestamp'"`
	Tenants      []*Tenant  `gorm:"many2many:tenant_user_rels;"`
	SystemRole   *SystemRole
	SystemRoleID uint
}

func (User) MarshalBinary

func (u User) MarshalBinary() ([]byte, error)

implement redis

func (*User) UnmarshalBinary

func (u *User) UnmarshalBinary(data []byte) error

type UserCommon

type UserCommon struct {
	ID           uint        `json:"id,omitempty"`
	Username     string      `json:"username,omitempty"`
	Email        string      `json:"email,omitempty"`
	Phone        string      `json:"phone,omitempty"`
	IsActive     *bool       `json:"isActive,omitempty"`
	CreatedAt    *time.Time  `json:"createdAt,omitempty"`
	Source       string      `gorm:"type:varchar(255)" json:"-"`
	LastLoginAt  *time.Time  `json:"lastLoginAt,omitempty"`
	SystemRole   *SystemRole `json:"systemRole,omitempty"`
	SystemRoleID uint        `json:"systemRoleID,omitempty"`
}

func (*UserCommon) GetEmail

func (u *UserCommon) GetEmail() string

func (*UserCommon) GetID

func (u *UserCommon) GetID() uint

func (*UserCommon) GetSource

func (u *UserCommon) GetSource() string

func (*UserCommon) GetSystemRoleID

func (u *UserCommon) GetSystemRoleID() uint

func (*UserCommon) GetUserKind

func (u *UserCommon) GetUserKind() string

func (*UserCommon) GetUsername

func (u *UserCommon) GetUsername() string

func (UserCommon) MarshalBinary

func (u UserCommon) MarshalBinary() ([]byte, error)

func (*UserCommon) SetLastLogin

func (u *UserCommon) SetLastLogin(t *time.Time)

func (UserCommon) TableName

func (UserCommon) TableName() string

func (*UserCommon) UnmarshalBinary

func (u *UserCommon) UnmarshalBinary(data []byte) error

type UserCreate

type UserCreate struct {
	ID       uint   `json:"id,omitempty"`
	Username string `json:"username,omitempty"`
	Email    string `json:"email,omitempty"`
	Password string `json:"password"`
}

func (UserCreate) TableName

func (UserCreate) TableName() string

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 UserSel

type UserSel struct {
	ID       uint
	Username string
	Email    string
}

type UserSimple

type UserSimple struct {
	ID       uint   `json:"id,omitempty"`
	Username string `json:"username,omitempty"`
	Email    string `json:"email,omitempty"`
	Role     string `json:"role,omitempty"`
}

func (UserSimple) TableName

func (UserSimple) TableName() string

type VirtualDomain

type VirtualDomain struct {
	ID   uint   `gorm:"primarykey"`
	Name 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"`
	Name 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"`
	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资源使用清单

func (*Workload) AddNotice

func (w *Workload) AddNotice()

func (*Workload) UniqueKey

func (w *Workload) UniqueKey() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL