types

package
v0.0.0-...-1ae172a Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppStatusUninstall    = "UnInstall"
	AppStatusNotReady     = "NotReady"
	AppStatusRunningFault = "RunningFault"
	AppStatusRunning      = "Running"

	// AppTypeOrdinaryApp 普通应用
	AppTypeOrdinaryApp = "ordinary_app"
	// AppTypeMiddleware 中间件
	AppTypeMiddleware = "middleware"
	// AppTypeClusterComponent 集群组件
	AppTypeClusterComponent = "component"
)
View Source
const (
	// AppVersionFromImport 导入应用
	AppVersionFromImport = "import"
	// AppVersionFromSpace 创建应用
	AppVersionFromSpace = "space"
)
View Source
const (
	AuditOperationCreate  = "创建"
	AuditOperationDelete  = "删除"
	AuditOperationUpdate  = "更新"
	AuditOperationInstall = "安装"
	AuditOperationUpgrade = "升级"
	// AuditOperationDestroy 应用销毁
	AuditOperationDestroy = "销毁"
	AuditOperationPatch   = "Patch"
	AuditOperationApply   = "Apply"
	AuditOperationClone   = "克隆"
	AuditOperationRelease = "发布"
	AuditOperationImport  = "导入"
)
View Source
const (
	AuditResourceApp        = "应用"
	AuditResourceAppVersion = "应用版本"
	AuditResourceProject    = "工作空间"

	AuditResourceAppStore = "应用商店"

	AuditResourceCluster          = "集群"
	AuditResourceClusterComponent = "集群组件"

	AuditResourcePipeSpace        = "流水线空间"
	AuditResourcePipeline         = "流水线"
	AuditResourcePipelineBuild    = "流水线构建"
	AuditResourcePipelineResource = "流水线资源"

	AuditResourcePlatformSecret   = "平台密钥"
	AuditResourcePlatformRegistry = "镜像仓库"
	AuditResourcePlatformSpacelet = "Spacelet"
	AuditResourcePlatformUser     = "用户"

	AuditResourcePermission = "权限"
)
View Source
const (
	ClusterFailed  = "Failed"
	ClusterPending = "Pending"
	ClusterConnect = "Connect"
)
View Source
const (
	WorkspaceTypeCode   = "code"
	WorkspaceTypeCustom = "custom"
)
View Source
const (
	WorkspaceCodeTypeHttps  = "https"
	WorkspaceCodeTypeGit    = "git"
	WorkspaceCodeTypeGitHub = "github"
	WorkspaceCodeTypeGitLab = "gitlab"
	WorkspaceCodeTypeGitee  = "gitee"
)
View Source
const (
	StageTriggerModeAuto   = "auto"
	StageTriggerModeManual = "manual"
)
View Source
const (
	PipelineStatusWait  = "wait"
	PipelineStatusDoing = "doing"
	PipelineStatusOK    = "ok"
	PipelineStatusError = "error"
	PipelineStatusPause = "pause"
	// PipelineStatusCancel 取消中,取消完成后状态为canceled
	PipelineStatusCancel = "cancel"
	// PipelineStatusCanceled 取消执行完成后状态
	PipelineStatusCanceled = "canceled"

	PipelineEnvWorkspaceId         = "PIPELINE_WORKSPACE_ID"
	PipelineEnvWorkspaceName       = "PIPELINE_WORKSPACE_NAME"
	PipelineEnvPipelineId          = "PIPELINE_PIPELINE_ID"
	PipelineEnvPipelineName        = "PIPELINE_PIPELINE_NAME"
	PipelineEnvPipelineBuildNumber = "PIPELINE_BUILD_NUMBER"
	PipelineEnvPipelineTriggerUser = "PIPELINE_TRIGGER_USER"
	PipelineEnvPipelineBuildId     = "PIPELINE_BUILD_ID"
)
View Source
const (
	// PipelineSourceTypeCode 流水线构建来源为代码库
	PipelineSourceTypeCode = "code"
	// PipelineSourceTypePipeline 流水线构建来源于其他流水线
	PipelineSourceTypePipeline = "pipeline"

	PipelineTriggerOperatorEqual   = "equal"
	PipelineTriggerOperatorExclude = "exclude"
	PipelineTriggerOperatorInclude = "regex"
)
View Source
const (
	// PipelineCodeCacheStatusOpen 对代码分支进行缓存
	PipelineCodeCacheStatusOpen = "open"
	// PipelineCodeCacheStatusClose 不进行代码分支缓存,当该代码空间下没有流水线代码触发配置时,状态为close,不需要缓存
	PipelineCodeCacheStatusClose = "close"
)
View Source
const (
	PipelineBranchTypeBranch  = "branch"
	PipelineBranchTypeRequest = "request"
)
View Source
const (
	// PipelineTriggerTypeCron 定时触发流水线构建
	PipelineTriggerTypeCron = "cron"
	// PipelineTriggerTypeCode 代码提交更新时触发流水线构建
	PipelineTriggerTypeCode = "code"
)
View Source
const (
	// PipelineTriggerEventStatusNew 新生成未消费的触发事件
	PipelineTriggerEventStatusNew = "new"
	// PipelineTriggerEventStatusConsumed 已消费的事件
	PipelineTriggerEventStatusConsumed = "consumed"

	// PipelineTriggerEventFromTrigger 事件触发来源流水线触发配置
	PipelineTriggerEventFromTrigger = "trigger"
)
View Source
const (
	BuiltinPluginBuildCodeToImage = "build_code_to_image"
	BuiltinPluginExecuteShell     = "execute_shell"

	// BuiltinPluginUpgradeApp 根据构建出来的代码镜像,升级项目应用
	BuiltinPluginUpgradeApp = "upgrade_app"
	// BuiltinPluginRelease 发布版本,给代码及镜像打发布tag号
	BuiltinPluginRelease = "release"
	// BuiltinPluginDeployK8s 替换镜像,并部署k8s资源
	BuiltinPluginDeployK8s = "deploy_k8s"
)
View Source
const (
	// PluginParamsFromEnv 从当前执行的环境变量中获取参数
	PluginParamsFromEnv = "env"

	// PluginParamsFromJob 从当前任务中的运行时变量获取执行参数
	PluginParamsFromJob = "job"

	// PluginParamsFromCodeSecret 当前流水线空间的代码密钥
	PluginParamsFromCodeSecret = "code_secret"

	// PluginParamsFromImageRegistry 平台配置中的镜像仓库配置
	PluginParamsFromImageRegistry = "image_registry"

	// PluginParamsFromPipelineResource 流水线中的资源数据,如镜像以及主机
	PluginParamsFromPipelineResource = "pipeline_resource"

	// PluginParamsFromPipelineEnv 流水线执行到当前的所有参数
	PluginParamsFromPipelineEnv = "pipeline_env"
)
View Source
const (
	OpGet    = "get"
	OpCreate = "create"
	OpUpdate = "update"
	OpDelete = "delete"
)
View Source
const (
	SettingsSecretTypePassword = "password"
	SettingsSecretTypeKey      = "key"
	SettingsSecretTypeToken    = "token"
)
View Source
const (
	// SpaceletStatusOnline spacele状态在线
	SpaceletStatusOnline = "online"
	// SpaceletStatusOffline spacelet状态不在线
	SpaceletStatusOffline = "offline"
)
View Source
const (
	ScopePlatform = "platform"
	ScopeCluster  = "cluster"
	ScopePipeline = "pipeline"
	ScopeProject  = "project"
	ScopeAppStore = "appstore"

	// RoleViewer 观察员,范围内只有查询资源权限
	RoleViewer = "viewer"
	// RoleEditor 编辑员,范围内有查询、更新、创建、删除权限,但是没有成员管理以及删除该范围权限
	RoleEditor = "editor"
	// RoleAdmin 管理员,范围内所有权限
	RoleAdmin = "admin"
)
View Source
const (
	ADMIN = "admin"
)
View Source
const PipelinePluginBuiltinUrl = "builtin"

Variables

View Source
var (
	AdminRole = &Role{
		Name:        "admin",
		Description: "管理员角色,拥有所有对象权限",
		Permissions: AllPermissions,
	}

	EditRole = &Role{
		Name:        "edit",
		Description: "编辑角色,拥有集群对象的操作权限",
		Permissions: []Permission{},
	}

	ViewRole = &Role{
		Name:        "view",
		Description: "查看角色,拥有集群对象的查看权限,没有操作权限",
		Permissions: []Permission{},
	}
)
View Source
var AllPermissions = []Permission{
	{
		Scope:      "settings",
		Object:     "cluster",
		Name:       "集群管理",
		Operations: []string{OpGet, OpCreate, OpUpdate, OpDelete},
	},
	{
		Scope:      "settings",
		Object:     "user",
		Name:       "用户管理",
		Operations: []string{OpGet, OpCreate, OpUpdate, OpDelete},
	},
	{
		Scope:      "settings",
		Object:     "role",
		Name:       "角色管理",
		Operations: []string{OpGet, OpCreate, OpUpdate, OpDelete},
	},
	{
		Scope:      "cluster",
		Object:     "node",
		Name:       "节点管理",
		Operations: []string{OpGet, OpCreate, OpUpdate, OpDelete},
	},
	{
		Scope:      "cluster",
		Object:     "pod",
		Name:       "容器组",
		Operations: []string{OpGet, OpCreate, OpUpdate, OpDelete},
	},
	{
		Scope:      "cluster",
		Object:     "deployment",
		Name:       "无状态",
		Operations: []string{OpGet, OpCreate, OpUpdate, OpDelete},
	},
	{
		Scope:      "cluster",
		Object:     "statefulset",
		Name:       "有状态",
		Operations: []string{OpGet, OpCreate, OpUpdate, OpDelete},
	},
	{
		Scope:      "cluster",
		Object:     "daemonset",
		Name:       "守护进程集",
		Operations: []string{OpGet, OpCreate, OpUpdate, OpDelete},
	},
	{
		Scope:      "cluster",
		Object:     "job",
		Name:       "任务",
		Operations: []string{OpGet, OpCreate, OpUpdate, OpDelete},
	},
	{
		Scope:      "cluster",
		Object:     "cronjob",
		Name:       "定时任务",
		Operations: []string{OpGet, OpCreate, OpUpdate, OpDelete},
	},
	{
		Scope:      "cluster",
		Object:     "configmap",
		Name:       "配置项",
		Operations: []string{OpGet, OpCreate, OpUpdate, OpDelete},
	},
	{
		Scope:      "cluster",
		Object:     "secret",
		Name:       "保密字典",
		Operations: []string{OpGet, OpCreate, OpUpdate, OpDelete},
	},
	{
		Scope:      "cluster",
		Object:     "hpa",
		Name:       "水平扩缩容",
		Operations: []string{OpGet, OpCreate, OpUpdate, OpDelete},
	},
	{
		Scope:      "cluster",
		Object:     "service",
		Name:       "服务",
		Operations: []string{OpGet, OpCreate, OpUpdate, OpDelete},
	},
	{
		Scope:      "cluster",
		Object:     "ingress",
		Name:       "路由",
		Operations: []string{OpGet, OpCreate, OpUpdate, OpDelete},
	},
	{
		Scope:      "cluster",
		Object:     "networkPolicy",
		Name:       "网络策略",
		Operations: []string{OpGet, OpCreate, OpUpdate, OpDelete},
	},
	{
		Scope:      "cluster",
		Object:     "pvc",
		Name:       "存储声明",
		Operations: []string{OpGet, OpCreate, OpUpdate, OpDelete},
	},
	{
		Scope:      "cluster",
		Object:     "pv",
		Name:       "存储卷",
		Operations: []string{OpGet, OpCreate, OpUpdate, OpDelete},
	},
	{
		Scope:      "cluster",
		Object:     "sc",
		Name:       "存储类",
		Operations: []string{OpGet, OpCreate, OpUpdate, OpDelete},
	},
	{
		Scope:      "cluster",
		Object:     "namespace",
		Name:       "命名空间",
		Operations: []string{OpGet, OpCreate, OpUpdate, OpDelete},
	},
	{
		Scope:      "cluster",
		Object:     "event",
		Name:       "事件",
		Operations: []string{OpGet, OpCreate, OpUpdate, OpDelete},
	},
	{
		Scope:      "cluster",
		Object:     "serviceaccount",
		Name:       "服务账户",
		Operations: []string{OpGet, OpCreate, OpUpdate, OpDelete},
	},
	{
		Scope:      "cluster",
		Object:     "rolebinding",
		Name:       "角色绑定",
		Operations: []string{OpGet, OpCreate, OpUpdate, OpDelete},
	},
	{
		Scope:      "cluster",
		Object:     "role",
		Name:       "角色",
		Operations: []string{OpGet, OpCreate, OpUpdate, OpDelete},
	},
}
View Source
var JobAlreadyRunningError = errors.New("job already running")

Functions

This section is empty.

Types

type App

type App struct {
	ID           uint        `gorm:"primaryKey" json:"id"`
	Scope        string      `` /* 132-byte string literal not displayed */
	ScopeId      uint        `gorm:"not null;uniqueIndex:ScopeNameUnique" json:"scope_id"`
	Name         string      `gorm:"size:255;not null;uniqueIndex:ScopeNameUnique" json:"name"`
	Description  string      `gorm:"type:text;" json:"description"`
	AppVersionId uint        `gorm:"comment:当前最新或者正在运行的应用版本" json:"app_version_id"`
	AppVersion   *AppVersion `gorm:"-" json:"app_version"`
	Type         string      `gorm:"size:255;not null;comment:应用类型" json:"type"`
	Status       string      `gorm:"not null;size:255;comment:应用状态" json:"status"`
	Namespace    string      `gorm:"size:255;" json:"namespace"`
	CreateUser   string      `gorm:"size:255;not null" json:"create_user"`
	UpdateUser   string      `gorm:"size:255;not null" json:"update_user"`
	CreateTime   time.Time   `gorm:"column:create_time;not null;autoCreateTime" json:"create_time"`
	UpdateTime   time.Time   `gorm:"column:update_time;not null;autoUpdateTime" json:"update_time"`

	PodsNum      int `gorm:"-" json:"pods_num"`
	ReadyPodsNum int `gorm:"-" json:"ready_pods_num"`
}

type AppRevision

type AppRevision struct {
	ID            uint      `gorm:"primaryKey" json:"id"`
	AppId         uint      `gorm:"not null;uniqueIndex:ProjectAppBuildRevisionUnique" json:"app_id"`
	BuildRevision uint      `gorm:"not null;uniqueIndex:ProjectAppBuildRevisionUnique" json:"build_revision"`
	AppVersionId  uint      `gorm:"not null;" json:"app_version_id"`
	Values        string    `gorm:"type:longtext;not null" json:"values"`
	CreateUser    string    `gorm:"size:50;not null" json:"create_user"`
	CreateTime    time.Time `gorm:"column:create_time;not null;autoCreateTime" json:"create_time"`
	UpdateTime    time.Time `gorm:"column:update_time;not null;autoUpdateTime" json:"update_time"`
}

AppRevision 应用安装升级历史记录

type AppStore

type AppStore struct {
	ID          uint      `gorm:"primaryKey" json:"id"`
	Name        string    `gorm:"size:255;not null;" json:"name"`
	Description string    `gorm:"type:text;" json:"description"`
	Type        string    `gorm:"size:255;not null;comment:应用类型,包括普通应用/中间件/集群组件" json:"type"`
	Icon        []byte    `gorm:"type:mediumblob" json:"icon"`
	CreateUser  string    `gorm:"size:255;not null" json:"create_user"`
	UpdateUser  string    `gorm:"size:255;not null" json:"update_user"`
	CreateTime  time.Time `gorm:"column:create_time;not null;autoCreateTime" json:"create_time"`
	UpdateTime  time.Time `gorm:"column:update_time;not null;autoUpdateTime" json:"update_time"`
}

AppStore 应用商店应用

type AppVersion

type AppVersion struct {
	ID             uint      `gorm:"primaryKey" json:"id"`
	Scope          string    `` /* 143-byte string literal not displayed */
	ScopeId        uint      `gorm:"not null;uniqueIndex:ScopeAppNameVersionUnique;comment:工作空间应用id或应用商店id" json:"scope_id"`
	PackageName    string    `gorm:"size:255;not null;uniqueIndex:ScopeAppNameVersionUnique" json:"package_name"`
	PackageVersion string    `gorm:"size:255;not null;uniqueIndex:ScopeAppNameVersionUnique" json:"package_version"`
	From           string    `gorm:"size:255;not null;comment:应用版本来源" json:"from"`
	AppVersion     string    `gorm:"size:255;not null" json:"app_version"`
	Values         string    `gorm:"type:longtext;not null" json:"values"`
	Description    string    `gorm:"type:text;" json:"description"`
	ChartPath      string    `gorm:"size:255;not null;comment:该应用版本chart存储路径" json:"chart_path"`
	CreateUser     string    `gorm:"size:50;not null" json:"create_user"`
	CreateTime     time.Time `gorm:"column:create_time;not null;autoCreateTime" json:"create_time"`
	UpdateTime     time.Time `gorm:"column:update_time;not null;autoUpdateTime" json:"update_time"`
}

AppVersion 应用版本

type AppVersionChart

type AppVersionChart struct {
	ID         uint      `gorm:"primaryKey" json:"id"`
	Path       string    `gorm:"size:255;uniqueIndex;comment:chart路径"`
	Content    []byte    `gorm:"type:mediumblob;comment:chart内容" json:"content"`
	CreateTime time.Time `gorm:"column:create_time;not null;autoCreateTime" json:"create_time"`
	UpdateTime time.Time `gorm:"column:update_time;not null;autoUpdateTime" json:"update_time"`
}

AppVersionChart 应用版本chart存储,相同chart只存储一份

type AuditOperate

type AuditOperate struct {
	ID                   uint           `gorm:"primaryKey" json:"id"`
	Operator             string         `gorm:"size:255;not null;comment:操作人" json:"operator"`
	Operation            string         `gorm:"size:255;not null;comment:操作类型(create/delete/update)" json:"operation"`
	OperateDetail        string         `gorm:"type:text;not null;comment:操作详情" json:"operate_detail"`
	Scope                string         `gorm:"size:50;not null;comment:操作对象所属范围(project/pipeline/cluster/platform)" json:"scope"`
	ScopeId              uint           `gorm:"not null;comment:所属范围id" json:"scope_id"`
	ScopeName            string         `gorm:"size:512;not null;comment:所属范围名称" json:"scope_name"`
	Namespace            string         `gorm:"size:512;not null;comment:集群命名空间" json:"namespace"`
	ResourceId           uint           `gorm:"not null;comment:操作资源id" json:"resource_id"`
	ResourceType         string         `gorm:"size:255;not null;comment:资源类型" json:"resource_type"`
	ResourceName         string         `gorm:"size:512;not null;comment:资源名称" json:"resource_name"`
	Code                 string         `gorm:"size:255;not null;comment:操作返回码" json:"code"`
	Message              string         `gorm:"type:text;not null;comment:操作返回信息" json:"message"`
	OperateData          datatypes.JSON `gorm:"type:json;comment:操作数据,操作参数以及返回数据" json:"operate_data"`
	OperateDataInterface interface{}    `gorm:"-" json:"-"`
	Ip                   string         `gorm:"size:512;comment:来源ip" json:"ip"`
	CreateTime           time.Time      `gorm:"column:create_time;not null;autoCreateTime" json:"create_time"`
}

AuditOperate 操作审计

func (AuditOperate) TableName

func (s AuditOperate) TableName() string

type Cluster

type Cluster struct {
	ID         uint      `gorm:"primaryKey" json:"id"`
	Name1      string    `gorm:"column:name;size:500;not null;uniqueIndex" json:"name1"`
	Name       string    `gorm:"-" json:"name"`
	KubeConfig string    `gorm:"type:text;column:kubeconfig" json:"-"`
	Token      string    `gorm:"size:255;not null;uniqueIndex" json:"token"`
	Status     string    `gorm:"size:50;" json:"status"`
	CreatedBy  string    `gorm:"size:255;not null;" json:"created_by"`
	Members    []string  `gorm:"-" json:"members"`
	CreateTime time.Time `gorm:"column:create_time;not null;autoCreateTime" json:"create_time"`
	UpdateTime time.Time `gorm:"column:update_time;not null;autoUpdateTime" json:"update_time"`
}

type ClusterStore

type ClusterStore struct {
	Common

	Name      string `json:"name"`
	Token     string `json:"token"`
	Status    string `json:"status"`
	CreatedBy string `json:"created_by"`
	Members   string `json:"members"`
}

type CodeBranchCommitCache

type CodeBranchCommitCache struct {
	BranchLatestCommit map[string]*PipelineBuildCodeBranch `json:"branches"`
}

CodeBranchCommitCache 流水线代码源分支最新提交记录缓存

func (*CodeBranchCommitCache) Scan

func (c *CodeBranchCommitCache) Scan(value interface{}) error

func (CodeBranchCommitCache) Value

func (c CodeBranchCommitCache) Value() (driver.Value, error)

type Common

type Common struct {
	CreateTime string `json:"create_time"`
	UpdateTime string `json:"update_time"`
}

type DBMigration

type DBMigration struct {
	Id         uint      `gorm:"primaryKey" json:"id"`
	Version    string    `gorm:"size:255" json:"version"` // 当前迁移的最新版本
	Lock       bool      `json:"lock"`                    // 迁移时首先要获取锁,保证每次只有一个实例在迁移
	CreateTime time.Time `json:"create_time"`
	UpdateTime time.Time `json:"update_time"`
}

DBMigration 数据库迁移表,在每次迭代时,有可能需要更新数据库表结构,那么需要做一些迁移的动作,比如增加字段或者数据迁移 该表会记录最新一次的迁移版本,下次如果有新的迁移版本,那么从该版本继续迁移

func (DBMigration) TableName

func (d DBMigration) TableName() string

type ImageRegistry

type ImageRegistry struct {
	Registry string `json:"registry"`
	User     string `json:"user"`
	Password string `json:"password"`
}

type Ldap

type Ldap struct {
	ID          uint   `gorm:"primaryKey" json:"id"`
	Name        string `gorm:"size:64;not null" json:"name"`
	Enable      string `gorm:"size:16;not null" json:"enable"`
	Url         string `gorm:"size:255;not null" json:"url"`
	MaxConn     int    `gorm:"type:uint" json:"max_conn"`
	BaseDN      string `gorm:"size:255;not null" json:"base_dn"`
	AdminDN     string `gorm:"size:64;not null" json:"admin_dn"`
	AdminDNPass string `gorm:"size:64;not null" json:"admin_dn_pass"`
}

func (Ldap) TableName

func (Ldap) TableName() string

type Map

type Map map[string]interface{}

func (*Map) Scan

func (m *Map) Scan(value interface{}) error

func (Map) Value

func (m Map) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type Permission

type Permission struct {
	Scope      string   `json:"scope"`
	Object     string   `json:"object"`
	Name       string   `json:"name"`
	Operations []string `json:"operations"`
}

type Pipeline

type Pipeline struct {
	ID          uint             `gorm:"primaryKey" json:"id"`
	Name        string           `gorm:"size:50;not null;uniqueIndex:idx_workspace_name" json:"name"`
	WorkspaceId uint             `gorm:"not null;uniqueIndex:idx_workspace_name" json:"workspace_id"`
	Sources     PipelineSources  `gorm:"type:json" json:"sources"`
	Stages      []*PipelineStage `gorm:"-" json:"stages"`
	CreateUser  string           `gorm:"size:50;not null" json:"create_user"`
	UpdateUser  string           `gorm:"size:50;not null" json:"update_user"`
	CreateTime  time.Time        `gorm:"not null;autoCreateTime" json:"create_time"`
	UpdateTime  time.Time        `gorm:"not null;autoUpdateTime" json:"update_time"`
}

type PipelineBuildCodeBranch

type PipelineBuildCodeBranch struct {
	Branch     string    `json:"branch"`
	CommitId   string    `json:"commit_id"`
	Author     string    `json:"author"`
	Message    string    `json:"message"`
	CommitTime time.Time `json:"commit_time"`
}

type PipelineBuildConfig

type PipelineBuildConfig struct {
	// 代码源触发时的提交
	CodeBranch *PipelineBuildCodeBranch `json:"code_branch,omitempty"`
	// 自定义流水线触发时的流水线源
	CustomSources []*PipelineBuildCustomSource `json:"custom_sources,omitempty"`
}

PipelineBuildConfig 流水线触发事件的配置信息,

  1. 如果是代码源更新触发,则触发配置为分支以及commit_id
  2. 如果是定时触发,则该配置为空,根据流水线的类型生成流水线构建 a. 如果是代码源流水线,则根据监听的所有分支,找到最新构建的分支进行构建 b. 如果是自定义流水线,则查询监听的所有流水线,找到最新的构建成功的记录进行构建

func (*PipelineBuildConfig) Scan

func (pt *PipelineBuildConfig) Scan(value interface{}) error

func (PipelineBuildConfig) Value

func (pt PipelineBuildConfig) Value() (driver.Value, error)

type PipelineBuildCustomSource

type PipelineBuildCustomSource struct {
	WorkspaceId         uint   `json:"workspace_id"`
	WorkspaceName       string `json:"workspace_name"`
	PipelineId          uint   `json:"pipeline_id"`
	PipelineName        string `json:"pipeline_name"`
	BuildReleaseVersion string `json:"build_release_version"`
	BuildId             uint   `json:"build_id"`
	BuildNumber         uint   `json:"build_number"`
	BuildOperator       string `json:"build_operator"`
	IsBuild             bool   `json:"is_build" default:"true"`
}

type PipelineCodeCache

type PipelineCodeCache struct {
	ID          uint `gorm:"primaryKey" json:"id"`
	WorkspaceId uint `gorm:"" json:"workspace_id"`
	// 缓存状态,open(开启)/close(关闭),当该代码空间下没有流水线代码触发配置时,状态为close,不需要缓存
	Status      string                 `gorm:"size:50" json:"status"`
	CommitCache *CodeBranchCommitCache `gorm:"type:json" json:"branch_cache"`
	CreateTime  time.Time              `gorm:"column:create_time;not null;autoCreateTime" json:"create_time"`
	UpdateTime  time.Time              `gorm:"column:update_time;not null;autoUpdateTime" json:"update_time"`
}

PipelineCodeCache 缓存代码分支的最新commit

func (*PipelineCodeCache) Unmarshal

func (p *PipelineCodeCache) Unmarshal(bytes []byte) (interface{}, error)

type PipelineJob

type PipelineJob struct {
	Name      string                 `json:"name"`
	PluginKey string                 `json:"plugin_key"`
	Params    map[string]interface{} `json:"params"`
	// spacelet调度策略
	SchedulePolicy *PipelineJobSchedulePolicy `json:"schedule_policy,omitempty"`
}

type PipelineJobSchedulePolicy

type PipelineJobSchedulePolicy struct {
	// 指定spacelet主机名
	Hostname string `json:"hostname,omitempty"`
	// 指定spacelet标签
	SpaceletSelector map[string]string `json:"spacelet_selector,omitempty"`
}

func (*PipelineJobSchedulePolicy) Scan

func (pj *PipelineJobSchedulePolicy) Scan(value interface{}) error

func (PipelineJobSchedulePolicy) Value

Value return json value, implement driver.Valuer interface

type PipelineJobs

type PipelineJobs []*PipelineJob

func (*PipelineJobs) Scan

func (pj *PipelineJobs) Scan(value interface{}) error

func (PipelineJobs) Value

func (pj PipelineJobs) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type PipelinePlugin

type PipelinePlugin struct {
	ID         uint                    `gorm:"primaryKey"`
	Name       string                  `gorm:"size:255;not null;uniqueIndex:idx_plugin_name"`
	Key        string                  `gorm:"size:50;not null;uniqueIndex:idx_plugin_key"`
	Url        string                  `gorm:"size:255;not null"`
	Params     PipelinePluginParams    `gorm:"type:json;not null"`
	Version    string                  `gorm:"version"`
	ResultEnv  PipelinePluginResultEnv `gorm:"type:json;"`
	CreateTime time.Time               `gorm:"not null;autoCreateTime"`
	UpdateTime time.Time               `gorm:"not null;autoUpdateTime"`
}

type PipelinePluginParams

type PipelinePluginParams struct {
	Params []*PipelinePluginParamsSpec `json:"params"`
}

func (*PipelinePluginParams) Scan

func (p *PipelinePluginParams) Scan(value interface{}) error

func (PipelinePluginParams) Value

func (p PipelinePluginParams) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type PipelinePluginParamsSpec

type PipelinePluginParamsSpec struct {
	ParamName string      `json:"param_name"`
	From      string      `json:"from"`
	FromName  string      `json:"from_name"`
	Default   interface{} `json:"default"`
}

type PipelinePluginResultEnv

type PipelinePluginResultEnv struct {
	EnvPath []*PipelinePluginResultEnvPath `json:"env_path"`
}

func (*PipelinePluginResultEnv) Scan

func (p *PipelinePluginResultEnv) Scan(value interface{}) error

func (PipelinePluginResultEnv) Value

Value return json value, implement driver.Valuer interface

type PipelinePluginResultEnvPath

type PipelinePluginResultEnvPath struct {
	EnvName    string `json:"env_name"`
	ResultName string `json:"result_name"`
}

type PipelineResource

type PipelineResource struct {
	ID          uint            `gorm:"primaryKey" json:"id"`
	WorkspaceId uint            `gorm:"not null;uniqueIndex:idx_workspace_resource" json:"workspace_id"`
	Name        string          `gorm:"size:255;not null;uniqueIndex:idx_workspace_resource" json:"name"`
	Global      bool            `gorm:"default:false" json:"global"`
	Type        string          `gorm:"size:50;not null" json:"type"`
	Value       string          `gorm:"size:500; not null;" json:"value"`
	SecretId    uint            `gorm:"" json:"secret_id"`
	Secret      *SettingsSecret `gorm:"-" json:"secret"`
	Description string          `gorm:"size:2000" json:"description"`
	CreateUser  string          `gorm:"size:50;not null" json:"create_user"`
	UpdateUser  string          `gorm:"size:50;not null" json:"update_user"`
	CreateTime  time.Time       `gorm:"not null;autoCreateTime" json:"create_time"`
	UpdateTime  time.Time       `gorm:"not null;autoUpdateTime" json:"update_time"`
}

type PipelineRun

type PipelineRun struct {
	ID          uint      `gorm:"primaryKey" json:"id"`
	PipelineId  uint      `gorm:"not null;uniqueIndex:idx_pipeline_build_number" json:"pipeline_id"`
	BuildNumber uint      `gorm:"not null;uniqueIndex:idx_pipeline_build_number" json:"build_number"`
	Params      Map       `gorm:"type:json" json:"params"`
	Status      string    `gorm:"size:50;not null" json:"status"`
	Env         Map       `gorm:"type:json" json:"env"`
	Operator    string    `gorm:"size:50;not null" json:"operator"`
	CreateTime  time.Time `gorm:"not null;autoCreateTime" json:"create_time"`
	UpdateTime  time.Time `gorm:"not null;autoUpdateTime" json:"update_time"`
}

func (*PipelineRun) Unmarshal

func (p *PipelineRun) Unmarshal(bytes []byte) (interface{}, error)

type PipelineRunJob

type PipelineRunJob struct {
	ID             uint                       `gorm:"primaryKey" json:"id"`
	PipelineRunId  uint                       `gorm:"not null" json:"pipeline_run_id"`
	StageRunId     uint                       `gorm:"not null" json:"stage_run_id"`
	Name           string                     `gorm:"size:50;not null" json:"name"`
	PluginKey      string                     `gorm:"size:255;not null" json:"plugin_key"`
	Status         string                     `gorm:"size:50;not null" json:"status"`
	Env            Map                        `gorm:"type:json;comment:任务执行完成后的变量参数值" json:"env"`
	Params         Map                        `gorm:"type:json;not null;comment:任务执行时参数" json:"params"`
	Result         *utils.Response            `gorm:"type:json;comment:任务执行结果" json:"result"`
	SpaceletId     uint                       `gorm:"comment:任务执行时的spacelet代理节点" json:"spacelet_id"`
	SchedulePolicy *PipelineJobSchedulePolicy `gorm:"type:json;comment:任务执行时调度到spacelet策略" json:"schedule_policy"`
	CreateTime     time.Time                  `gorm:"not null;autoCreateTime" json:"create_time"`
	UpdateTime     time.Time                  `gorm:"not null;autoUpdateTime" json:"update_time"`
}

func (*PipelineRunJob) Unmarshal

func (p *PipelineRunJob) Unmarshal(bytes []byte) (interface{}, error)

type PipelineRunJobLog

type PipelineRunJobLog struct {
	ID         uint      `gorm:"primaryKey" json:"id"`
	JobRunId   uint      `gorm:"column:job_run_id;not null" json:"job_run_id"`
	Logs       string    `gorm:"type:longtext" json:"logs"`
	CreateTime time.Time `gorm:"not null;autoCreateTime" json:"create_time"`
	UpdateTime time.Time `gorm:"not null;autoUpdateTime" json:"update_time"`
}

type PipelineRunJobs

type PipelineRunJobs []*PipelineRunJob

type PipelineRunStage

type PipelineRunStage struct {
	ID             uint            `gorm:"primaryKey" json:"id"`
	Name           string          `gorm:"name;size:255;not null" json:"name"`
	TriggerMode    string          `gorm:"size:20;not null" json:"trigger_mode"`
	PrevStageRunId uint            `gorm:"not null" json:"prev_stage_run_id"`
	PipelineRunId  uint            `gorm:"not null" json:"pipeline_run_id"`
	Status         string          `gorm:"size:50;not null" json:"status"`
	Env            Map             `gorm:"type:json" json:"env"`
	CustomParams   Map             `gorm:"json" json:"custom_params"`
	Jobs           PipelineRunJobs `gorm:"-" json:"jobs"`
	ExecTime       time.Time       `gorm:"not null;autoCreateTime" json:"exec_time"`
	FinishTime     *time.Time      `gorm:"" json:"finish_time"`
	CreateTime     time.Time       `gorm:"not null;autoCreateTime" json:"create_time"`
	UpdateTime     time.Time       `gorm:"not null;autoUpdateTime" json:"update_time"`
}

type PipelineSource

type PipelineSource struct {
	Type          string `json:"type"`
	Workspace     uint   `json:"workspace"`
	WorkspaceName string `json:"workspace_name"`
	Pipeline      uint   `json:"pipeline"`
	PipelineName  string `json:"pipeline_name"`
	Stage         uint   `json:"stage"`
	BranchType    string `json:"branch_type"`
	Operator      string `json:"operator"`
	Branch        string `json:"branch"`
}

PipelineSource 流水线触发源,代码分支以及其他流水线

type PipelineSources

type PipelineSources []*PipelineSource

func (*PipelineSources) Scan

func (pt *PipelineSources) Scan(value interface{}) error

func (PipelineSources) Value

func (pt PipelineSources) Value() (driver.Value, error)

type PipelineStage

type PipelineStage struct {
	ID         uint   `gorm:"primaryKey" json:"id"`
	Name       string `gorm:"size:50;not null;uniqueIndex:idx_pipeline_stage_name" json:"name"`
	PipelineId uint   `gorm:"not null;uniqueIndex:idx_pipeline_stage_name" json:"pipeline_id"`
	// 在流水线中对阶段的自定义参数,执行时自动放到阶段的env中
	CustomParams Map          `gorm:"type:json" json:"custom_params"`
	TriggerMode  string       `gorm:"size:20;not null;" json:"trigger_mode"`
	PrevStageId  uint         `gorm:"not null" json:"prev_stage_id"`
	Jobs         PipelineJobs `gorm:"type:json;not null" json:"jobs"`
}

PipelineStage 流水线阶段

type PipelineTrigger

type PipelineTrigger struct {
	ID         uint                  `gorm:"primaryKey" json:"id"`
	PipelineId uint                  `gorm:"" json:"pipeline_id"`
	Type       string                `json:"type"`
	Config     PipelineTriggerConfig `gorm:"type:json" json:"config"`
	// 下一次触发时间
	NextTriggerTime *sql.NullTime `gorm:"" json:"next_trigger_time"`
	UpdateUser      string        `gorm:"size:50;not null" json:"update_user"`
	CreateTime      time.Time     `gorm:"not null;autoCreateTime" json:"create_time"`
	UpdateTime      time.Time     `gorm:"not null;autoUpdateTime" json:"update_time"`
}

PipelineTrigger 流水线触发配置

func (*PipelineTrigger) Unmarshal

func (p *PipelineTrigger) Unmarshal(bytes []byte) (interface{}, error)

type PipelineTriggerConfig

type PipelineTriggerConfig struct {
	// 定时触发配置
	Cron *PipelineTriggerConfigCron `json:"cron,omitempty"`
	// 代码源分支最近一次触发的提交记录
	Code *PipelineTriggerConfigCode `json:"code,omitempty"`
}

func (*PipelineTriggerConfig) Scan

func (pt *PipelineTriggerConfig) Scan(value interface{}) error

func (PipelineTriggerConfig) Value

func (pt PipelineTriggerConfig) Value() (driver.Value, error)

type PipelineTriggerConfigCode

type PipelineTriggerConfigCode struct {
	BranchLatestCommit map[string]*PipelineBuildCodeBranch `json:"branches"`
}

PipelineTriggerConfigCode 流水线代码源分支最新提交记录

type PipelineTriggerConfigCron

type PipelineTriggerConfigCron struct {
	Cron string `json:"cron"`
}

PipelineTriggerConfigCron 流水线定时触发配置

type PipelineTriggerEvent

type PipelineTriggerEvent struct {
	ID         uint   `gorm:"primaryKey" json:"id"`
	PipelineId uint   `gorm:"" json:"pipeline_id"`
	From       string `gorm:"size:50" json:"from"`
	TriggerId  uint   `gorm:"" json:"trigger_id"`
	Status     string `gorm:"size:50;" json:"status"`
	// 事件触发的构建配置
	EventConfig PipelineBuildConfig `gorm:"type:json" json:"event_config"`
	// 事件执行结果记录,触发成功/失败,以及失败原因
	EventResult *utils.Response `gorm:"type:json" json:"event_result"`
	TriggerUser string          `gorm:"size:255;" json:"trigger_user"`
	CreateTime  time.Time       `gorm:"not null;autoCreateTime" json:"create_time"`
	UpdateTime  time.Time       `gorm:"not null;autoUpdateTime" json:"update_time"`
}

PipelineTriggerEvent 根据流水线触发配置,当触发条件达到时生成触发事件,根据事件生成新的流水线构建任务

func (*PipelineTriggerEvent) Unmarshal

func (p *PipelineTriggerEvent) Unmarshal(bytes []byte) (interface{}, error)

type PipelineWorkspace

type PipelineWorkspace struct {
	ID          uint                   `gorm:"primaryKey" json:"id"`
	Name        string                 `gorm:"size:255;not null;uniqueIndex" json:"name"`
	Description string                 `gorm:"type:text;" json:"description"`
	Pipelines   []*Pipeline            `gorm:"-" json:"pipelines"`
	Type        string                 `gorm:"size:20;not null" json:"type"`
	Code        *PipelineWorkspaceCode `gorm:"type:json" json:"code"`
	CreateUser  string                 `gorm:"size:50;not null" json:"create_user"`
	UpdateUser  string                 `gorm:"size:50;not null" json:"update_user"`
	CreateTime  time.Time              `gorm:"column:create_time;not null;autoCreateTime" json:"create_time"`
	UpdateTime  time.Time              `gorm:"column:update_time;not null;autoUpdateTime" json:"update_time"`
}

type PipelineWorkspaceCode

type PipelineWorkspaceCode struct {
	Type     string `json:"type"`
	ApiUrl   string `json:"api_url"`
	CloneUrl string `json:"clone_url"`
	SecretId uint   `json:"secret_id"`
}

func (*PipelineWorkspaceCode) Scan

func (c *PipelineWorkspaceCode) Scan(value interface{}) error

func (PipelineWorkspaceCode) Value

func (c PipelineWorkspaceCode) Value() (driver.Value, error)

type PipelineWorkspaceRelease

type PipelineWorkspaceRelease struct {
	ID             uint      `gorm:"primaryKey" json:"id"`
	WorkspaceId    uint      `gorm:"not null;uniqueIndex:idx_workspace_version" json:"workspace_id"`
	ReleaseVersion string    `gorm:"size:500;not null;uniqueIndex:idx_workspace_version" json:"release_version"`
	JobRunId       uint      `gorm:"not null;" json:"job_run_id"`
	CreateTime     time.Time `gorm:"column:create_time;not null;autoCreateTime" json:"create_time"`
	UpdateTime     time.Time `gorm:"column:update_time;not null;autoUpdateTime" json:"update_time"`
}

type Project

type Project struct {
	ID          uint      `gorm:"primaryKey" json:"id"`
	Name        string    `gorm:"size:255;not null;uniqueIndex" json:"name"`
	Description string    `gorm:"size:2000;not null;" json:"description"`
	ClusterId   string    `gorm:"size:255;not null;" json:"cluster_id"`
	Namespace   string    `gorm:"size:255;not null;" json:"namespace"`
	Owner       string    `gorm:"size:255;not null" json:"owner"`
	CreateUser  string    `gorm:"size:255;not null" json:"create_user"`
	UpdateUser  string    `gorm:"size:255;not null" json:"update_user"`
	CreateTime  time.Time `gorm:"column:create_time;not null;autoCreateTime" json:"create_time"`
	UpdateTime  time.Time `gorm:"column:update_time;not null;autoUpdateTime" json:"update_time"`
}

type Role

type Role struct {
	Common
	Name        string       `json:"name"`
	Description string       `json:"description"`
	Permissions []Permission `json:"permissions"`
}

type RoleStore

type RoleStore struct {
	Common
	Name        string `json:"name"`
	Description string `json:"description"`
	Permissions string `json:"permissions"`
}

type Secret

type Secret struct {
	Type        string `json:"type"`
	User        string `json:"user"`
	Password    string `json:"password"`
	PrivateKey  string `json:"private_key"`
	AccessToken string `json:"access_token"`
}

Secret 用于所有地方的密钥,比如git、镜像仓库等

type SettingsImageRegistry

type SettingsImageRegistry struct {
	ID         uint      `gorm:"primaryKey" json:"id"`
	Registry   string    `gorm:"size:255;not null;uniqueIndex" json:"registry"`
	User       string    `gorm:"size:255;not null;" json:"user"`
	Password   string    `gorm:"size:255;not null;" json:"password"`
	CreateUser string    `gorm:"size:255;not null" json:"create_user"`
	UpdateUser string    `gorm:"size:255;not null" json:"update_user"`
	CreateTime time.Time `gorm:"not null;autoCreateTime" json:"create_time"`
	UpdateTime time.Time `gorm:"not null;autoUpdateTime" json:"update_time"`
}

func (*SettingsImageRegistry) GetImageRegistry

func (s *SettingsImageRegistry) GetImageRegistry() *ImageRegistry

type SettingsSecret

type SettingsSecret struct {
	ID          uint      `gorm:"primaryKey" json:"id"`
	Name        string    `gorm:"size:255;not null;uniqueIndex" json:"name"`
	Description string    `gorm:"size:2000;" json:"description"`
	Type        string    `gorm:"size:50;not null" json:"type"`
	User        string    `gorm:"size:255;" json:"user"`
	Password    string    `gorm:"size:255;" json:"-"`
	PrivateKey  string    `gorm:"size:5000;" json:"-"`
	AccessToken string    `gorm:"size:2000;" json:"-"`
	CreateUser  string    `gorm:"size:255;not null" json:"create_user"`
	UpdateUser  string    `gorm:"size:255;not null" json:"update_user"`
	CreateTime  time.Time `gorm:"not null;autoCreateTime" json:"create_time"`
	UpdateTime  time.Time `gorm:"not null;autoUpdateTime" json:"update_time"`
}

func (*SettingsSecret) GetSecret

func (s *SettingsSecret) GetSecret() *Secret

type Spacelet

type Spacelet struct {
	ID         uint           `gorm:"primaryKey" json:"id"`
	Hostname   string         `gorm:"size:255;not null;" json:"hostname"`
	HostIp     string         `gorm:"size:255;not null;uniqueIndex:HostPortUnique" json:"hostip"`
	Port       int            `gorm:"not null;uniqueIndex:HostPortUnique" json:"port"`
	Labels     SpaceletLabels `gorm:"type:json;comment:spacelet标签" json:"labels"`
	Token      string         `gorm:"size:255;not null;" json:"token,omitempty"`
	Status     string         `gorm:"size:50;not null" json:"status"`
	CreateTime time.Time      `gorm:"column:create_time;not null;autoCreateTime" json:"create_time"`
	UpdateTime time.Time      `gorm:"column:update_time;not null;autoUpdateTime" json:"update_time"`
}

Spacelet 流水线执行代理节点,spacelet启动时会进行注册

func (Spacelet) TableName

func (s Spacelet) TableName() string

type SpaceletLabels

type SpaceletLabels map[string]string

func (*SpaceletLabels) Scan

func (m *SpaceletLabels) Scan(value interface{}) error

func (SpaceletLabels) Value

func (m SpaceletLabels) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type User

type User struct {
	ID         uint         `gorm:"primaryKey" json:"id"`
	Name       string       `gorm:"size:255;not null;uniqueIndex" json:"name"`
	Email      string       `gorm:"size:500" json:"email"`
	Password   string       `gorm:"size:1000;not null" json:"password"`
	Roles      *[]*UserRole `gorm:"-" json:"roles"`
	Status     string       `gorm:"size:255" json:"status"`
	IsSuper    bool         `json:"is_super"`
	LastLogin  time.Time    `json:"last_login"`
	CreateTime time.Time    `gorm:"column:create_time;not null;autoCreateTime" json:"create_time"`
	UpdateTime time.Time    `gorm:"column:update_time;not null;autoUpdateTime" json:"update_time"`
}

type UserRole

type UserRole struct {
	ID         uint      `gorm:"primaryKey" json:"id"`
	UserId     uint      `gorm:"not null;uniqueIndex:idx_user_scope_id" json:"user_id"`
	UserName   string    `gorm:"-" json:"username"`
	Scope      string    `gorm:"size:50;not null;uniqueIndex:idx_user_scope_id" json:"scope"`
	ScopeId    uint      `gorm:"not null;uniqueIndex:idx_user_scope_id" json:"scope_id"`
	Role       string    `gorm:"size:50;not null;" json:"role"`
	CreateTime time.Time `gorm:"column:create_time;not null;autoCreateTime" json:"create_time"`
	UpdateTime time.Time `gorm:"column:update_time;not null;autoUpdateTime" json:"update_time"`
}

type UserSession

type UserSession struct {
	Common
	UserName  string    `json:"username"`
	SessionId uuid.UUID `json:"session_id"`
}

Jump to

Keyboard shortcuts

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