dbclient

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2021 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrZeroAffectedRows = errors.New("affected rows was 0")
	ErrRecordNotFound   = errors.New("not found")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	*xorm.Engine
}

func New

func New() (*Client, error)

func (*Client) AppendPipelineEvent

func (client *Client) AppendPipelineEvent(pipelineID uint64, newEvents []*apistructs.PipelineEvent, ops ...SessionOption) error

func (*Client) ArchivePipeline

func (client *Client) ArchivePipeline(pipelineID uint64) (_ uint64, err error)

func (*Client) BatchInsertLabels added in v1.0.1

func (client *Client) BatchInsertLabels(labels []spec.PipelineLabel, ops ...SessionOption) (err error)

func (*Client) BatchListPipelineReportsByPipelineID

func (client *Client) BatchListPipelineReportsByPipelineID(pipelineIDs []uint64, types []string, ops ...SessionOption) (map[uint64][]spec.PipelineReport, error)

func (*Client) CheckExistPipelineCronByApplicationBranchYmlName

func (client *Client) CheckExistPipelineCronByApplicationBranchYmlName(applicationID uint64, branch string, pipelineYmlName string) (bool, spec.PipelineCron, error)

func (*Client) ConvertPipelineReport

func (client *Client) ConvertPipelineReport(dbReport spec.PipelineReport) apistructs.PipelineReport

func (*Client) CreatePipeline

func (client *Client) CreatePipeline(p *spec.Pipeline, ops ...SessionOption) error

CreatePipeline: base + extra + labels

func (*Client) CreatePipelineArchive

func (client *Client) CreatePipelineArchive(archive *spec.PipelineArchive, ops ...SessionOption) error

func (*Client) CreatePipelineBase

func (client *Client) CreatePipelineBase(base *spec.PipelineBase, ops ...SessionOption) error

func (*Client) CreatePipelineCron

func (client *Client) CreatePipelineCron(cron *spec.PipelineCron) error

func (*Client) CreatePipelineExtra

func (client *Client) CreatePipelineExtra(extra *spec.PipelineExtra, ops ...SessionOption) error

func (*Client) CreatePipelineLabels

func (client *Client) CreatePipelineLabels(p *spec.Pipeline, ops ...SessionOption) (err error)

func (*Client) CreatePipelineQueue

func (client *Client) CreatePipelineQueue(req apistructs.PipelineQueueCreateRequest, ops ...SessionOption) (*apistructs.PipelineQueue, error)

CreatePipelineQueue

func (*Client) CreatePipelineReport

func (client *Client) CreatePipelineReport(report *spec.PipelineReport, ops ...SessionOption) error

func (*Client) CreatePipelineStage

func (client *Client) CreatePipelineStage(ps *spec.PipelineStage, ops ...SessionOption) (err error)

func (*Client) CreatePipelineTask

func (client *Client) CreatePipelineTask(pt *spec.PipelineTask, ops ...SessionOption) (err error)

func (*Client) DeleteArtifact

func (client *Client) DeleteArtifact(id int64) error

func (*Client) DeleteArtifactsByImages

func (client *Client) DeleteArtifactsByImages(_type apistructs.BuildArtifactType, images []string) error

func (*Client) DeleteBuildCache

func (client *Client) DeleteBuildCache(id interface{}) (err error)

func (*Client) DeleteCmsNsConfigs

func (client *Client) DeleteCmsNsConfigs(cmsNs spec.PipelineCmsNs, keys []string, ops ...SessionOption) error

func (*Client) DeletePipeline

func (client *Client) DeletePipeline(id uint64, ops ...SessionOption) error

func (*Client) DeletePipelineCron

func (client *Client) DeletePipelineCron(id interface{}) error

func (*Client) DeletePipelineLabelsByPipelineID

func (client *Client) DeletePipelineLabelsByPipelineID(pipelineID uint64, ops ...SessionOption) error

func (*Client) DeletePipelineQueue

func (client *Client) DeletePipelineQueue(queueID uint64, ops ...SessionOption) error

DeletePipelineQueue

func (*Client) DeletePipelineRelated

func (client *Client) DeletePipelineRelated(pipelineID uint64, ops ...SessionOption) error

func (*Client) DeletePipelineReportsByPipelineID

func (client *Client) DeletePipelineReportsByPipelineID(pipelineID uint64, ops ...SessionOption) error

func (*Client) DeletePipelineStagesByPipelineID

func (client *Client) DeletePipelineStagesByPipelineID(pipelineID uint64, ops ...SessionOption) error

func (*Client) DeletePipelineTasksByPipelineID

func (client *Client) DeletePipelineTasksByPipelineID(pipelineID uint64, ops ...SessionOption) error

func (*Client) DisablePipelineCron

func (client *Client) DisablePipelineCron(new_ *spec.PipelineCron) error

更新cron的enable = false,cronExpr = new_.CronExpr

func (*Client) FindCauseFailedPipelineTasks

func (client *Client) FindCauseFailedPipelineTasks(pipelineID uint64) (spec.RerunFailedDetail, error)

FindCauseFailedPipelineTasks 寻找导致失败的节点

func (*Client) FindLifecycleHookClientList

func (client *Client) FindLifecycleHookClientList() (clients []*PipelineLifecycleHookClient, err error)

func (*Client) FindPipelineTaskByName

func (client *Client) FindPipelineTaskByName(pipelineID uint64, name string) (spec.PipelineTask, error)

func (*Client) FindSnippetClientList

func (client *Client) FindSnippetClientList() (clients []*DicePipelineSnippetClient, err error)

func (*Client) GetBuildArtifactBySha256

func (client *Client) GetBuildArtifactBySha256(sha256 string) (artifact spec.CIV3BuildArtifact, err error)

func (*Client) GetBuildCache

func (client *Client) GetBuildCache(clusterName, imageName string) (cache spec.CIV3BuildCache, err error)

func (*Client) GetCmsNs

func (client *Client) GetCmsNs(pipelineSource apistructs.PipelineSource, ns string, ops ...SessionOption) (spec.PipelineCmsNs, bool, error)

func (*Client) GetCmsNsConfigs

func (client *Client) GetCmsNsConfigs(cmsNs spec.PipelineCmsNs, keys []string, ops ...SessionOption) ([]spec.PipelineCmsConfig, error)

func (*Client) GetLabel

func (client *Client) GetLabel(id uint64) (label *spec.PipelineLabel, err error)

func (*Client) GetPipeline

func (client *Client) GetPipeline(id interface{}, ops ...SessionOption) (spec.Pipeline, error)

GetPipeline: base + extra + labels

func (*Client) GetPipelineArchiveByPipelineID

func (client *Client) GetPipelineArchiveByPipelineID(pipelineID uint64, ops ...SessionOption) (spec.PipelineArchive, bool, error)

func (*Client) GetPipelineBase

func (client *Client) GetPipelineBase(id uint64, ops ...SessionOption) (spec.PipelineBase, bool, error)

func (*Client) GetPipelineCron

func (client *Client) GetPipelineCron(id interface{}) (cron spec.PipelineCron, err error)

func (*Client) GetPipelineEvents

func (client *Client) GetPipelineEvents(pipelineID uint64, ops ...SessionOption) (*spec.PipelineReport, []*apistructs.PipelineEvent, error)

GetPipelineEvents get pipeline events from reports. return: report, events, error

func (*Client) GetPipelineExtraByPipelineID

func (client *Client) GetPipelineExtraByPipelineID(pipelineID uint64, ops ...SessionOption) (spec.PipelineExtra, bool, error)

func (*Client) GetPipelineFromArchive

func (client *Client) GetPipelineFromArchive(pipelineID uint64, ops ...SessionOption) (spec.Pipeline, bool, error)

func (*Client) GetPipelineIncludeArchive

func (client *Client) GetPipelineIncludeArchive(pipelineID uint64, ops ...SessionOption) (spec.Pipeline, bool, bool, error)

return: pipeline, exist, findFromArchive, error

func (*Client) GetPipelineOutputs

func (client *Client) GetPipelineOutputs(pipelineID uint64) (map[string]map[string]string, error)

GetPipelineOutputs 返回 pipeline 下所有 task 的 output

func (*Client) GetPipelineQueue

func (client *Client) GetPipelineQueue(queueID uint64, ops ...SessionOption) (*apistructs.PipelineQueue, bool, error)

GetPipelineQueue

func (*Client) GetPipelineStage

func (client *Client) GetPipelineStage(id interface{}, ops ...SessionOption) (spec.PipelineStage, error)

func (*Client) GetPipelineStageWithPreStatus

func (client *Client) GetPipelineStageWithPreStatus(id interface{}, ops ...SessionOption) (spec.PipelineStage, error)

func (*Client) GetPipelineStatus

func (client *Client) GetPipelineStatus(id uint64, ops ...SessionOption) (apistructs.PipelineStatus, error)

func (*Client) GetPipelineTask

func (client *Client) GetPipelineTask(id interface{}) (spec.PipelineTask, error)

func (*Client) GetPipelineTasksFromArchive

func (client *Client) GetPipelineTasksFromArchive(pipelineID uint64, ops ...SessionOption) ([]spec.PipelineTask, error)

func (*Client) GetPipelineTasksIncludeArchive

func (client *Client) GetPipelineTasksIncludeArchive(pipelineID uint64, ops ...SessionOption) ([]spec.PipelineTask, bool, error)

return: tasks, findFromArchive, error

func (*Client) GetPipelineWithExistInfo

func (client *Client) GetPipelineWithExistInfo(id interface{}, ops ...SessionOption) (spec.Pipeline, bool, error)

GetPipelineWithExistInfo 当 id 对应的流水线记录不存在时,error = nil, found = false

func (*Client) GetPipelineWithTasks

func (client *Client) GetPipelineWithTasks(id uint64) (*spec.PipelineWithTasks, error)

GetPipelineWithTasks

func (*Client) IdempotentCreateCmsNs

func (client *Client) IdempotentCreateCmsNs(pipelineSource apistructs.PipelineSource, ns string, ops ...SessionOption) (spec.PipelineCmsNs, error)

func (*Client) IdempotentDeleteCmsNs

func (client *Client) IdempotentDeleteCmsNs(pipelineSource apistructs.PipelineSource, ns string, ops ...SessionOption) error

func (*Client) InsertOrUpdateCmsNsConfig

func (client *Client) InsertOrUpdateCmsNsConfig(cmsNs spec.PipelineCmsNs, config spec.PipelineCmsConfig, ops ...SessionOption) error

func (*Client) InsertOrUpdatePipelineCron

func (client *Client) InsertOrUpdatePipelineCron(new_ *spec.PipelineCron) error

func (*Client) ListAllPipelineCrons

func (client *Client) ListAllPipelineCrons() (crons []spec.PipelineCron, err error)

func (*Client) ListLabelsByPipelineID

func (client *Client) ListLabelsByPipelineID(pipelineID uint64, ops ...SessionOption) ([]spec.PipelineLabel, error)

ListLabelsByPipelineID 根据 pipelineID 获取 labels

func (*Client) ListPipelineBasesByIDs

func (client *Client) ListPipelineBasesByIDs(pipelineIDs []uint64, ops ...SessionOption) (map[uint64]spec.PipelineBase, error)

func (*Client) ListPipelineConfigsOfActionExecutor

func (client *Client) ListPipelineConfigsOfActionExecutor() (configs []spec.PipelineConfig, cfgChan chan spec.ActionExecutorConfig, err error)

func (*Client) ListPipelineCrons

func (client *Client) ListPipelineCrons(enable *bool, ops ...SessionOption) ([]spec.PipelineCron, error)

func (*Client) ListPipelineCronsByApplicationID

func (client *Client) ListPipelineCronsByApplicationID(applicationID uint64) (crons []spec.PipelineCron, err error)

func (*Client) ListPipelineExtrasByPipelineIDs

func (client *Client) ListPipelineExtrasByPipelineIDs(pipelineIDs []uint64, ops ...SessionOption) (map[uint64]spec.PipelineExtra, error)

func (*Client) ListPipelineIDsByStatuses

func (client *Client) ListPipelineIDsByStatuses(status ...apistructs.PipelineStatus) ([]uint64, error)

ListPipelineIDsByStatuses

func (*Client) ListPipelineLabels added in v1.0.1

func (client *Client) ListPipelineLabels(req *apistructs.PipelineLabelListRequest, ops ...SessionOption) ([]spec.PipelineLabel, int64, error)

func (*Client) ListPipelineLabelsByTypeAndTargetIDs

func (client *Client) ListPipelineLabelsByTypeAndTargetIDs(_type apistructs.PipelineLabelType, targetIDs []uint64, ops ...SessionOption) (map[uint64][]spec.PipelineLabel, error)

func (*Client) ListPipelineSources

func (client *Client) ListPipelineSources() ([]apistructs.PipelineSource, error)

func (*Client) ListPipelineStageByPipelineID

func (client *Client) ListPipelineStageByPipelineID(pipelineID uint64, ops ...SessionOption) ([]spec.PipelineStage, error)

func (*Client) ListPipelineStageByStatuses

func (client *Client) ListPipelineStageByStatuses(statuses ...apistructs.PipelineStatus) ([]spec.PipelineStage, error)

func (*Client) ListPipelineTasksByPipelineID

func (client *Client) ListPipelineTasksByPipelineID(pipelineID uint64, ops ...SessionOption) ([]spec.PipelineTask, error)

func (*Client) ListPipelineTasksByStageID

func (client *Client) ListPipelineTasksByStageID(stageID uint64) ([]*spec.PipelineTask, error)

func (*Client) ListPipelineTasksByTypeStatuses

func (client *Client) ListPipelineTasksByTypeStatuses(typ string, statuses ...apistructs.PipelineStatus) ([]spec.PipelineTask, error)

func (*Client) ListPipelinesByIDs

func (client *Client) ListPipelinesByIDs(pipelineIDs []uint64, ops ...SessionOption) ([]spec.Pipeline, error)

func (*Client) MakePipelineReportTypeLabelKey

func (client *Client) MakePipelineReportTypeLabelKey(typ apistructs.PipelineReportType) (string, string)

func (*Client) NewArtifact

func (client *Client) NewArtifact(sha, identityText string, t apistructs.BuildArtifactType, content string, clusterName string, pipelineID uint64) (spec.CIV3BuildArtifact, error)

func (*Client) NewSession

func (client *Client) NewSession(ops ...SessionOption) *Session

func (*Client) PageListPipelines

func (client *Client) PageListPipelines(req apistructs.PipelinePageListRequest, ops ...SessionOption) ([]spec.Pipeline, []uint64, int64, int64, error)

return: pagingPipelines, pagingPipelineIDs, total, currentPageSize, error

func (*Client) PagingPipelineCron

func (client *Client) PagingPipelineCron(req apistructs.PipelineCronPagingRequest) ([]spec.PipelineCron, int64, error)

return: result, total, nil

func (*Client) PagingPipelineQueues

func (*Client) PagingPipelineReportSets

func (client *Client) PagingPipelineReportSets(req apistructs.PipelineReportSetPagingRequest, ops ...SessionOption) ([]apistructs.PipelineReportSet, int, error)

func (*Client) ParseRerunFailedDetail

func (client *Client) ParseRerunFailedDetail(detail *spec.RerunFailedDetail) (
	map[string]*spec.PipelineTask, map[string]*spec.PipelineTask, error)

func (*Client) PipelineStatistic

func (client *Client) PipelineStatistic(source, clusterName string) (*apistructs.PipelineStatisticResponseData, error)

PipelineStatistic pipeline 执行情况统计

func (*Client) PrefixListNs

func (client *Client) PrefixListNs(pipelineSource apistructs.PipelineSource, nsPrefix string, ops ...SessionOption) ([]spec.PipelineCmsNs, error)

func (*Client) RefreshPipeline

func (client *Client) RefreshPipeline(p *spec.Pipeline) error

RefreshPipeline 更新 pipeline

func (*Client) RefreshPipelineTask

func (client *Client) RefreshPipelineTask(task *spec.PipelineTask) error

func (*Client) SelectTargetIDsByLabels

func (client *Client) SelectTargetIDsByLabels(req apistructs.TargetIDSelectByLabelRequest, ops ...SessionOption) (targetIDs []uint64, err error)

func (*Client) StoreAnalyzedCrossCluster

func (client *Client) StoreAnalyzedCrossCluster(pipelineID uint64, analyzedCrossCluster bool, ops ...SessionOption) error

func (*Client) UpdateCmsNsConfigs

func (client *Client) UpdateCmsNsConfigs(cmsNs spec.PipelineCmsNs, configs []spec.PipelineCmsConfig, ops ...SessionOption) error

func (*Client) UpdatePipelineBase

func (client *Client) UpdatePipelineBase(id uint64, base *spec.PipelineBase, ops ...SessionOption) error

func (*Client) UpdatePipelineBaseStatus

func (client *Client) UpdatePipelineBaseStatus(id uint64, status apistructs.PipelineStatus, ops ...SessionOption) error

func (*Client) UpdatePipelineCron

func (client *Client) UpdatePipelineCron(id interface{}, cron *spec.PipelineCron) error

func (*Client) UpdatePipelineCronWillUseDefault

func (client *Client) UpdatePipelineCronWillUseDefault(id interface{}, cron *spec.PipelineCron, columns []string) error

更新cron,但是假如传入的cron有默认值,那么数据库会被更新成默认值

func (*Client) UpdatePipelineExtraByPipelineID

func (client *Client) UpdatePipelineExtraByPipelineID(pipelineID uint64, extra *spec.PipelineExtra, ops ...SessionOption) error

func (*Client) UpdatePipelineExtraExtraInfoByPipelineID

func (client *Client) UpdatePipelineExtraExtraInfoByPipelineID(pipelineID uint64, extraInfo spec.PipelineExtraInfo, ops ...SessionOption) error

func (*Client) UpdatePipelineExtraSnapshot

func (client *Client) UpdatePipelineExtraSnapshot(pipelineID uint64, snapshot spec.Snapshot, ops ...SessionOption) error

func (*Client) UpdatePipelineProgress

func (client *Client) UpdatePipelineProgress(pipelineID uint64, progress int, ops ...SessionOption) error

func (*Client) UpdatePipelineQueue

func (client *Client) UpdatePipelineQueue(req apistructs.PipelineQueueUpdateRequest, ops ...SessionOption) (*apistructs.PipelineQueue, error)

UpdatePipelineQueue

func (*Client) UpdatePipelineReport

func (client *Client) UpdatePipelineReport(report *spec.PipelineReport, ops ...SessionOption) error

func (*Client) UpdatePipelineShowMessage

func (client *Client) UpdatePipelineShowMessage(pipelineID uint64, showMessage apistructs.ShowMessage, ops ...SessionOption) error

UpdatePipelineShowMessage 更新 extra.ExtraInfo.ShowMessage

func (*Client) UpdatePipelineStage

func (client *Client) UpdatePipelineStage(id interface{}, stage *spec.PipelineStage) error

func (*Client) UpdatePipelineTask

func (client *Client) UpdatePipelineTask(id uint64, task *spec.PipelineTask, ops ...SessionOption) error

func (*Client) UpdatePipelineTaskContext

func (client *Client) UpdatePipelineTaskContext(id uint64, ctx spec.PipelineTaskContext, ops ...SessionOption) error

func (*Client) UpdatePipelineTaskExtra

func (client *Client) UpdatePipelineTaskExtra(id uint64, extra spec.PipelineTaskExtra, ops ...SessionOption) error

func (*Client) UpdatePipelineTaskResult

func (client *Client) UpdatePipelineTaskResult(id uint64, result apistructs.PipelineTaskResult) error

func (*Client) UpdatePipelineTaskSnippetDetail

func (client *Client) UpdatePipelineTaskSnippetDetail(id uint64, snippetDetail apistructs.PipelineTaskSnippetDetail, ops ...SessionOption) error

UpdatePipelineTaskSnippetDetail 更新 snippet task 的 snippet 信息

func (*Client) UpdatePipelineTaskStatus

func (client *Client) UpdatePipelineTaskStatus(id uint64, status apistructs.PipelineStatus, ops ...SessionOption) error

func (*Client) UpdateWholeStatusBorn

func (client *Client) UpdateWholeStatusBorn(pipelineID uint64, ops ...SessionOption) (err error)

UpdateWholeStatusBorn 状态更新顺序:task -> stage -> pipeline

func (*Client) UpdateWholeStatusCancel

func (client *Client) UpdateWholeStatusCancel(p *spec.Pipeline, ops ...SessionOption) (err error)

UpdateWholeStatusCancel 状态更新顺序:task -> stage -> pipeline

type DicePipelineSnippetClient

type DicePipelineSnippetClient struct {
	ID    uint64                     `json:"id" xorm:"pk autoincr"`
	Name  string                     `json:"name"`
	Host  string                     `json:"host"`
	Extra PipelineSnippetClientExtra `json:"extra" xorm:"json"`
}

func (*DicePipelineSnippetClient) TableName

func (ps *DicePipelineSnippetClient) TableName() string

type PipelineLifecycleHookClient

type PipelineLifecycleHookClient struct {
	ID     uint64 `json:"id" xorm:"pk autoincr"`
	Name   string `json:"name"`
	Host   string `json:"host"`
	Prefix string `json:"prefix"`
}

func (*PipelineLifecycleHookClient) TableName

func (ps *PipelineLifecycleHookClient) TableName() string

type PipelineSnippetClientExtra

type PipelineSnippetClientExtra struct {
	UrlPathPrefix string `json:"urlPathPrefix"`
}

type Session

type Session struct {
	*xorm.Session
	AllowZeroAffectedRows bool
	NeedAutoClose         bool
	NeedNoAutoTime        bool
}

func (*Session) Close

func (session *Session) Close()

type SessionOption

type SessionOption func(*Session)

func WithAllowZeroAffectedRows

func WithAllowZeroAffectedRows(allow bool) SessionOption

func WithNoAutoTime

func WithNoAutoTime() SessionOption

WithNoAutoTime 仅作用在当前 session 若该 op 后接 WithTxSession 等其他从外部传入 session 的 op,则 WithNoAutoTime 不会在传入的 session 上生效 因此需要注意 op 顺序

func WithTxSession

func WithTxSession(_session *xorm.Session) SessionOption

Jump to

Keyboard shortcuts

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