models

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuditLogLevelNormal   AuditLogLevel = "Normal"
	AuditLogLevelWarning  AuditLogLevel = "Warning"
	AuditLogLevelCritical AuditLogLevel = "Critical"

	// CURD
	AuditLogTypeUnknown AuditLogType = "Unknown"
	AuditLogTypeCreate  AuditLogType = "Create"
	AuditLogTypeUpdate  AuditLogType = "Update"
	AuditLogTypeRead    AuditLogType = "Read"
	AuditLogTypeDelete  AuditLogType = "Delete"
)
View Source
const (
	AuthTypeDB     = "db"
	AuthTypeOAuth2 = "oauth2"
	AuthTypeLDAP   = "ldap"
)
View Source
const (
	GroupAdmin     = "管理员"
	GroupViewer    = "访客"
	GroupDeveloper = "项目开发"
)
View Source
const (
	DefaultNamespace = "demo"

	TableNameNamespace = "namespace"
)
View Source
const (
	TableNamePermission = "permission"

	PermissionCreate  = "CREATE"
	PermissionUpdate  = "UPDATE"
	PermissionRead    = "READ"
	PermissionDelete  = "DELETE"
	PermissionDeploy  = "DEPLOY"
	PermissionOffline = "OFFLINE"

	PermissionTypeApp                   = "APP"
	PermissionTypeAppUser               = "APPUSER"
	PermissionTypeDeployment            = "DEPLOYMENT"
	PermissionTypeSecret                = "SECRET"
	PermissionTypeService               = "SERVICE"
	PermissionTypeConfigMap             = "CONFIGMAP"
	PermissionTypeCronjob               = "CRONJOB"
	PermissionTypePersistentVolumeClaim = "PVC"
	PermissionTypeNamespace             = "NAMESPACE"
	PermissionTypeNamespaceUser         = "NAMESPACEUSER"
	PermissionTypeWebHook               = "WEBHOOK"
	PermissionTypeStatefulset           = "STATEFULSET"
	PermissionTypeDaemonSet             = "DAEMONSET"
	PermissionBill                      = "BILL"
	PermissionTypeAPIKey                = "APIKEY"
	PerMissionTypeIngress               = "INGRESS"
	PermissionBlank                     = "_"
)
View Source
const ListFilterExprSep = "__"
View Source
const (
	TableNameApp = "app"
)
View Source
const (
	TableNameAppStarred = "app_starred"
)
View Source
const (
	TableNameAppUser = "app_user"
)
View Source
const (
	TableNameAuditLog = "audit_log"
)
View Source
const (
	TableNameConfigMap = "config_map"
)
View Source
const (
	TableNameConfigMapTemplate = "config_map_template"
)
View Source
const (
	TableNameCronjob = "cronjob"
)
View Source
const (
	TableNameCronjobTemplate = "cronjob_template"
)
View Source
const (
	TableNameDaemonSet = "daemon_set"
)
View Source
const (
	TableNameDaemonSetTemplate = "daemon_set_template"
)
View Source
const (
	TableNameDeployment = "deployment"
)
View Source
const (
	TableNameDeploymentTemplate = "deployment_template"
)
View Source
const TableNameIngress = "ingress"
View Source
const TableNameIngressTemplate = "ingress_template"
View Source
const (
	TableNameInvoice = "invoice"
)
View Source
const (
	TableNameNamespaceUser = "namespace_user"
)
View Source
const (
	TableNameNotification = "notification"
)
View Source
const (
	TableNameNotificationLog = "notification_log"
)
View Source
const (
	TableNamePersistentVolumeClaim = "persistent_volume_claim"
)
View Source
const (
	TableNamePersistentVolumeClaimTemplate = "persistent_volume_claim_template"
)
View Source
const (
	TableNameSecret = "secret"
)
View Source
const (
	TableNameSecretTemplate = "secret_template"
)
View Source
const (
	TableNameService = "service"
)
View Source
const (
	TableNameServiceTemplate = "service_template"
)
View Source
const (
	TableNameStatefulset = "statefulset"
)
View Source
const (
	TableNameStatefulsetTemplate = "statefulset_template"
)

Variables

View Source
var (
	UserModel                     *userModel
	AppModel                      *appModel
	AppUserModel                  *appUserModel
	AppStarredModel               *appStarredModel
	NamespaceUserModel            *namespaceUserModel
	ClusterModel                  *clusterModel
	DeploymentModel               *deploymentModel
	DeploymentTplModel            *deploymentTplModel
	PermissionModel               *permissionModel
	GroupModel                    *groupModel
	NamespaceModel                *namespaceModel
	ConfigMapModel                *configMapModel
	ConfigMapTplModel             *configMapTplModel
	CronjobModel                  *cronjobModel
	CronjobTplModel               *cronjobTplModel
	SecretModel                   *secretModel
	SecretTplModel                *secretTplModel
	PublishStatusModel            *publishStatusModel
	PublishHistoryModel           *publishHistoryModel
	PersistentVolumeClaimModel    *persistentVolumeClaimModel
	PersistentVolumeClaimTplModel *persistentVolumeClaimTplModel
	AuditLogModel                 *auditLogModel
	ApiKeyModel                   *apiKeyModel
	WebHookModel                  *webHookModel
	StatefulsetModel              *statefulsetModel
	StatefulsetTplModel           *statefulsetTplModel
	ConfigModel                   *configModel
	DaemonSetModel                *daemonSetModel
	DaemonSetTplModel             *daemonSetTplModel
	ChargeModel                   *chargeModel
	InvoiceModel                  *invoiceModel
	NotificationModel             *notificationModel
	NotificationLogModel          *notificationLogModel
	IngressModel                  *ingressModel
	IngressTemplateModel          *ingressTemplateModel
)
View Source
var (
	APIKeyUser = User{
		Id:      0,
		Name:    "OpenAPI",
		Type:    APIUser,
		Display: "OpenAPI",
	}

	AnonymousUser = User{
		Id:      0,
		Name:    "Anonymous",
		Type:    DefaultUser,
		Display: "Anonymous",
	}
)
View Source
var TableToKubeApiTypeMap = map[string]KubeApiType{
	TableNameDeployment:            KubeApiTypeDeployment,
	TableNameCronjob:               KubeApiTypeCronJob,
	TableNameStatefulset:           KubeApiTypeStatefulSet,
	TableNameDaemonSet:             KubeApiTypeDaemonSet,
	TableNameService:               KubeApiTypeService,
	TableNameConfigMap:             KubeApiTypeConfigMap,
	TableNameSecret:                KubeApiTypeSecret,
	TableNamePersistentVolumeClaim: KubeApiTypePersistentVolumeClaim,
}

Functions

func BuildFilter

func BuildFilter(qs orm.QuerySeter, query map[string]interface{}) orm.QuerySeter

func BuildGroupBy

func BuildGroupBy(qb orm.QueryBuilder, groupby []string) orm.QueryBuilder

func BuildOrder

func BuildOrder(qb orm.QueryBuilder, sort string) orm.QueryBuilder

func BuildQuery

func BuildQuery(qb orm.QueryBuilder, query map[string]interface{}) (orm.QueryBuilder, []interface{})

func GetAll

func GetAll(queryTable interface{}, list interface{}, q *common.QueryParam) error

func GetAppIdByFilter

func GetAppIdByFilter(queryTable string, filter map[string]interface{}) (err error, id int64)

func GetTotal

func GetTotal(queryTable interface{}, q *common.QueryParam) (int64, error)

func ListTemplate

func ListTemplate(list interface{}, q *common.QueryParam, table string, resourceType PublishType, isOnline bool) (total int64, err error)

func Ormer

func Ormer() orm.Ormer

singleton init ormer ,only use for normal db operation if you begin transaction,please use orm.NewOrm()

Types

type APIKey

type APIKey struct {
	Id    int64  `orm:"auto" json:"id,omitempty"`
	Name  string `orm:"index;size(128)" json:"name,omitempty"`
	Token string `orm:"type(text)" json:"token,omitempty"`
	// 0:全局 1:命名空间 2:项目
	Type       APIKeyType `orm:"type(integer)" json:"type"`
	ResourceId int64      `orm:"null;type(bigint)" json:"resourceId,omitempty"`
	// TODO beego 默认删除规则为级联删除,可选项 do_nothing on_delete
	Group       *Group     `orm:"null;rel(fk);on_delete(set_null)" json:"group,omitempty"`
	Description string     `orm:"null;size(512)" json:"description,omitempty"`
	User        string     `orm:"size(128)" json:"user,omitempty"`
	ExpireIn    int64      `orm:"type(bigint)" json:"expireIn"`            // 过期时间,单位:秒
	Deleted     bool       `orm:"default(false)" json:"deleted,omitempty"` // 是否生效
	CreateTime  *time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime  *time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`
}

func (*APIKey) String

func (k *APIKey) String() string

func (*APIKey) TableName

func (*APIKey) TableName() string

type APIKeyType

type APIKeyType int32
const (
	TableNameAPIKey = "api_key"

	GlobalAPIKey      APIKeyType = 0
	NamespaceAPIKey   APIKeyType = 1
	ApplicationAPIKey APIKeyType = 2
)

type ActionPermission

type ActionPermission struct {
	PermissionRead    bool `json:"read" mapstructure:"READ"`
	PermissionCreate  bool `json:"create" mapstructure:"CREATE"`
	PermissionUpdate  bool `json:"update" mapstructure:"UPDATE"`
	PermissionDelete  bool `json:"delete" mapstructure:"DELETE"`
	PermissionDeploy  bool `json:"deploy" mapstructure:"DEPLOY"`
	PermissionOffline bool `json:"offline" mapstructure:"OFFLINE"`
}

type App

type App struct {
	Id        int64      `orm:"auto" json:"id,omitempty"`
	Name      string     `orm:"index;size(128)" json:"name,omitempty"`
	Namespace *Namespace `orm:"index;column(namespace_id);rel(fk)" json:"namespace"`
	/*
		{
		    "mode": "beta",
		    "system.api-name-generate-rule":"none" // refers to models.Config ConfigKeyApiNameGenerateRule
		}
	*/
	MetaData    string `orm:"type(text)" json:"metaData,omitempty"`
	Description string `orm:"null;size(512)" json:"description,omitempty"`

	CreateTime *time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime *time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`
	User       string     `orm:"size(128)" json:"user,omitempty"`
	Deleted    bool       `orm:"default(false)" json:"deleted,omitempty"`

	// 用于权限的关联查询
	AppUsers []*AppUser `orm:"reverse(many)" json:"-"`

	// 关注的关联查询
	AppStars []*AppStarred `orm:"reverse(many)" json:"-"`
}

func (*App) String

func (a *App) String() string

func (*App) TableName

func (*App) TableName() string

type AppStar

type AppStar struct {
	App

	CreateTime    time.Time `json:"createTime"`
	NamespaceId   int64     `json:"namespaceId"`
	NamespaceName string    `json:"namespaceName"`
	Starred       bool      `json:"starred"`
}

由于beego已注册的model columns会缓存,而标记为orm:"-"的column不会缓存进去 会导致orm:"-"的column 使用QueryRows无法查询 具体代码:astaxie/beego/orm/orm_raw.go QueryRows

type AppStarred

type AppStarred struct {
	Id   int64 `orm:"auto" json:"id,omitempty"`
	App  *App  `orm:"index;rel(fk);column(app_id)" json:"app,omitempty"`
	User *User `orm:"index;rel(fk);column(user_id)" json:"user,omitempty"`
}

func (*AppStarred) TableName

func (*AppStarred) TableName() string

func (*AppStarred) TableUnique

func (*AppStarred) TableUnique() [][]string

type AppStatistics

type AppStatistics struct {
	Total   int64              `json:"total,omitempty"`
	Details *[]NamespaceDetail `json:"details,omitempty"`
}

type AppUser

type AppUser struct {
	Id    int64  `orm:"auto" json:"id,omitempty"`
	App   *App   `orm:"index;rel(fk);column(app_id)" json:"app,omitempty"`
	User  *User  `orm:"index;rel(fk);column(user_id)" json:"user,omitempty"`
	Group *Group `orm:"index;rel(fk)" json:"group,omitempty"`

	CreateTime *time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime *time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`

	Groups     []*Group `orm:"-" json:"groups,omitempty"`
	GroupsName string   `orm:"-" json:"groupsName,omitempty"`
}

func (*AppUser) TableName

func (*AppUser) TableName() string

type AuditLog

type AuditLog struct {
	Id         int64         `orm:"auto" json:"id,omitempty"`
	SubjectId  int64         `orm:"type(bigint)" json:"subjectId,omitempty"`
	LogType    AuditLogType  `orm:"index;size(128)" json:"logType,omitempty"`
	LogLevel   AuditLogLevel `orm:"index;size(128)" json:"logLevel,omitempty"`
	Action     string        `orm:"index;size(255)" json:"action,omitempty"`
	Message    string        `orm:"type(text);null" json:"message,omitempty"`
	UserIp     string        `orm:"size(200)" json:"userIp,omitempty"`
	User       string        `orm:"index;size(128)" json:"user,omitempty"`
	CreateTime *time.Time    `orm:"auto_now_add;type(datetime);null" json:"createTime,omitempty"`
}

func (*AuditLog) TableName

func (*AuditLog) TableName() string

type AuditLogLevel

type AuditLogLevel string

type AuditLogType

type AuditLogType string

type AuthModel

type AuthModel struct {
	Username string
	Password string
	// oauth2 name ex. google github
	OAuth2Name string
	OAuth2Code string
}

AuthModel holds information used to authenticate.

type Charge

type Charge struct {
	Id        int64  `orm:"auto" json:"id,omitempty"`
	Namespace string `orm:"size(1024)" json:"namespace,omitempty"`
	App       string `orm:"index;size(1024)" json:"app,omitempty"`
	Name      string `orm:"size(1024)" json:"name,omitempty"`
	Type      string `orm:"index;size(1024)" json:"type,omitempty"`

	UnitPrice float64 `orm:"digits(12);decimals(4)" json:"unitPrice,omitempty"`
	Quantity  int     `orm:"int(11)" json:"quantity,omitempty"`
	Amount    float64 `orm:"digits(12);decimals(4)" json:"amount,omitempty"`

	ResourceName ResourceName `orm:"size(1024)" json:"resourceName,omitempty"`
	StartTime    *time.Time   `orm:"type(datetime)" json:"startTime,omitempty"`
	CreateTime   *time.Time   `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
}

func (*Charge) TableName

func (*Charge) TableName() string

type Cluster

type Cluster struct {
	Id   int64  `orm:"auto" json:"id,omitempty"`
	Name string `orm:"unique;index;size(128)" json:"name,omitempty"`
	/*
		   {
			  "robin": {
		          "token": "robin token",
		          "url":"http://10.10.10.10:8080",
		          "sftpPort": 2022,
		          "passwordDesKey": "Dhg4YuMn"   // change one or more character,the length must be 8.
		       },
			  "rbd": {              // rbd默认配置,创建或修改RBD类型的PV时会使用此配置填充
			    "monitors": [
			      "10.10.10.1:6789",
			      "10.10.10.2:6789",
			      "10.10.10.3:6789"
			    ],
			    "fsType": "xfs",
			    "pool": "k8s_pool",
			    "user": "search",
			    "keyring": "/etc/ceph/ceph.client.search.keyring"
			  },
			  "cephfs": {         // cephfs默认配置,创建或修改cephfs类型的PV时会使用此配置填充
			    "monitors": [
			      "10.10.10.4:6789",
			      "10.10.10.5:6789",
			      "10.10.10.6:6789"
			    ],
			    "user": "search",
			    "secretRef": {
			      "name": "infra-cephfs"
			    }
			  }
			}
	*/
	MetaData    string     `orm:"null;type(text)" json:"metaData,omitempty"`
	Master      string     `orm:"size(128)" json:"master,omitempty"` // apiserver地址,示例: https://10.172.189.140
	KubeConfig  string     `orm:"null;type(text)" json:"kubeConfig,omitempty"`
	Description string     `orm:"null;size(512)" json:"description,omitempty"`
	CreateTime  *time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime  *time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`
	User        string     `orm:"size(128)" json:"user,omitempty"`
	Deleted     bool       `orm:"default(false)" json:"deleted,omitempty"`
	// the cluster status
	Status ClusterStatus `orm:"default(0)" json:"status"`

	MetaDataObj ClusterMetaData `orm:"-" json:"-"`
}

func (*Cluster) TableName

func (*Cluster) TableName() string

type ClusterMeta

type ClusterMeta struct {
	ResourcesLimit ResourcesLimit `json:"resourcesLimit"`
}

type ClusterMetaData

type ClusterMetaData struct {
	// robin plugin
	Robin *ClusterRobinMetaData `json:"robin"`
	// kubetool log source
	LogSource string `json:"logSource"`
	// rbd默认配置,创建或修改RBD类型的PV时会使用此配置填充
	RBD *v1.RBDVolumeSource `json:"rbd"`
	// cephfs默认配置,创建或修改cephfs类型的PV时会使用此配置填充
	CephFS *v1.CephFSVolumeSource `json:"cephfs"`
	// 默认添加环境变量,会在发布资源时在每个Container添加此环境变量, will be overwrite by namespace's ImagePullSecrets
	Env []v1.EnvVar
	// current cluster image pull secrets, will be overwrite by namespace's ImagePullSecrets
	ImagePullSecrets []v1.LocalObjectReference `json:"imagePullSecrets"`
}

type ClusterRobinMetaData

type ClusterRobinMetaData struct {
	Token          string `json:"token"`
	Url            string `json:"url"`
	SftpPort       int    `json:"sftpPort"`
	PasswordDesKey string `json:"passwordDesKey"`
}

type ClusterStatus

type ClusterStatus int32
const (
	ClusterStatusNormal      ClusterStatus = 0
	ClusterStatusMaintaining ClusterStatus = 1

	TableNameCluster = "cluster"
)

type Config

type Config struct {
	Id int64 `orm:"auto" json:"id,omitempty"`

	Name  ConfigKey `orm:"size(256)" json:"name,omitempty"`
	Value string    `orm:"type(text)" json:"value,omitempty"`
}

func (*Config) TableName

func (*Config) TableName() string

type ConfigKey

type ConfigKey string
const (
	ConfigKeyTitile          ConfigKey = "system.title"
	ConfigKeyImageNamePrefix ConfigKey = "system.image-prefix"
	ConfigKeyAffinity        ConfigKey = "system.affinity"
	// redirect to monitor uri config
	// will be replace {{app.name}} to app's name
	// e.g  https://github.com/{{app.name}}, if the app name is wayne, will redirect to https://github.com/wayne
	ConfigKeyMonitorUri ConfigKey = "system.monitor-uri"
	// Option Values : join none
	// join: means ApiName will join with app name e.g. app name is wayne, deployment name is foo, the final name is wayne-foo
	// none: do nothing with the ApiName
	ConfigKeyApiNameGenerateRule ConfigKey = "system.api-name-generate-rule"

	ConfigKeyOauth2Title ConfigKey = "system.oauth2-title"

	TableNameConfig = "config"
)

type ConfigMap

type ConfigMap struct {
	Id          int64  `orm:"auto" json:"id,omitempty"`
	Name        string `orm:"unique;size(128)" json:"name,omitempty"`
	MetaData    string `orm:"type(text)" json:"metaData,omitempty"`
	App         *App   `orm:"index;rel(fk)" json:"app,omitempty"`
	Description string `orm:"null;size(512)" json:"description,omitempty"`
	OrderId     int64  `orm:"index;default(0)" json:"order"`

	CreateTime *time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime *time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`
	User       string     `orm:"size(128)" json:"user,omitempty"`
	Deleted    bool       `orm:"default(false)" json:"deleted,omitempty"`

	AppId int64 `orm:"-" json:"appId,omitempty"`
}

func (*ConfigMap) TableName

func (*ConfigMap) TableName() string

type ConfigMapTemplate

type ConfigMapTemplate struct {
	Id        int64      `orm:"auto" json:"id,omitempty"`
	Name      string     `orm:"size(128)" json:"name,omitempty"`
	Template  string     `orm:"type(text)" json:"template,omitempty"`
	ConfigMap *ConfigMap `orm:"index;rel(fk);column(config_map_id)" json:"configMap,omitempty"`
	// 存储模版可上线机房
	// 例如{"clusters":["K8S"]}
	MetaData    string `orm:"type(text)" json:"metaData,omitempty"`
	Description string `orm:"size(512)" json:"description,omitempty"`

	CreateTime time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`
	User       string    `orm:"size(128)" json:"user,omitempty"`
	Deleted    bool      `orm:"default(false)" json:"deleted,omitempty"`

	Status      []*PublishStatus `orm:"-" json:"status,omitempty"`
	ConfigMapId int64            `orm:"-" json:"configMapId,omitempty"`
}

func (*ConfigMapTemplate) TableName

func (*ConfigMapTemplate) TableName() string

type Cronjob

type Cronjob struct {
	Id   int64  `orm:"auto" json:"id,omitempty"`
	Name string `orm:"unique;size(128)" json:"name,omitempty"`
	// 存储模版可上线机房,已挂起的机房
	/*
		{
		  "replicas": {
		    "K8S": 1
		  },
		}
	*/
	MetaData    string          `orm:"type(text)" json:"metaData,omitempty"`
	MetaDataObj CronjobMetaData `orm:"-" json:"-"`
	App         *App            `orm:"index;rel(fk)" json:"app,omitempty"`
	Description string          `orm:"null;size(512)" json:"description,omitempty"`
	OrderId     int64           `orm:"index;default(0)" json:"order"`

	CreateTime *time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime *time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`
	User       string     `orm:"size(128)" json:"user,omitempty"`
	Deleted    bool       `orm:"default(false)" json:"deleted,omitempty"`

	AppId int64 `orm:"-" json:"appId,omitempty"`
}

func (*Cronjob) TableName

func (*Cronjob) TableName() string

type CronjobMetaData

type CronjobMetaData struct {
	Replicas map[string]int32 `json:"replicas"`
	Suspends map[string]bool  `json:"suspends"`
	Affinity *kapi.Affinity   `json:"affinity,omitempty"`
	// 是否允许用户使用特权模式,默认不允许,key 为容器名称
	Privileged map[string]*bool `json:"privileged"`
}

type CronjobTemplate

type CronjobTemplate struct {
	Id          int64    `orm:"auto" json:"id,omitempty"`
	Name        string   `orm:"size(128)" json:"name,omitempty"`
	Template    string   `orm:"type(text)" json:"template,omitempty"`
	Cronjob     *Cronjob `orm:"index;rel(fk);column(cronjob_id)" json:"cronjob,omitempty"`
	MetaData    string   `orm:"type(text)" json:"metaData,omitempty"`
	Description string   `orm:"size(512)" json:"description,omitempty"`

	CreateTime time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`
	User       string    `orm:"size(128)" json:"user,omitempty"`
	Deleted    bool      `orm:"default(false)" json:"deleted,omitempty"`

	Status    []*PublishStatus `orm:"-" json:"status,omitempty"`
	CronjobId int64            `orm:"-" json:"cronjobId,omitempty"`
}

func (*CronjobTemplate) TableName

func (*CronjobTemplate) TableName() string

type DaemonSet

type DaemonSet struct {
	Id   int64  `orm:"auto" json:"id,omitempty"`
	Name string `orm:"unique;index;size(128)" json:"name,omitempty"`
	/* 存储元数据
	{
	  "privileged":{"nginx",true},
	  "affinity": {
	    "podAntiAffinity": {
	      "requiredDuringSchedulingIgnoredDuringExecution": [
	        {
	          "labelSelector": {
	            "matchExpressions": [
	              {
	                "operator": "In",
	                "values": [
	                  "xxx"
	                ],
	                "key": "app"
	              }
	            ]
	          },
	          "topologyKey": "kubernetes.io/hostname"
	        }
	      ]
	    }
	  },
	  "resources":{
			"cpuRequestLimitPercent": "50%", // cpu request和limit百分比,默认50%
			"memoryRequestLimitPercent": "100%", // memory request和limit百分比,默认100%
			"cpuLimit":"12",  // cpu限制,默认12个核
			"memoryLimit":"64" // 内存限制,默认64G
			"replicaLimit":"32" // 份数限制,默认32份
	  }
	}
	*/
	MetaData    string            `orm:"type(text)" json:"metaData,omitempty"`
	MetaDataObj DaemonSetMetaData `orm:"-" json:"-"`
	App         *App              `orm:"index;rel(fk)" json:"app,omitempty"`
	Description string            `orm:"null;size(512)" json:"description,omitempty"`
	OrderId     int64             `orm:"index;default(0)" json:"order"`

	CreateTime time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`
	User       string    `orm:"size(128)" json:"user,omitempty"`
	Deleted    bool      `orm:"default(false)" json:"deleted,omitempty"`

	AppId int64 `orm:"-" json:"appId,omitempty"`
}

func (*DaemonSet) TableName

func (*DaemonSet) TableName() string

type DaemonSetMetaData

type DaemonSetMetaData struct {
	Resources map[string]string `json:"resources,omitempty"`
	Affinity  *kapi.Affinity    `json:"affinity,omitempty"`
	// 是否允许用户使用特权模式,默认不允许,key 为容器名称
	Privileged map[string]*bool `json:"privileged"`
}

type DaemonSetTemplate

type DaemonSetTemplate struct {
	Id          int64      `orm:"auto" json:"id,omitempty"`
	Name        string     `orm:"size(128)" json:"name,omitempty"`
	Template    string     `orm:"type(text)" json:"template,omitempty"`
	DaemonSet   *DaemonSet `orm:"index;rel(fk)" json:"daemonSet,omitempty"`
	Description string     `orm:"size(512)" json:"description,omitempty"`

	CreateTime time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`
	User       string    `orm:"size(128)" json:"user,omitempty"`
	Deleted    bool      `orm:"default(false)" json:"deleted,omitempty"`

	DaemonSetId int64            `orm:"-" json:"daemonSetId,omitempty"`
	Status      []*PublishStatus `orm:"-" json:"status,omitempty"`
}

func (*DaemonSetTemplate) TableName

func (*DaemonSetTemplate) TableName() string

type DeployCount

type DeployCount struct {
	Date  time.Time `json:"date,omitempty"`
	Count int       `json:"count"`
}

type Deployment

type Deployment struct {
	Id   int64  `orm:"auto" json:"id,omitempty"`
	Name string `orm:"unique;index;size(128)" json:"name,omitempty"`
	/* 存储部署元数据
	{
	  "replicas": {
	    "K8S": 1
	  },
	  "privileged":{"nginx",true},
	  "affinity": {
	    "podAntiAffinity": {
	      "requiredDuringSchedulingIgnoredDuringExecution": [
	        {
	          "labelSelector": {
	            "matchExpressions": [
	              {
	                "operator": "In",
	                "values": [
	                  "xxx"
	                ],
	                "key": "app"
	              }
	            ]
	          },
	          "topologyKey": "kubernetes.io/hostname"
	        }
	      ]
	    }
	  },
	  "resources":{
			"cpuRequestLimitPercent": "50%", // cpu request和limit百分比,默认50%
			"memoryRequestLimitPercent": "100%", // memory request和limit百分比,默认100%
			"cpuLimit":"12",  // cpu限制,默认12个核
			"memoryLimit":"64" // 内存限制,默认64G
			"replicaLimit":"32" // 部署份数限制,默认32份
	  }
	}
	*/
	MetaData    string             `orm:"type(text)" json:"metaData,omitempty"`
	MetaDataObj DeploymentMetaData `orm:"-" json:"-"`
	App         *App               `orm:"index;rel(fk)" json:"app,omitempty"`
	Description string             `orm:"null;size(512)" json:"description,omitempty"`
	OrderId     int64              `orm:"index;default(0)" json:"order"`

	CreateTime *time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime *time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`
	User       string     `orm:"size(128)" json:"user,omitempty"`
	Deleted    bool       `orm:"default(false)" json:"deleted,omitempty"`

	AppId int64 `orm:"-" json:"appId,omitempty"`
}

func (*Deployment) TableName

func (*Deployment) TableName() string

type DeploymentMetaData

type DeploymentMetaData struct {
	Replicas  map[string]int32  `json:"replicas"`
	Resources map[string]string `json:"resources,omitempty"`
	Affinity  *kapi.Affinity    `json:"affinity,omitempty"`
	// 是否允许用户使用特权模式,默认不允许,key 为容器名称
	Privileged map[string]*bool `json:"privileged"`
}

type DeploymentTemplate

type DeploymentTemplate struct {
	Id          int64       `orm:"auto" json:"id,omitempty"`
	Name        string      `orm:"size(128)" json:"name,omitempty"`
	Template    string      `orm:"type(text)" json:"template,omitempty"`
	Deployment  *Deployment `orm:"index;rel(fk);column(deployment_id)" json:"deployment,omitempty"`
	Description string      `orm:"size(512)" json:"description,omitempty"`

	// TODO
	// 如果使用指针类型auto_now_add和auto_now可以自动生效,但是orm QueryRows无法对指针类型的time正常赋值,
	// 不使用指针类型创建时需要手动把创建时间设置为当前时间,更新时也需要处理创建时间
	CreateTime time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`
	User       string    `orm:"size(128)" json:"user,omitempty"`
	Deleted    bool      `orm:"default(false)" json:"deleted,omitempty"`

	DeploymentId int64            `orm:"-" json:"deploymentId,omitempty"`
	Status       []*PublishStatus `orm:"-" json:"status,omitempty"`
}

func (*DeploymentTemplate) TableName

func (*DeploymentTemplate) TableName() string

type Group

type Group struct {
	Id      int64     `orm:"pk;auto" json:"id,omitempty"`
	Name    string    `orm:"index;size(200)" json:"name,omitempty"`
	Comment string    `orm:"type(text)" json:"comment,omitempty"`
	Type    GroupType `orm:"type(integer)" json:"type"`

	CreateTime *time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime *time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`

	// 用于权限的关联查询
	Permissions    []*Permission    `orm:"rel(m2m);rel_table(group_permissions)" json:"permissions,omitempty"`
	AppUsers       []*AppUser       `orm:"reverse(many)" json:"appUsers,omitempty"`
	NamespaceUsers []*NamespaceUser `orm:"reverse(many)" json:"namespaceUsers,omitempty"`
}

func (*Group) String

func (g *Group) String() string

func (*Group) TableName

func (*Group) TableName() string

type GroupType

type GroupType int
const (
	AppGroupType GroupType = iota
	NamespaceGroupType

	TableNameGroup = "group"
)

type Ingress added in v1.1.0

type Ingress struct {
	Id          int64  `orm:"auto" json:"id,omitempty"`
	Name        string `orm:"unique;index;size(128)" json:"name,omitempty"`
	MetaData    string `orm:"type(text)" json:"metaData,omitempty"`
	App         *App   `orm:"index;rel(fk)" json:"app,omitempty"`
	Description string `orm:"nill,size(512)" json:"description,omitempty"`
	OrderId     int64  `orm:"index;default(0)" json:"order"`

	CreateTime *time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime *time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`
	User       string     `orm:"size(128)" json:"user,omitempty"`
	Deleted    bool       `orm:"default(false)" json:"deleted,omitempty"`

	AppId int64 `orm:"-" json:"appId,omitempty"`
}

func (*Ingress) TableName added in v1.1.0

func (*Ingress) TableName() string

type IngressTemplate added in v1.1.0

type IngressTemplate struct {
	Id          int64    `orm:"auto" json:"id,omitempty"`
	Name        string   `orm:"size(128)" json:"name,omitempty"`
	Template    string   `orm:"type(text)" json:"template,omitempty"`
	Ingress     *Ingress `orm:"index;rel(fk);column(ingress_id)" json:"ingress,omitempty"`
	Description string   `orm:"size(512)" json:"description,omitempty"`

	CreateTime time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`
	User       string    `orm:"size(128)" json:"user,omitempty"`
	Deleted    bool      `orm:"default(false)" json:"deleted,omitempty"`

	Status    []*PublishStatus `orm:"-" json:"status,omitempty"`
	IngressId int64            `orm:"-" json:"ingressId,omitempty"`
}

func (*IngressTemplate) TableName added in v1.1.0

func (*IngressTemplate) TableName() string

type Invoice

type Invoice struct {
	Id        int64  `orm:"auto" json:"id,omitempty"`
	Namespace string `orm:"size(1024)" json:"namespace,omitempty"`
	App       string `orm:"index;size(1024)" json:"app,omitempty"`

	Amount float64 `orm:"digits(12);decimals(4)" json:"amount,omitempty"`

	StartDate *time.Time `orm:"type(datetime)" json:"startDate,omitempty"`
	EndDate   *time.Time `orm:"type(datetime)" json:"endDate,omitempty"`
	BillDate  *time.Time `orm:"type(datetime)" json:"billDate,omitempty"`

	CreateTime *time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
}

func (*Invoice) TableName

func (*Invoice) TableName() string

type KubeApiType

type KubeApiType string
const (
	KubeApiTypeDeployment            KubeApiType = "Deployment"
	KubeApiTypeCronJob               KubeApiType = "CronJob"
	KubeApiTypeStatefulSet           KubeApiType = "StatefulSet"
	KubeApiTypeDaemonSet             KubeApiType = "DaemonSet"
	KubeApiTypeService               KubeApiType = "Service"
	KubeApiTypeConfigMap             KubeApiType = "ConfigMap"
	KubeApiTypeSecret                KubeApiType = "Secret"
	KubeApiTypePersistentVolumeClaim KubeApiType = "PersistentVolumeClaim"
	KubeApiTypeJob                   KubeApiType = "Job"
	KubeApiTypeReplicaSet            KubeApiType = "ReplicaSet"
)

type LdapConf

type LdapConf struct {
	LdapURL               string `json:"ldap_url"`
	LdapSearchDn          string `json:"ldap_search_dn"`
	LdapSearchPassword    string `json:"ldap_search_password"`
	LdapBaseDn            string `json:"ldap_base_dn"`
	LdapFilter            string `json:"ldap_filter"`
	LdapUID               string `json:"ldap_uid"`
	LdapScope             int    `json:"ldap_scope"`
	LdapConnectionTimeout int    `json:"ldap_connection_timeout"`
}

type LdapUser

type LdapUser struct {
	Username string `json:"ldap_username"`
	Email    string `json:"ldap_email"`
	Realname string `json:"ldap_realname"`
	DN       string `json:"-"`
}

LdapUser ...

type Namespace

type Namespace struct {
	Id   int64  `orm:"auto" json:"id,omitempty"`
	Name string `orm:"index;unique;size(128)" json:"name,omitempty"`
	// 配置对应Kubernetes的namespace  {"namespace":"default"}
	// 配置对应namespace可使用的集群  {"clusters":"K8S"}
	MetaData    string            `orm:"type(text)" json:"metaData,omitempty"`
	MetaDataObj NamespaceMetaData `orm:"-" json:"-"`
	CreateTime  *time.Time        `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime  *time.Time        `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`
	User        string            `orm:"size(128)" json:"user,omitempty"`
	Deleted     bool              `orm:"default(false)" json:"deleted,omitempty"`

	// 用于权限的关联查询
	NamespaceUsers []*NamespaceUser `orm:"reverse(many)" json:"-"`
}

func (*Namespace) String

func (ns *Namespace) String() string

func (*Namespace) TableName

func (*Namespace) TableName() string

type NamespaceDetail

type NamespaceDetail struct {
	Name  string `json:"name"`
	Count int64  `json:"count"`
}

type NamespaceMetaData

type NamespaceMetaData struct {
	// kubernetes' namespace
	Namespace string `json:"namespace,omitempty"`
	// key is cluster name, if the key not exist on clusterMeta
	// means this namespace could't use the cluster
	ClusterMetas map[string]ClusterMeta `json:"clusterMeta,omitempty"`
	// current namespace env, will overwrite cluster's Env
	Env []v1.EnvVar `json:"env,omitempty"`
	// current namespace image pull secrets, will overwrite cluster's ImagePullSecrets
	ImagePullSecrets []v1.LocalObjectReference `json:"imagePullSecrets"`
}

type NamespaceUser

type NamespaceUser struct {
	Id        int64      `orm:"auto" json:"id,omitempty"`
	Namespace *Namespace `orm:"index;rel(fk);column(namespace_id)" json:"namespace,omitempty"`
	User      *User      `orm:"index;rel(fk);column(user_id)" json:"user,omitempty"`
	Group     *Group     `orm:"index;rel(fk)" json:"group,omitempty"`

	CreateTime *time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime *time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`

	Groups     []*Group `orm:"-" json:"groups,omitempty"`
	GroupsName string   `orm:"-" json:"groupsName,omitempty"`
}

func (*NamespaceUser) TableName

func (*NamespaceUser) TableName() string

type Notification

type Notification struct {
	Id          int64             `orm:"auto" json:"id,omitempty"`
	Type        NotificationType  `orm:"index;size(128)" json:"type,omitempty"`
	Title       string            `orm:"size(2000)" json:"title,omitempty"`
	Message     string            `orm:"type(text)" json:"message,omitempty"`
	FromUser    *User             `orm:"index;rel(fk)" json:"from,omitempty"`
	Level       NotificationLevel `orm:"default(0)" json:"level,omitempty"`
	IsPublished bool              `orm:"default(false)" json:"is_published"`
	CreateTime  *time.Time        `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime  *time.Time        `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`
}

func (*Notification) TableName

func (*Notification) TableName() string

type NotificationLevel

type NotificationLevel int
const (
	LowNotification NotificationLevel = iota
	MiddleNotification
	HighNotification
)

type NotificationLog

type NotificationLog struct {
	Id           int64         `orm:"auto" json:"id,omitempty"`
	UserId       int64         `orm:"default(0)" json:"user_id,omitempty"`
	CreateTime   *time.Time    `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	IsReaded     bool          `orm:"default(false)" json:"is_readed"`
	Notification *Notification `orm:"index;column(notification_id);rel(fk)" json:"notification"`
}

func (*NotificationLog) TableName

func (*NotificationLog) TableName() string

type NotificationType

type NotificationType string
const (
	NoticeNotification  NotificationType = "公告"
	WarningNotification NotificationType = "警告"
)

type Permission

type Permission struct {
	Id      int64  `orm:"auto" json:"id,omitempty"`
	Name    string `orm:"index;size(200)" json:"name,omitempty"`
	Comment string `orm:"type(text)" json:"comment,omitempty"`

	CreateTime *time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime *time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`

	Groups []*Group `orm:"reverse(many)" json:"groups,omitempty"`
}

func (*Permission) TableName

func (*Permission) TableName() string

type PersistentVolumeClaim

type PersistentVolumeClaim struct {
	Id          int64  `orm:"auto" json:"id,omitempty"`
	Name        string `orm:"unique;index;size(128)" json:"name,omitempty"`
	MetaData    string `orm:"type(text)" json:"metaData,omitempty"`
	App         *App   `orm:"index;rel(fk)" json:"app,omitempty"`
	Description string `orm:"null;size(512)" json:"description,omitempty"`
	OrderId     int64  `orm:"index;default(0)" json:"order"`

	CreateTime *time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime *time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`
	User       string     `orm:"size(128)" json:"user,omitempty"`
	Deleted    bool       `orm:"default(false)" json:"deleted,omitempty"`

	AppId int64 `orm:"-" json:"appId,omitempty"`
}

func (*PersistentVolumeClaim) TableName

func (*PersistentVolumeClaim) TableName() string

type PersistentVolumeClaimTemplate

type PersistentVolumeClaimTemplate struct {
	Id                    int64                  `orm:"auto" json:"id,omitempty"`
	Name                  string                 `orm:"size(128)" json:"name,omitempty"`
	Template              string                 `orm:"type(text)" json:"template,omitempty"`
	PersistentVolumeClaim *PersistentVolumeClaim `orm:"index;rel(fk)" json:"persistentVolumeClaim,omitempty"`
	// 存储模版可上线机房
	// 例如{"clusters":["K8S"]}
	MetaData    string `orm:"type(text)" json:"metaData,omitempty"`
	Description string `orm:"size(512)" json:"description,omitempty"`

	CreateTime time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`
	User       string    `orm:"size(128)" json:"user,omitempty"`
	Deleted    bool      `orm:"default(false)" json:"deleted,omitempty"`

	Status                  []*PublishStatus `orm:"-" json:"status,omitempty"`
	PersistentVolumeClaimId int64            `orm:"-" json:"persistentVolumeClaimId,omitempty"`
}

func (*PersistentVolumeClaimTemplate) TableName

type PublishHistory

type PublishHistory struct {
	Id           int64         `orm:"auto" json:"id,omitempty"`
	Type         PublishType   `orm:"index;type(integer)" json:"type,omitempty"`
	ResourceId   int64         `orm:"index" json:"resourceId,omitempty"`
	ResourceName string        `orm:"size(128)" json:"resourceName,omitempty"`
	TemplateId   int64         `orm:"index;column(template_id)" json:"templateId,omitempty"`
	Cluster      string        `orm:"size(128)" json:"cluster,omitempty"`
	Status       ReleaseStatus `orm:"type(integer)" json:"status,omitempty"`
	Message      string        `orm:"type(text)" json:"message,omitempty"`
	User         string        `orm:"size(128)" json:"user,omitempty"`
	CreateTime   *time.Time    `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
}

func (*PublishHistory) TableName

func (*PublishHistory) TableName() string

type PublishStatus

type PublishStatus struct {
	Id         int64       `orm:"auto" json:"id,omitempty"`
	Type       PublishType `orm:"index;type(integer)" json:"type,omitempty"`
	ResourceId int64       `orm:"index;column(resource_id)" json:"resourceId,omitempty"`
	TemplateId int64       `orm:"index;column(template_id);" json:"templateId,omitempty"`
	Cluster    string      `orm:"size(128);column(cluster)" json:"cluster,omitempty"`
}

记录已发布模版信息

func (*PublishStatus) TableName

func (*PublishStatus) TableName() string

type PublishType

type PublishType int32
const (
	PublishTypeDeployment PublishType = iota
	PublishTypeService
	PublishTypeConfigMap
	PublishTypeSecret
	PublishTypePersistentVolumeClaim
	PublishTypeCronJob
	PublishTypeStatefulSet
	PublishTypeDaemonSet
	PublishTypeIngress

	TableNamePublishStatus = "publish_status"
)

type ReleaseStatus

type ReleaseStatus int32
const (
	ReleaseFailure ReleaseStatus = iota
	ReleaseSuccess

	TableNamePublishHistory = "publish_history"
)

type ResourceName

type ResourceName string
const (
	Mem ResourceName = "mem"
	Cpu ResourceName = "cpu"

	TableNameCharge = "charge"
)

type ResourcesLimit

type ResourcesLimit struct {
	// unit core
	Cpu int64 `json:"cpu,omitempty"`
	// unit G
	Memory int64 `json:"memory,omitempty"`
}

type Secret

type Secret struct {
	Id          int64  `orm:"auto" json:"id,omitempty"`
	Name        string `orm:"unique;index;size(128)" json:"name,omitempty"`
	MetaData    string `orm:"type(text)" json:"metaData,omitempty"`
	App         *App   `orm:"index;rel(fk)" json:"app,omitempty"`
	Description string `orm:"null;size(512)" json:"description,omitempty"`
	OrderId     int64  `orm:"index;default(0)" json:"order"`

	CreateTime *time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime *time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`
	User       string     `orm:"size(128)" json:"user,omitempty"`
	Deleted    bool       `orm:"default(false)" json:"deleted,omitempty"`

	AppId int64 `orm:"-" json:"appId,omitempty"`
}

func (*Secret) TableName

func (*Secret) TableName() string

type SecretTemplate

type SecretTemplate struct {
	Id       int64   `orm:"auto" json:"id,omitempty"`
	Name     string  `orm:"size(128)" json:"name,omitempty"`
	Template string  `orm:"type(text)" json:"template,omitempty"`
	Secret   *Secret `orm:"index;rel(fk);column(secret_map_id)" json:"secret,omitempty"`
	// 存储模版可上线机房
	// 例如{"clusters":["K8S"]}
	MetaData    string `orm:"type(text)" json:"metaData,omitempty"`
	Description string `orm:"size(512)" json:"description,omitempty"`

	CreateTime time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`
	User       string    `orm:"size(128)" json:"user,omitempty"`
	Deleted    bool      `orm:"default(false)" json:"deleted,omitempty"`

	Status   []*PublishStatus `orm:"-" json:"status,omitempty"`
	SecretId int64            `orm:"-" json:"secretId,omitempty"`
}

func (*SecretTemplate) TableName

func (*SecretTemplate) TableName() string

type Service

type Service struct {
	Id          int64  `orm:"auto" json:"id,omitempty"`
	Name        string `orm:"unique;index;size(128)" json:"name,omitempty"`
	MetaData    string `orm:"type(text)" json:"metaData,omitempty"`
	App         *App   `orm:"index;rel(fk)" json:"app,omitempty"`
	Description string `orm:"null;size(512)" json:"description,omitempty"`
	OrderId     int64  `orm:"index;default(0)" json:"order"`

	CreateTime *time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime *time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`
	User       string     `orm:"size(128)" json:"user,omitempty"`
	Deleted    bool       `orm:"default(false)" json:"deleted,omitempty"`

	AppId int64 `orm:"-" json:"appId,omitempty"`
}

func (*Service) TableName

func (*Service) TableName() string

type ServiceTemplate

type ServiceTemplate struct {
	Id          int64    `orm:"auto" json:"id,omitempty"`
	Name        string   `orm:"size(128)" json:"name,omitempty"`
	Template    string   `orm:"type(text)" json:"template,omitempty"`
	Service     *Service `orm:"index;rel(fk);column(service_id)" json:"service,omitempty"`
	Description string   `orm:"size(512)" json:"description,omitempty"`

	CreateTime time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`
	User       string    `orm:"size(128)" json:"user,omitempty"`
	Deleted    bool      `orm:"default(false)" json:"deleted,omitempty"`

	Status    []*PublishStatus `orm:"-" json:"status,omitempty"`
	ServiceId int64            `orm:"-" json:"serviceId,omitempty"`
}

func (*ServiceTemplate) TableName

func (*ServiceTemplate) TableName() string

type Statefulset

type Statefulset struct {
	Id   int64  `orm:"auto" json:"id,omitempty"`
	Name string `orm:"unique;index;size(128)" json:"name,omitempty"`
	/* 存储元数据
	{
	  "replicas": {
	    "K8S": 1
	  },
	  "privileged":{"nginx",true},
	  "affinity": {
	    "podAntiAffinity": {
	      "requiredDuringSchedulingIgnoredDuringExecution": [
	        {
	          "labelSelector": {
	            "matchExpressions": [
	              {
	                "operator": "In",
	                "values": [
	                  "xxx"
	                ],
	                "key": "app"
	              }
	            ]
	          },
	          "topologyKey": "kubernetes.io/hostname"
	        }
	      ]
	    }
	  },
	  "resources":{
			"cpuRequestLimitPercent": "50%", // cpu request和limit百分比,默认50%
			"memoryRequestLimitPercent": "100%", // memory request和limit百分比,默认100%
			"cpuLimit":"12",  // cpu限制,默认12个核
			"memoryLimit":"64" // 内存限制,默认64G
			"replicaLimit":"32" // 份数限制,默认32份
	  }
	}
	*/
	MetaData    string              `orm:"type(text)" json:"metaData,omitempty"`
	MetaDataObj StatefulsetMetaData `orm:"-" json:"-"`
	App         *App                `orm:"index;rel(fk)" json:"app,omitempty"`
	Description string              `orm:"null;size(512)" json:"description,omitempty"`
	OrderId     int64               `orm:"index;default(0)" json:"order"`

	CreateTime time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`
	User       string    `orm:"size(128)" json:"user,omitempty"`
	Deleted    bool      `orm:"default(false)" json:"deleted,omitempty"`

	AppId int64 `orm:"-" json:"appId,omitempty"`
}

func (*Statefulset) TableName

func (*Statefulset) TableName() string

type StatefulsetMetaData

type StatefulsetMetaData struct {
	Replicas  map[string]int32  `json:"replicas"`
	Resources map[string]string `json:"resources,omitempty"`
	Affinity  *kapi.Affinity    `json:"affinity,omitempty"`
	// 是否允许用户使用特权模式,默认不允许,key 为容器名称
	Privileged map[string]*bool `json:"privileged"`
}

type StatefulsetTemplate

type StatefulsetTemplate struct {
	Id          int64        `orm:"auto" json:"id,omitempty"`
	Name        string       `orm:"size(128)" json:"name,omitempty"`
	Template    string       `orm:"type(text)" json:"template,omitempty"`
	Statefulset *Statefulset `orm:"index;rel(fk);column(statefulset_id)" json:"statefulset,omitempty"`
	Description string       `orm:"size(512)" json:"description,omitempty"`

	CreateTime time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`
	User       string    `orm:"size(128)" json:"user,omitempty"`
	Deleted    bool      `orm:"default(false)" json:"deleted,omitempty"`

	StatefulsetId int64            `orm:"-" json:"statefulsetId,omitempty"`
	Status        []*PublishStatus `orm:"-" json:"status,omitempty"`
}

func (*StatefulsetTemplate) TableName

func (*StatefulsetTemplate) TableName() string

type TypePermission

type TypePermission struct {
	PermissionTypeApp                   ActionPermission `json:"app" mapstructure:"APP"`
	PermissionTypeAppUser               ActionPermission `json:"appUser" mapstructure:"APPUSER"`
	PermissionTypeNamespace             ActionPermission `json:"namespace" mapstructure:"NAMESPACE"`
	PermissionTypeNamespaceUser         ActionPermission `json:"namespaceUser" mapstructure:"NAMESPACEUSER"`
	PermissionTypeDeployment            ActionPermission `json:"deployment" mapstructure:"DEPLOYMENT"`
	PermissionTypeSecret                ActionPermission `json:"secret" mapstructure:"SECRET"`
	PermissionTypeService               ActionPermission `json:"service" mapstructure:"SERVICE"`
	PermissionTypeConfigMap             ActionPermission `json:"configmap" mapstructure:"CONFIGMAP"`
	PermissionTypeCronjob               ActionPermission `json:"cronjob" mapstructure:"CRONJOB"`
	PermissionTypePersistentVolumeClaim ActionPermission `json:"pvc" mapstructure:"PVC"`
	PermissionTypeWebHook               ActionPermission `json:"webHook" mapstructure:"WEBHOOK"`
	PermissionTypeApiKey                ActionPermission `json:"apiKey" mapstructure:"APIKEY"`
	PermissionTypeStatefulset           ActionPermission `json:"statefulset" mapstructure:"STATEFULSET"`
	PermissionTypeDaemonSet             ActionPermission `json:"daemonSet" mapstructure:"DAEMONSET"`
	PermissionTypeBILL                  ActionPermission `json:"bill" mapstructure:"BILL"`
	PermissionIngress                   ActionPermission `json:"ingress" mapstructure:"INGRESS"`
}

type User

type User struct {
	Id        int64      `orm:"pk;auto" json:"id,omitempty"`
	Name      string     `orm:"index;unique;size(200)" json:"name,omitempty"`
	Password  string     `orm:"size(255)" json:"-"`
	Salt      string     `orm:"size(32)" json:"-"`
	Email     string     `orm:"unique;size(200)" json:"email,omitempty"`
	Display   string     `orm:"size(200)" json:"display,omitempty"`
	Comment   string     `orm:"type(text)" json:"comment,omitempty"`
	Type      UserType   `orm:"type(integer)" json:"type"`
	Admin     bool       `orm:"default(False)" json:"admin"`
	LastLogin *time.Time `orm:"auto_now_add;type(datetime)" json:"lastLogin,omitempty"`
	LastIp    string     `orm:"size(200)" json:"lastIp,omitempty"`

	Deleted    bool       `orm:"default(false)" json:"deleted,omitempty"`
	CreateTime *time.Time `orm:"auto_now_add;type(datetime)" json:"createTime,omitempty"`
	UpdateTime *time.Time `orm:"auto_now;type(datetime)" json:"updateTime,omitempty"`

	Namespaces []*Namespace `orm:"-" json:"namespaces,omitempty"`
}

func (*User) GetTypeName

func (u *User) GetTypeName() string

func (*User) TableName

func (*User) TableName() string

type UserStatistics

type UserStatistics struct {
	Total int64 `json:"total,omitempty"`
}

type UserType

type UserType int
const (
	DefaultUser UserType = iota
	SystemUser
	APIUser

	TableNameUser = "user"
)

type WebHook

type WebHook struct {
	Id       int64        `orm:"auto" json:"id"`
	Name     string       `orm:"index;size(128)" json:"name"`
	Scope    WebHookScope `json:"scope"`
	ObjectId int64        `json:"objectId"`

	Url    string `orm:"null;size(512)" json:"url"`
	Secret string `orm:"null;size(512)" json:"secret"`
	Events string `orm:"type(text)" json:"events"`

	CreateTime *time.Time `orm:"auto_now_add;type(datetime)" json:"createTime"`
	UpdateTime *time.Time `orm:"auto_now;type(datetime)" json:"updateTime"`
	User       string     `orm:"size(128)" json:"user"`
	Enabled    bool       `orm:"default(false)" json:"enabled"`
}

func (*WebHook) GetHookEvents

func (h *WebHook) GetHookEvents() []*hookevent.HookEvent

func (*WebHook) TableName

func (*WebHook) TableName() string

func (*WebHook) TableUnique

func (*WebHook) TableUnique() [][]string

type WebHookScope

type WebHookScope int64
const (
	WebHookScopeNamespace WebHookScope = iota
	WebHookScopeApp

	TableNameWebHook = "web_hook"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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