spec

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 21, 2021 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//pipelineCron表的字段名
	PipelineCronCronExpr = "cron_expr"
	PipelineCronEnable   = "enable"
)
View Source
const (
	StoreTypeNFSProto = "file://"
)

Variables

View Source
var (
	PipelineTaskExecutorNameEmpty            = ""
	PipelineTaskExecutorNameSchedulerDefault = "scheduler"
	PipelineTaskExecutorNameAPITestDefault   = "api-test"
)

Functions

This section is empty.

Types

type ActionExecutorConfig

type ActionExecutorConfig struct {
	Kind    string            `json:"kind,omitempty"`
	Name    string            `json:"name,omitempty"`
	Options map[string]string `json:"options,omitempty"`
}

type CIV3BuildArtifact

type CIV3BuildArtifact struct {
	ID           int64                        `json:"id" xorm:"pk autoincr BIGINT(20)"`
	CreatedAt    time.Time                    `json:"createdAt" xorm:"created"`
	UpdatedAt    time.Time                    `json:"updatedAt" xorm:"updated"`
	Sha256       string                       `json:"sha256" xorm:"sha_256"` // 唯一标识
	IdentityText string                       `json:"identityText"`          // 便于记忆的字段,用来生成唯一标识
	Type         apistructs.BuildArtifactType `json:"type"`                  // 类型,存的是文件在 NFS 上的地址,或者直接是文件内容
	Content      string                       `json:"content"`               // 内容,根据 type 进行解析
	ClusterName  string                       `json:"clusterName"`           // 集群 name
	PipelineID   uint64                       `json:"pipelineID"`            // 关联的构建 ID
}

func (*CIV3BuildArtifact) Convert2DTO

func (artifact *CIV3BuildArtifact) Convert2DTO() *apistructs.BuildArtifact

func (*CIV3BuildArtifact) TableName

func (*CIV3BuildArtifact) TableName() string

type CIV3BuildCache

type CIV3BuildCache struct {
	ID          int64     `json:"id" xorm:"pk autoincr"`
	Name        string    `json:"name"`
	ClusterName string    `json:"clusterName"`
	LastPullAt  time.Time `json:"lastPullAt"`
	CreatedAt   time.Time `json:"createdAt" xorm:"created"`
	UpdatedAt   time.Time `json:"updatedAt" xorm:"updated"`
	DeletedAt   time.Time `xorm:"deleted"`
}

func (*CIV3BuildCache) TableName

func (*CIV3BuildCache) TableName() string

type FlinkSparkConf

type FlinkSparkConf struct {
	// 该部分在 action 的 source 里声明
	Depend    string   `json:"depends,omitempty"`
	MainClass string   `json:"main_class,omitempty"`
	MainArgs  []string `json:"main_args,omitempty"`

	// flink/spark action 运行需要一个 jar resource(flink 为 jarID,spark 为 jarURL)
	// 该部分在运行期动态赋值
	JarResource string `json:"jarResource,omitempty"`
}

type Pipeline

type Pipeline struct {
	PipelineBase
	PipelineExtra
	Labels map[string]string
}

Pipeline

func (*Pipeline) DecodeV1UniquePipelineYmlName

func (p *Pipeline) DecodeV1UniquePipelineYmlName(name string) string

DecodeV1UniquePipelineYmlName 根据 GenerateV1UniquePipelineYmlName 生成规则,反解析得到 originName

func (*Pipeline) EnsureGC

func (p *Pipeline) EnsureGC()

EnsureGC without nil field

func (*Pipeline) GenIdentityInfo

func (p *Pipeline) GenIdentityInfo() apistructs.IdentityInfo

func (*Pipeline) GenerateNormalLabelsForCreateV2

func (p *Pipeline) GenerateNormalLabelsForCreateV2() map[string]string

GenerateNormalLabelsForCreateV2 pipeline.createV2 有一些字段通过标签来传递,例如 commit

func (*Pipeline) GenerateV1UniquePipelineYmlName

func (p *Pipeline) GenerateV1UniquePipelineYmlName(originPipelineYmlPath string) string

GenerateV1UniquePipelineYmlName 为 v1 pipeline 返回 pipelineYmlName,该 name 在 source 下唯一 生成规则: AppID/DiceWorkspace/Branch/PipelineYmlPath 1) 100/PROD/master/ec/dws/itm/workflow/item_1d_df_process.workflow 2) 200/DEV/feature/dice/pipeline.yml

func (*Pipeline) GetCancelUserID

func (p *Pipeline) GetCancelUserID() string

func (*Pipeline) GetConfigManageNamespaces

func (p *Pipeline) GetConfigManageNamespaces() []string

func (*Pipeline) GetLabel

func (p *Pipeline) GetLabel(labelKey string) string

func (*Pipeline) GetPipelineAppliedResources

func (p *Pipeline) GetPipelineAppliedResources() apistructs.PipelineAppliedResources

GetPipelineAppliedResources return limited and min resource when pipeline run.

func (*Pipeline) GetPipelineQueueID

func (p *Pipeline) GetPipelineQueueID() (uint64, bool)

GetPipelineQueueID return pipeline queue id if exist, or 0.

func (*Pipeline) GetResourceGCTTL

func (p *Pipeline) GetResourceGCTTL() uint64

func (*Pipeline) GetRunUserID

func (p *Pipeline) GetRunUserID() string

func (*Pipeline) GetSubmitUserID

func (p *Pipeline) GetSubmitUserID() string

func (*Pipeline) MergeLabels

func (p *Pipeline) MergeLabels() map[string]string

type PipelineArchive

type PipelineArchive struct {
	ID          uint64    `json:"id" xorm:"pk autoincr"`
	TimeCreated time.Time `json:"timeCreated" xorm:"created"`
	TimeUpdated time.Time `json:"timeUpdated" xorm:"updated"`

	PipelineID      uint64                    `json:"pipelineID"`
	PipelineSource  apistructs.PipelineSource `json:"pipelineSource"`
	PipelineYmlName string                    `json:"pipelineYmlName"`
	Status          apistructs.PipelineStatus `json:"status"`

	// DiceVersion record the dice version when archived,
	// it will impact `content` field unmarshal method
	DiceVersion string                 `json:"diceVersion"`
	Content     PipelineArchiveContent `json:"content" xorm:"json"`
}

PipelineArchive pipeline 归档表

func (*PipelineArchive) TableName

func (*PipelineArchive) TableName() string

type PipelineArchiveContent

type PipelineArchiveContent struct {
	Pipeline        Pipeline         `json:"pipeline"`
	PipelineLabels  []PipelineLabel  `json:"pipelineLabels"`
	PipelineStages  []PipelineStage  `json:"pipelineStages"`
	PipelineTasks   []PipelineTask   `json:"pipelineTasks"`
	PipelineReports []PipelineReport `json:"pipelineReports"`
}

PipelineArchiveContent contains: - pipelines - pipeline_labels - pipeline_stages - pipeline_tasks

type PipelineBase

type PipelineBase struct {
	ID uint64 `json:"id" xorm:"pk autoincr"`

	PipelineSource  apistructs.PipelineSource `json:"pipelineSource"`
	PipelineYmlName string                    `json:"pipelineYmlName"`

	ClusterName string `json:"clusterName,omitempty"`

	Status apistructs.PipelineStatus `json:"status,omitempty"`

	Type        apistructs.PipelineType        `json:"type,omitempty"`
	TriggerMode apistructs.PipelineTriggerMode `json:"triggerMode,omitempty"`

	// 定时相关信息
	// +optional
	CronID *uint64 `json:"cronID,omitempty"`

	// Snippet
	IsSnippet        bool    `json:"isSnippet"`
	ParentPipelineID *uint64 `json:"parentPipelineID,omitempty"`
	ParentTaskID     *uint64 `json:"parentTaskID,omitempty"`

	// CostTimeSec 总耗时(秒)
	CostTimeSec int64 `json:"costTimeSec,omitempty"` // pipeline 总耗时/秒
	// TimeBegin 执行开始时间
	TimeBegin *time.Time `json:"timeBegin,omitempty"` // 执行开始时间
	// TimeEnd 执行结束时间
	TimeEnd *time.Time `json:"timeEnd,omitempty"` // 执行结束时间

	TimeCreated *time.Time `json:"timeCreated,omitempty" xorm:"created"`
	TimeUpdated *time.Time `json:"timeUpdated,omitempty" xorm:"updated"`
}

PipelineBase represents `pipeline_bases` table.

func (*PipelineBase) TableName

func (*PipelineBase) TableName() string

type PipelineCmsConfig

type PipelineCmsConfig struct {
	ID uint64 `json:"id" xorm:"pk autoincr"`

	NsID uint64 `json:"nsID"`

	Key   string `json:"key"`
	Value string `json:"value"`

	Encrypt *bool `json:"encrypt"`

	Type apistructs.PipelineCmsConfigType `json:"type"`

	Extra PipelineCmsConfigExtra `json:"extra" xorm:"json"`

	TimeCreated *time.Time `json:"timeCreated,omitempty" xorm:"created"`
	TimeUpdated *time.Time `json:"timeUpdated,omitempty" xorm:"updated"`
}

PipelineCmsConfig 配置管理命名空间下的具体配置

func (PipelineCmsConfig) BeforeSet

func (c PipelineCmsConfig) BeforeSet(fieldName string, cell xorm.Cell)

BeforeSet is invoked before FromDB order: get value from db -> invoke BeforeSet -> invoke FromDB -> struct

func (PipelineCmsConfig) Equal

func (c PipelineCmsConfig) Equal(another PipelineCmsConfig) bool

func (PipelineCmsConfig) TableName

func (PipelineCmsConfig) TableName() string

type PipelineCmsConfigExtra

type PipelineCmsConfigExtra struct {
	// Operations 从数据库取出时保证不为 nil
	Operations *apistructs.PipelineCmsConfigOperations `json:"operations"`
	// Comment 注释
	Comment string `json:"comment"`
	// From 配置项来源,可为空。例如:证书管理同步
	From string `json:"from"`
}

func (*PipelineCmsConfigExtra) FromDB

func (extra *PipelineCmsConfigExtra) FromDB(b []byte) error

FromDB 处理 operations 默认值,老数据无需通过 dbmigration 赋值

func (*PipelineCmsConfigExtra) ToDB

func (extra *PipelineCmsConfigExtra) ToDB() ([]byte, error)

ToDB 为 operations 赋默认值

type PipelineCmsNs

type PipelineCmsNs struct {
	ID uint64 `json:"id" xorm:"pk autoincr"`

	PipelineSource apistructs.PipelineSource `json:"pipelineSource"`

	Ns string `json:"ns"`

	TimeCreated *time.Time `json:"timeCreated,omitempty" xorm:"created"`
	TimeUpdated *time.Time `json:"timeUpdated,omitempty" xorm:"updated"`
}

PipelineCmsNs 配置管理命名空间

func (PipelineCmsNs) TableName

func (PipelineCmsNs) TableName() string

type PipelineCombosReq

type PipelineCombosReq struct {
	Branches []string `json:"branches"`
	Sources  []string `json:"sources"`
	YmlNames []string `json:"ymlNames"`
}

type PipelineConfig

type PipelineConfig struct {
	ID    uint64             `json:"id" xorm:"pk autoincr"`
	Type  PipelineConfigType `json:"type"`
	Value interface{}        `json:"value" xorm:"json"`
}

func (PipelineConfig) TableName

func (PipelineConfig) TableName() string

type PipelineConfigType

type PipelineConfigType string
var (
	PipelineConfigTypeActionExecutor PipelineConfigType = "action_executor"
)

type PipelineCron

type PipelineCron struct {
	ID          uint64    `json:"id" xorm:"pk autoincr"`
	TimeCreated time.Time `json:"timeCreated" xorm:"created"` // 记录创建时间
	TimeUpdated time.Time `json:"timeUpdated" xorm:"updated"` // 记录更新时间

	PipelineSource  apistructs.PipelineSource `json:"pipelineSource"`
	PipelineYmlName string                    `json:"pipelineYmlName"`

	CronExpr string `json:"cronExpr"`
	//PipelineSource  string            `json:"pipelineSource"`
	Enable *bool             `json:"enable"` // 1 true, 0 false
	Extra  PipelineCronExtra `json:"extra,omitempty" xorm:"json"`

	// Deprecated
	ApplicationID uint64 `json:"applicationID" xorm:"application_id"`
	// Deprecated
	Branch string `json:"branch"`
	// Deprecated
	BasePipelineID uint64 `json:"basePipelineID"` // 用于记录最开始创建出这条 cron 记录的 pipeline id
}

func (*PipelineCron) Convert2DTO

func (pc *PipelineCron) Convert2DTO() *apistructs.PipelineCronDTO

func (*PipelineCron) GetAppID

func (pc *PipelineCron) GetAppID() uint64

GetAppID 返回 AppID,若为 0 则表示不存在 优先级如下: 1. pc.AppID 2. pc.Extra.Labels["AppID"]

func (*PipelineCron) GetBranch

func (pc *PipelineCron) GetBranch() string

GetBranch 返回 Branch, "" 则表示不存在 优先级如下: 1. pc.Branch 2. pc.Extra.Labels["Branch"]

func (PipelineCron) TableName

func (PipelineCron) TableName() string

type PipelineCronExtra

type PipelineCronExtra struct {
	PipelineYml            string            `json:"pipelineYml"`
	ClusterName            string            `json:"clusterName"`
	FilterLabels           map[string]string `json:"labels"`
	NormalLabels           map[string]string `json:"normalLabels"` // userID 存储提交流水线的用户 ID
	Envs                   map[string]string `json:"envs"`
	ConfigManageNamespaces []string          `json:"configManageNamespaces,omitempty"`
	CronStartFrom          *time.Time        `json:"cronStartFrom,omitempty"`
	// 新版为 v2
	Version string `json:"version"`

	// compensate
	// Compensator 老的 cron 为空,经过补偿后会自动赋值默认配置;新创建的 cron 一定会有值。
	Compensator *apistructs.CronCompensator `json:"compensator,omitempty"`
	//每次中断补偿执行的时间,下次中断补偿从这个时间开始查询
	LastCompensateAt *time.Time `json:"lastCompensateAt,omitempty"`
}

PipelineCronExtra cron 扩展信息, 不参与过滤

type PipelineExtra

type PipelineExtra struct {
	PipelineID uint64 `json:"pipelineID,omitempty" xorm:"pk 'pipeline_id'"`

	// PipelineYml 流水线定义文件
	PipelineYml string `json:"pipelineYml"`

	// Extra 额外信息
	Extra PipelineExtraInfo `json:"extra" xorm:"json"`

	// NormalLabels 普通标签,仅展示,不可过滤
	NormalLabels map[string]string `json:"normalLabels" xorm:"json"`

	// Snapshot 运行时的快照
	Snapshot Snapshot `json:"snapshot" xorm:"json"`

	// CommitDetail 提交详情
	CommitDetail apistructs.CommitDetail `json:"commitDetail" xorm:"json"`

	// Progress 流水线整体执行进度,0-100
	// -1 表示未设置
	// progress 只存最终结果,若 >= 0,直接返回,无需再计算
	Progress int `json:"progress"`

	ExtraTimeCreated *time.Time `json:"timeCreated,omitempty" xorm:"created 'time_created'"`
	ExtraTimeUpdated *time.Time `json:"timeUpdated,omitempty" xorm:"updated 'time_updated'"`

	// 以下为冗余字段,因为使用 sql 迁移时,无法将 应用相关字段 迁移到 labels 中,所以要先做冗余
	// 新建的流水线,不会插入以下字段
	Commit  string `json:"commit"`
	OrgName string `json:"orgName"`

	Snippets []pipelineyml.SnippetPipelineYmlCache `json:"snippets" xorm:"snippets"`
}

PipelineExtra represents `pipeline_extras` table. `pipeline_extras` 与 `pipeline_bases` 一一对应

func (*PipelineExtra) GetCommitID

func (extra *PipelineExtra) GetCommitID() string

func (*PipelineExtra) GetOrgName

func (extra *PipelineExtra) GetOrgName() string

func (*PipelineExtra) TableName

func (*PipelineExtra) TableName() string

type PipelineExtraInfo

type PipelineExtraInfo struct {
	Namespace         string                       `json:"namespace"`
	DiceWorkspace     apistructs.DiceWorkspace     `json:"diceWorkspace,omitempty"`
	PipelineYmlSource apistructs.PipelineYmlSource `json:"pipelineYmlSource,omitempty"`
	SubmitUser        *apistructs.PipelineUser     `json:"submitUser,omitempty"`
	RunUser           *apistructs.PipelineUser     `json:"runUser,omitempty"`
	CancelUser        *apistructs.PipelineUser     `json:"cancelUser,omitempty"`
	InternalClient    string                       `json:"internalClient,omitempty"`
	CronExpr          string                       `json:"cronExpr,omitempty"`
	CronTriggerTime   *time.Time                   `json:"cronTriggerTime,omitempty"` // 秒级精确,毫秒级误差请忽略,cron expr 精确度同样为秒级
	ShowMessage       *apistructs.ShowMessage      `json:"showMessage,omitempty"`
	Messages          []string                     `json:"errors,omitempty"` // TODO ShowMessage 和 Message
	// Deprecated
	ConfigManageNamespaceOfSecretsDefault string `json:"configManageNamespaceOfSecretsDefault,omitempty"`
	// Deprecated
	ConfigManageNamespaceOfSecrets string   `json:"configManageNamespaceOfSecrets,omitempty"`
	ConfigManageNamespaces         []string `json:"configManageNamespaces,omitempty"`

	CopyFromPipelineID *uint64            `json:"copyFromPipelineID,omitempty"` // 是否是从其他节点拷贝过来
	RerunFailedDetail  *RerunFailedDetail `json:"rerunFailedDetail,omitempty"`

	IsAutoRun      bool                     `json:"isAutoRun,omitempty"` // 创建后是否自动开始执行
	ShareVolumeID  string                   `json:"shareVolumeId,omitempty"`
	TaskWorkspaces []string                 `json:"taskWorkspaces,omitempty"` //工作目录,例如git
	StorageConfig  apistructs.StorageConfig `json:"storageConfig,omitempty"`  // 挂载设置

	CallbackURLs []string `json:"callbackURLs,omitempty"`

	Version string `json:"version,omitempty"` // 1.1, 1.0

	// 是否已经 完成 Reconciler GC
	CompleteReconcilerGC bool `json:"completeReconcilerGC"`

	// 是否已完成 Reconcile teardown
	CompleteReconcilerTeardown bool `json:"completeReconcilerTeardown"`

	// 用于保存自动转换前的 v1 pipelineYmlName(通过 V1 API 创建的流水线,通过该参数调用 gittar 获取内容)
	PipelineYmlNameV1 string `json:"pipelineYmlNameV1,omitempty"`

	// pipeline 运行时的输入参数
	RunPipelineParams []apistructs.PipelineRunParam `json:"runPipelineParams,omitempty"`

	// GC
	GC apistructs.PipelineGC `json:"gc,omitempty"`

	// OutputDefines
	DefinedOutputs []apistructs.PipelineOutput `json:"definedOutputs,omitempty"`

	SnippetChain []uint64 `json:"snippetChain,omitempty"`

	QueueInfo *QueueInfo `json:"queueInfo,omitempty"`
}

type PipelineLabel

type PipelineLabel struct {
	ID uint64 `json:"id" xorm:"pk autoincr"`

	Type     apistructs.PipelineLabelType `json:"type,omitempty"`
	TargetID uint64                       `json:"targetID"`

	PipelineSource  apistructs.PipelineSource `json:"pipelineSource"`
	PipelineYmlName string                    `json:"pipelineYmlName"`

	Key   string `json:"key"`
	Value string `json:"value"`

	TimeCreated time.Time `json:"timeCreated" xorm:"created"`
	TimeUpdated time.Time `json:"timeUpdated" xorm:"updated"`
}

PipelineLabel 标签

func (PipelineLabel) TableName

func (p PipelineLabel) TableName() string

type PipelineOld

type PipelineOld struct {
	ID uint64 `json:"id,omitempty" xorm:"pk autoincr"`

	// 通过 source + pipelineYmlName 唯一定位
	Source apistructs.PipelineSource `json:"source,omitempty"`
	// 通过 v1 创建的 pipeline,自动生成唯一的 pipelineYmlName
	// 通过 v2 创建的 pipeline,由调用方保证
	PipelineYmlName string `json:"pipelineYmlName,omitempty"`
	PipelineYml     string `json:"pipelineYml,omitempty"`

	// 调度集群
	// +required
	ClusterName string `json:"clusterName,omitempty"`

	// 运行时相关信息
	Type        apistructs.PipelineType        `json:"type,omitempty"`
	TriggerMode apistructs.PipelineTriggerMode `json:"triggerMode,omitempty"`
	Snapshot    Snapshot                       `json:"snapshot,omitempty" xorm:"json"` // 快照
	Progress    float64                        `json:"progress,omitempty" xorm:"-"`    // pipeline 执行进度, eg: 0.8 表示 80%
	Status      apistructs.PipelineStatus      `json:"status,omitempty"`
	Extra       PipelineExtraInfo              `json:"extra,omitempty" xorm:"json"`

	// 时间
	CostTimeSec int64      `json:"costTimeSec,omitempty"`                // pipeline 总耗时/秒
	TimeBegin   *time.Time `json:"timeBegin,omitempty"`                  // 执行开始时间
	TimeEnd     *time.Time `json:"timeEnd,omitempty"`                    // 执行结束时间
	TimeCreated *time.Time `json:"timeCreated,omitempty" xorm:"created"` // 记录创建时间
	TimeUpdated *time.Time `json:"timeUpdated,omitempty" xorm:"updated"` // 记录更新时间

	// 定时相关信息
	// +optional
	CronID *uint64 `json:"cronID,omitempty"`

	// deprecated
	BasePipelineID uint64 `json:"basePipelineID,omitempty"` // 该字段用来分页展示时 group 分组,相同 BasePipelineID 的数据会被折叠成一条,通过执行记录来跳转

	// 应用相关信息
	// +optional
	OrgID           uint64 `json:"orgID,omitempty"`
	OrgName         string `json:"orgName,omitempty"` // tag schedule
	ProjectID       uint64 `json:"projectID,omitempty"`
	ProjectName     string `json:"projectName,omitempty"` // tag schedule
	ApplicationID   uint64 `json:"applicationID,omitempty"`
	ApplicationName string `json:"applicationName,omitempty"`

	// 分支相关信息
	// +optional
	PipelineYmlSource apistructs.PipelineYmlSource `json:"pipelineYmlSource,omitempty"` // yml 文件来源
	Branch            string                       `json:"branch,omitempty"`
	Commit            string                       `json:"commit,omitempty"`
	CommitDetail      apistructs.CommitDetail      `json:"commitDetail,omitempty" xorm:"json"`
}

PipelineOld

func (*PipelineOld) TableName

func (*PipelineOld) TableName() string

type PipelineReport

type PipelineReport struct {
	ID         uint64 `xorm:"pk autoincr"`
	PipelineID uint64
	Type       apistructs.PipelineReportType
	Meta       apistructs.PipelineReportMeta `xorm:"json"`
	CreatorID  string
	UpdaterID  string
	CreatedAt  time.Time `xorm:"created"`
	UpdatedAt  time.Time `xorm:"updated"`
}

PipelineBase represents `dice_pipeline_reports` table.

func (*PipelineReport) TableName

func (*PipelineReport) TableName() string

type PipelineStage

type PipelineStage struct {
	ID         uint64 `json:"id" xorm:"pk autoincr"`
	PipelineID uint64 `json:"pipelineID"`

	Name   string                    `json:"name"`
	Extra  PipelineStageExtra        `json:"extra" xorm:"json"`
	Status apistructs.PipelineStatus `json:"status"`

	CostTimeSec int64     `json:"costTimeSec"`
	TimeBegin   time.Time `json:"timeBegin"`                  // 执行开始时间
	TimeEnd     time.Time `json:"timeEnd"`                    // 执行结束时间
	TimeCreated time.Time `json:"timeCreated" xorm:"created"` // 记录创建时间
	TimeUpdated time.Time `json:"timeUpdated" xorm:"updated"` // 记录更新时间
}

func (*PipelineStage) Convert2DTO

func (ps *PipelineStage) Convert2DTO() *apistructs.PipelineStageDTO

func (*PipelineStage) TableName

func (ps *PipelineStage) TableName() string

type PipelineStageExtra

type PipelineStageExtra struct {
	PreStage   *PreStageSimple `json:"preStage,omitempty"`
	StageOrder int             `json:"stageOrder"` // 0,1,2,...
}

type PipelineStageWithTask

type PipelineStageWithTask struct {
	PipelineStage
	PipelineTasks []*PipelineTask
}

type PipelineTask

type PipelineTask struct {
	ID         uint64 `json:"id" xorm:"pk autoincr"`
	PipelineID uint64 `json:"pipelineID"`
	StageID    uint64 `json:"stageID"`

	Name         string                        `json:"name"`
	OpType       PipelineTaskOpType            `json:"opType"`         // Deprecated: get, put, task
	Type         string                        `json:"type,omitempty"` // git, buildpack, release, dice ... 当 OpType 为自定义任务时为空
	ExecutorKind PipelineTaskExecutorKind      `json:"executorKind"`   // scheduler, memory
	Status       apistructs.PipelineStatus     `json:"status"`
	Extra        PipelineTaskExtra             `json:"extra" xorm:"json"`
	Context      PipelineTaskContext           `json:"context" xorm:"json"`
	Result       apistructs.PipelineTaskResult `json:"result" xorm:"json"`

	IsSnippet             bool                                  `json:"isSnippet"`                         // 该节点是否是嵌套流水线节点
	SnippetPipelineID     *uint64                               `json:"snippetPipelineID"`                 // 嵌套的流水线 id
	SnippetPipelineDetail *apistructs.PipelineTaskSnippetDetail `json:"snippetPipelineDetail" xorm:"json"` // 嵌套的流水线详情

	CostTimeSec  int64     `json:"costTimeSec"`                // -1 表示暂无耗时信息, 0 表示确实是0s结束
	QueueTimeSec int64     `json:"queueTimeSec"`               // 等待调度的耗时, -1 暂无耗时信息, 0 表示确实是0s结束 TODO 赋值
	TimeBegin    time.Time `json:"timeBegin"`                  // 执行开始时间
	TimeEnd      time.Time `json:"timeEnd"`                    // 执行结束时间
	TimeCreated  time.Time `json:"timeCreated" xorm:"created"` // 记录创建时间
	TimeUpdated  time.Time `json:"timeUpdated" xorm:"updated"` // 记录更新时间
}

func (*PipelineTask) Convert2DTO

func (pt *PipelineTask) Convert2DTO() *apistructs.PipelineTaskDTO

func (*PipelineTask) NodeName

func (pt *PipelineTask) NodeName() string

func (*PipelineTask) PrevNodeNames

func (pt *PipelineTask) PrevNodeNames() []string

func (*PipelineTask) ReleaseID

func (pt *PipelineTask) ReleaseID() string

func (*PipelineTask) RuntimeID

func (pt *PipelineTask) RuntimeID() string

func (*PipelineTask) TableName

func (*PipelineTask) TableName() string

type PipelineTaskContext

type PipelineTaskContext struct {
	InStorages  apistructs.Metadata `json:"inStorages,omitempty"`
	OutStorages apistructs.Metadata `json:"outStorages,omitempty"`

	CmsDiceFiles apistructs.Metadata `json:"cmsDiceFiles,omitempty"`
}

func (*PipelineTaskContext) Dedup

func (c *PipelineTaskContext) Dedup()

type PipelineTaskExecutorKind

type PipelineTaskExecutorKind string
var (
	PipelineTaskExecutorKindScheduler PipelineTaskExecutorKind = "SCHEDULER"
	PipelineTaskExecutorKindMemory    PipelineTaskExecutorKind = "MEMORY"
	PipelineTaskExecutorKindAPITest   PipelineTaskExecutorKind = "APITEST"
)

type PipelineTaskExtra

type PipelineTaskExtra struct {
	Namespace    string            `json:"namespace,omitempty"`
	ExecutorName string            `json:"executorName,omitempty"`
	ClusterName  string            `json:"clusterName,omitempty"`
	AllowFailure bool              `json:"allowFailure,omitempty"`
	Pause        bool              `json:"pause,omitempty"`
	Timeout      time.Duration     `json:"timeout,omitempty"`
	PrivateEnvs  map[string]string `json:"envs,omitempty"`       // PrivateEnvs 由 agent 注入 run 运行时,run 可见,容器内不可见
	PublicEnvs   map[string]string `json:"publicEnvs,omitempty"` // PublicEnvs 注入容器,run 可见,容器内亦可见
	Labels       map[string]string `json:"labels,omitempty"`
	Image        string            `json:"image,omitempty"`
	Cmd          string            `json:"cmd,omitempty"`
	CmdArgs      []string          `json:"cmdArgs,omitempty"`
	Binds        []apistructs.Bind `json:"binds,omitempty"`
	// Volumes 创建 task 时的 volumes 快照
	// 若一开始 volume 无 volumeID,启动 task 后返回的 volumeID 不会在这里更新,只会更新到 task.Context.OutStorages 里
	Volumes         []apistructs.MetadataField `json:"volumes,omitempty"` //
	PreFetcher      *apistructs.PreFetcher     `json:"preFetcher,omitempty"`
	RuntimeResource RuntimeResource            `json:"runtimeResource,omitempty"`
	UUID            string                     `json:"uuid"` // 用于查询日志等,pipeline 开始执行时才会赋值 // 对接多个 executor,不一定每个 executor 都能自定义 UUID,所以这个 uuid 实际上是目标系统的 uuid
	TimeBeginQueue  time.Time                  `json:"timeBeginQueue"`
	TimeEndQueue    time.Time                  `json:"timeEndQueue"`
	StageOrder      int                        `json:"stageOrder"` // 0,1,2,...

	// RunAfter indicates the tasks this task depends.
	RunAfter []string `json:"runAfter"`

	FlinkSparkConf FlinkSparkConf `json:"flinkSparkConf,omitempty"`

	Action pipelineyml.Action `json:"action,omitempty"`

	OpenapiOAuth2TokenPayload apistructs.OpenapiOAuth2TokenPayload `json:"openapiOAuth2TokenPayload"`

	LoopOptions *apistructs.PipelineTaskLoopOptions `json:"loopOptions,omitempty"` // 开始执行后保证不为空

	AppliedResources apistructs.PipelineAppliedResources `json:"appliedResources,omitempty"`
}

type PipelineTaskOpType

type PipelineTaskOpType string

Operation

var (
	PipelineTaskOpTypeGet  PipelineTaskOpType = "get"
	PipelineTaskOpTypePut  PipelineTaskOpType = "put"
	PipelineTaskOpTypeTask PipelineTaskOpType = "task"
)

type PipelineWithStage

type PipelineWithStage struct {
	Pipeline
	PipelineStages []*PipelineStageWithTask
}

type PipelineWithTasks

type PipelineWithTasks struct {
	Pipeline *Pipeline
	Tasks    []*PipelineTask
}

func (*PipelineWithTasks) DoneTasks

func (p *PipelineWithTasks) DoneTasks() []string

type PreStageSimple

type PreStageSimple struct {
	ID     uint64                    `json:"id"`
	Status apistructs.PipelineStatus `json:"preStageStatus,omitempty"`
}

type QueueInfo

type QueueInfo struct {
	QueueID        uint64 `json:"queueID"`
	CustomPriority int64  `json:"customPriority"`
}

type RerunFailedDetail

type RerunFailedDetail struct {
	RerunPipelineID uint64            `json:"rerunPipelineID,omitempty"`
	StageIndex      int               `json:"stageIndex,omitempty"`
	SuccessTasks    map[string]uint64 `json:"successTasks,omitempty"`
	FailedTasks     map[string]uint64 `json:"failedTasks,omitempty"`
	NotExecuteTasks map[string]uint64 `json:"notExecuteTasks,omitempty"`
}

type RuntimeResource

type RuntimeResource struct {
	CPU    float64 `json:"cpu"`
	Memory float64 `json:"memory"`
	Disk   float64 `json:"disk"`
}

func GenDefaultTaskResource

func GenDefaultTaskResource() RuntimeResource

type Snapshot

type Snapshot struct {
	PipelineYml     string            `json:"pipeline_yml,omitempty"` // 对占位符进行渲染
	Secrets         map[string]string `json:"secrets,omitempty"`
	PlatformSecrets map[string]string `json:"platformSecrets,omitempty"`
	CmsDiceFiles    map[string]string `json:"cmsDiceFiles,omitempty"`
	Envs            map[string]string `json:"envs,omitempty"`

	AnalyzedCrossCluster *bool `json:"analyzedCrossCluster,omitempty"`

	RunPipelineParams apistructs.PipelineRunParamsWithValue `json:"runPipelineParams,omitempty"` // 流水线运行时参数

	// IdentityInfo 身份信息
	IdentityInfo apistructs.IdentityInfo `json:"identityInfo" xorm:"json"`

	// OutputValues output 定义和从 task 里采集上来的值
	OutputValues []apistructs.PipelineOutputWithValue `json:"outputValues,omitempty"`

	// AppliedResources calculated by all actions
	AppliedResources apistructs.PipelineAppliedResources `json:"appliedResources,omitempty"`

	// BindQueue stores the binding queue info if have.
	BindQueue *apistructs.PipelineQueue `json:"bindQueue,omitempty"`

	// Events stores pipeline level k8s-like events
	Events []*apistructs.PipelineEvent `json:"events,omitempty"`
}

func (*Snapshot) FromDB

func (s *Snapshot) FromDB(b []byte) error

FromDB 兼容 Snapshot 老数据

func (*Snapshot) ToDB

func (s *Snapshot) ToDB() ([]byte, error)

type StoreType

type StoreType string
var (
	StoreTypeOSS             StoreType = "OSS"
	StoreTypeNFS             StoreType = "NFS"
	StoreTypeDiceVolumeNFS   StoreType = "dice-nfs-volume"
	StoreTypeDiceVolumeLocal StoreType = "dice-local-volume"
	StoreTypeDiceVolumeFake  StoreType = "dice-fake-volume"
	StoreTypeDiceCacheNFS    StoreType = "dice-cache-nfs-volume"
)

type Volume

type Volume struct {
	HostPath      string `json:"hostPath"`
	ContainerPath string `json:"containerPath"`
	ReadOnly      bool   `json:"readOnly"`
}

Jump to

Keyboard shortcuts

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