services

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: Apache-2.0, MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBlueprintRunning = errors.Default.New("the blueprint is running")

ErrBlueprintRunning indicates there is a running pipeline with the specified blueprint_id

Functions

func CancelPipeline

func CancelPipeline(pipelineId uint64) errors.Error

CancelPipeline FIXME ...

func CancelTask

func CancelTask(taskId uint64) errors.Error

CancelTask FIXME ...

func ComputePipelineStatus added in v0.15.0

func ComputePipelineStatus(pipeline *models.DbPipeline, isCancelled bool) (string, errors.Error)

ComputePipelineStatus determines pipleline status by its latest(rerun included) tasks statuses 1. TASK_COMPLETED: all tasks were executed sucessfully 2. TASK_FAILED: SkipOnFail=false with failed task(s) 3. TASK_PARTIAL: SkipOnFail=true with failed task(s)

func CreateBlueprint

func CreateBlueprint(blueprint *models.Blueprint) errors.Error

CreateBlueprint accepts a Blueprint instance and insert it to database

func CreateDbPipeline added in v0.14.0

func CreateDbPipeline(newPipeline *models.NewPipeline) (*models.DbPipeline, errors.Error)

CreateDbPipeline returns a NewPipeline

func CreatePipeline

func CreatePipeline(newPipeline *models.NewPipeline) (*models.Pipeline, errors.Error)

CreatePipeline and return the model

func CreateProject added in v0.15.0

func CreateProject(projectInput *models.ApiInputProject) (*models.ApiOutputProject, errors.Error)

CreateProject accepts a project instance and insert it to database

func CreateTask

func CreateTask(newTask *models.NewTask) (*models.Task, errors.Error)

CreateTask creates a new task

func ExecuteMigration added in v0.12.0

func ExecuteMigration() errors.Error

ExecuteMigration executes all pending migration scripts and initialize services module

func GeneratePlanJsonV100 added in v0.12.0

func GeneratePlanJsonV100(settings *models.BlueprintSettings) (core.PipelinePlan, errors.Error)

GeneratePlanJsonV100 generates pipeline plan according v1.0.0 definition

func GeneratePlanJsonV200 added in v0.15.0

func GeneratePlanJsonV200(
	projectName string,
	syncPolicy core.BlueprintSyncPolicy,
	sources *models.BlueprintSettings,
	metrics map[string]json.RawMessage,
) (core.PipelinePlan, errors.Error)

GeneratePlanJsonV200 generates pipeline plan according v2.0.0 definition

func GetBasicRes added in v0.15.0

func GetBasicRes() core.BasicRes

GetBasicRes returns the core.BasicRes instance used by services module

func GetBlueprint

func GetBlueprint(blueprintId uint64) (*models.Blueprint, errors.Error)

GetBlueprint returns the detail of a given Blueprint ID

func GetBlueprintByProjectName added in v0.15.0

func GetBlueprintByProjectName(projectName string) (*models.Blueprint, errors.Error)

GetBlueprintByProjectName returns the detail of a given ProjectName

func GetBlueprints

func GetBlueprints(query *BlueprintQuery) ([]*models.Blueprint, int64, errors.Error)

GetBlueprints returns a paginated list of Blueprints based on `query`

func GetDbBlueprint added in v0.14.0

func GetDbBlueprint(dbBlueprintId uint64) (*models.DbBlueprint, errors.Error)

GetDbBlueprint returns the detail of a given Blueprint ID

func GetDbBlueprintByProjectName added in v0.15.0

func GetDbBlueprintByProjectName(projectName string) (*models.DbBlueprint, errors.Error)

GetDbBlueprintByProjectName returns the detail of a given projectName

func GetDbBlueprints added in v0.14.0

func GetDbBlueprints(query *BlueprintQuery) ([]*models.DbBlueprint, int64, errors.Error)

GetDbBlueprints returns a paginated list of Blueprints based on `query`

func GetDbPipeline added in v0.14.0

func GetDbPipeline(pipelineId uint64) (*models.DbPipeline, errors.Error)

GetDbPipeline by id

func GetDbPipelines added in v0.14.0

func GetDbPipelines(query *PipelineQuery) ([]*models.DbPipeline, int64, errors.Error)

GetDbPipelines by query

func GetLatestTasksOfPipeline added in v0.15.0

func GetLatestTasksOfPipeline(pipeline *models.DbPipeline) ([]*models.Task, errors.Error)

GetLatestTasksOfPipeline returns latest tasks (reran tasks are excluding) of specified pipeline

func GetMigrator added in v0.15.0

func GetMigrator() core.Migrator

GetMigrator returns the core.Migrator instance used by services module

func GetPipeline

func GetPipeline(pipelineId uint64) (*models.Pipeline, errors.Error)

GetPipeline by id

func GetPipelineLogger added in v0.15.0

func GetPipelineLogger(pipeline *models.Pipeline) core.Logger

GetPipelineLogger returns logger for the pipeline

func GetPipelineLogsArchivePath added in v0.13.0

func GetPipelineLogsArchivePath(pipeline *models.Pipeline) (string, errors.Error)

GetPipelineLogsArchivePath creates an archive for the logs of this pipeline and returns its file path

func GetPipelines

func GetPipelines(query *PipelineQuery) ([]*models.Pipeline, int64, errors.Error)

GetPipelines by query

func GetPluginsApiResources

func GetPluginsApiResources() (map[string]map[string]map[string]core.ApiResourceHandler, errors.Error)

GetPluginsApiResources return value

{
	"jira": {
		"connections": {
			"POST": *ApiResourceHandler
		}
	}
}

GetPluginsApiResources returns all APIs of all plugins

func GetProject added in v0.15.0

func GetProject(name string) (*models.ApiOutputProject, errors.Error)

GetProject returns a Project

func GetProjects added in v0.15.0

func GetProjects(query *ProjectQuery) ([]*models.Project, int64, errors.Error)

GetProjects returns a paginated list of Projects based on `query`

func GetRepos

func GetRepos() ([]*code.Repo, int64, errors.Error)

GetRepos FIXME ...

func GetTask

func GetTask(taskId uint64) (*models.Task, errors.Error)

GetTask FIXME ...

func GetTasks

func GetTasks(query *TaskQuery) ([]*models.Task, int64, errors.Error)

GetTasks returns paginated tasks that match the given query

func GetTasksWithLastStatus added in v0.15.0

func GetTasksWithLastStatus(pipelineId uint64) ([]*models.Task, errors.Error)

GetTasksWithLastStatus returns task list of the pipeline, only the most recently tasks would be returned TODO: adopts GetLatestTasksOfPipeline

func Init added in v0.12.0

func Init()

Init the services module

func InitResources added in v0.15.0

func InitResources()

InitResources creates resources needed by services module

func InsertRow

func InsertRow(table string, rows []map[string]interface{}) (int64, errors.Error)

InsertRow FIXME ...

func MakePlanForBlueprint added in v0.15.0

func MakePlanForBlueprint(blueprint *models.Blueprint) (core.PipelinePlan, errors.Error)

MakePlanForBlueprint generates pipeline plan by version

func MigrationRequireConfirmation added in v0.12.0

func MigrationRequireConfirmation() bool

MigrationRequireConfirmation returns if there were migration scripts waiting to be executed

func NotifyExternal

func NotifyExternal(pipelineId uint64) errors.Error

NotifyExternal FIXME ...

func ParallelizePipelinePlans added in v0.15.0

func ParallelizePipelinePlans(plans ...core.PipelinePlan) core.PipelinePlan

ParallelizePipelinePlans merges multiple pipelines into one unified plan by assuming they can be executed in parallel

func PatchBlueprint added in v0.12.0

func PatchBlueprint(id uint64, body map[string]interface{}) (*models.Blueprint, errors.Error)

PatchBlueprint FIXME ...

func PatchProject added in v0.15.0

func PatchProject(name string, body map[string]interface{}) (*models.ApiOutputProject, errors.Error)

PatchProject FIXME ...

func ReloadBlueprints

func ReloadBlueprints(c *cron.Cron) errors.Error

ReloadBlueprints FIXME ...

func RerunPipeline added in v0.15.0

func RerunPipeline(pipelineId uint64, task *models.Task) ([]*models.Task, errors.Error)

RerunPipeline would rerun all failed tasks or specified task

func RerunTask added in v0.15.0

func RerunTask(taskId uint64) (*models.Task, errors.Error)

RerunTask reruns specified task

func RunPipelineInQueue added in v0.12.0

func RunPipelineInQueue(pipelineMaxParallel int64)

RunPipelineInQueue query pipeline from db and run it in a queue

func RunTasksStandalone added in v0.15.0

func RunTasksStandalone(parentLogger core.Logger, taskIds []uint64) errors.Error

RunTasksStandalone run tasks in parallel

func SaveDbBlueprint added in v0.15.0

func SaveDbBlueprint(dbBlueprint *models.DbBlueprint) errors.Error

SaveDbBlueprint accepts a Blueprint instance and upsert it to database

func SequencializePipelinePlans added in v0.15.0

func SequencializePipelinePlans(plans ...core.PipelinePlan) core.PipelinePlan

SequencializePipelinePlans merges multiple pipelines into one unified plan by assuming they must be executed in sequencial order

func TriggerBlueprint added in v0.12.0

func TriggerBlueprint(id uint64) (*models.Pipeline, errors.Error)

TriggerBlueprint triggers blueprint immediately

func VerifyStruct added in v0.15.0

func VerifyStruct(v interface{}) errors.Error

VerifyStruct verifies given struct with `validator`

func WrapPipelinePlans added in v0.15.0

func WrapPipelinePlans(beforePlanJson json.RawMessage, mainPlan core.PipelinePlan, afterPlanJson json.RawMessage) (core.PipelinePlan, errors.Error)

WrapPipelinePlans merges multiple pipelines and append before and after pipeline

Types

type BlueprintQuery

type BlueprintQuery struct {
	Pagination
	Enable   *bool  `form:"enable,omitempty"`
	IsManual *bool  `form:"is_manual"`
	Label    string `form:"label"`
}

BlueprintQuery is a query for GetBlueprints

type NotificationService

type NotificationService struct {
	EndPoint string
	Secret   string
}

NotificationService FIXME ...

func NewNotificationService

func NewNotificationService(endpoint, secret string) *NotificationService

NewNotificationService FIXME ...

func (*NotificationService) PipelineStatusChanged

func (n *NotificationService) PipelineStatusChanged(params PipelineNotification) errors.Error

PipelineStatusChanged FIXME ...

type Pagination added in v0.15.0

type Pagination struct {
	Page     int `form:"page"`
	PageSize int `form:"pageSize"`
}

Pagination holds the paginate information

func (*Pagination) GetPage added in v0.15.0

func (p *Pagination) GetPage() int

GetPage returns current page number

func (*Pagination) GetPageSize added in v0.15.0

func (p *Pagination) GetPageSize() int

GetPageSize returns a sensible page size based on input

func (*Pagination) GetPageSizeOr added in v0.15.0

func (p *Pagination) GetPageSizeOr(defaultVal int) int

GetPageSizeOr returns the page size or fallback to `defaultVal`

func (*Pagination) GetSkip added in v0.15.0

func (p *Pagination) GetSkip() int

GetSkip returns how many records should be skipped for specified page

type PipelineNotification

type PipelineNotification struct {
	PipelineID uint64
	CreatedAt  time.Time
	UpdatedAt  time.Time
	BeganAt    *time.Time
	FinishedAt *time.Time
	Status     string
}

PipelineNotification FIXME ...

type PipelineQuery

type PipelineQuery struct {
	Pagination
	Status      string `form:"status"`
	Pending     int    `form:"pending"`
	BlueprintId uint64 `uri:"blueprintId" form:"blueprint_id"`
	Label       string `form:"label"`
}

PipelineQuery is a query for GetPipelines

type ProjectQuery added in v0.15.0

type ProjectQuery struct {
	Pagination
}

ProjectQuery used to query projects as the api project input

type RunningTask

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

RunningTask FIXME ...

func (*RunningTask) Add

func (rt *RunningTask) Add(taskId uint64, cancel context.CancelFunc) errors.Error

Add FIXME ...

func (*RunningTask) FillProgressDetailToTasks

func (rt *RunningTask) FillProgressDetailToTasks(tasks []*models.Task)

FillProgressDetailToTasks lock less times than GetProgressDetail

func (*RunningTask) GetProgressDetail

func (rt *RunningTask) GetProgressDetail(taskId uint64) *models.TaskProgressDetail

GetProgressDetail FIXME ...

func (*RunningTask) Remove

func (rt *RunningTask) Remove(taskId uint64) (context.CancelFunc, errors.Error)

Remove FIXME ...

type RunningTaskData

type RunningTaskData struct {
	Cancel         context.CancelFunc
	ProgressDetail *models.TaskProgressDetail
}

RunningTaskData FIXME ...

type TaskQuery

type TaskQuery struct {
	Pagination
	Status     string `form:"status"`
	Plugin     string `form:"plugin"`
	PipelineId uint64 `form:"pipelineId" uri:"pipelineId"`
	Pending    int    `form:"pending"`
}

TaskQuery FIXME .

Jump to

Keyboard shortcuts

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