workflow

package
v0.54.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: BSD-3-Clause Imports: 55 Imported by: 4

Documentation

Index

Constants

View Source
const (
	SecretProjContext                   = "proj"
	SecretAppContext                    = "app:%d"
	SecretEnvContext                    = "env:%d"
	SecretProjIntegrationContext        = "integration:%d"
	SecretApplicationIntegrationContext = "app:%d:integration:%s"
)
View Source
const WorkflowAsCodePattern = ".cds/*.yml"

WorkflowAsCodePattern is the default code pattern to find cds files

Variables

View Source
var (
	Audits = map[string]sdk.Audit{
		fmt.Sprintf("%T", sdk.EventWorkflowAdd{}):              addWorkflowAudit{},
		fmt.Sprintf("%T", sdk.EventWorkflowUpdate{}):           updateWorkflowAudit{},
		fmt.Sprintf("%T", sdk.EventWorkflowPermissionAdd{}):    addWorkflowPermissionAudit{},
		fmt.Sprintf("%T", sdk.EventWorkflowPermissionUpdate{}): updateWorkflowPermissionAudit{},
		fmt.Sprintf("%T", sdk.EventWorkflowPermissionDelete{}): deleteWorkflowPermissionAudit{},
	}
)
View Source
var (
	KeyResult = cache.Key("run", "result")
)

Functions

func AddResult

func AddResult(ctx context.Context, db *gorp.DbMap, store cache.Store, wr *sdk.WorkflowRun, runResult *sdk.WorkflowRunResult) error

func AddSpawnInfosNodeJobRun

func AddSpawnInfosNodeJobRun(db gorp.SqlExecutor, nodeID, jobID int64, infos []sdk.SpawnInfo) error

AddSpawnInfosNodeJobRun saves spawn info before starting worker

func AddWorkflowIntegration

func AddWorkflowIntegration(db gorp.SqlExecutor, integ *sdk.WorkflowProjectIntegration) error

AddWorkflowIntegration link a project integration on a workflow

func AddWorkflowRunInfo

func AddWorkflowRunInfo(run *sdk.WorkflowRun, infos ...sdk.SpawnMsg)

AddWorkflowRunInfo add WorkflowRunInfo on a WorkflowRun

func AggregateOnWorkflowTemplateInstance

func AggregateOnWorkflowTemplateInstance(ctx context.Context, db gorp.SqlExecutor, wtis ...*sdk.WorkflowTemplateInstance) error

AggregateOnWorkflowTemplateInstance set workflow for each workflow template instance.

func BookNodeJobRun

func BookNodeJobRun(ctx context.Context, store cache.Store, defaultBookDelay int64, customBookDelay map[string]int64, id int64, hatchery *sdk.Service) (*sdk.Service, error)

BookNodeJobRun Book a job for a hatchery

func CanBeRun

func CanBeRun(workflowRun *sdk.WorkflowRun, workflowNodeRun *sdk.WorkflowNodeRun) bool

CanBeRun return boolean to know if a workflow node run can be run or not TODO: if no bugs are found, it could be used to refactor process.go

func CanUploadRunResult

func CanUploadRunResult(ctx context.Context, db *gorp.DbMap, store cache.Store, wr sdk.WorkflowRun, runResultCheck sdk.WorkflowRunResultCheck) (bool, error)

func CheckRegion

func CheckRegion(ctx context.Context, db gorp.SqlExecutor, proj sdk.Project, wf sdk.Workflow) error

func CheckValidity

func CheckValidity(_ context.Context, _ gorp.SqlExecutor, w *sdk.Workflow) error

CheckValidity checks workflow validity

func CompleteWorkflow

func CompleteWorkflow(ctx context.Context, db gorp.SqlExecutor, w *sdk.Workflow, proj sdk.Project, opts LoadOptions) error

func CountNodeJobRunQueue

func CountNodeJobRunQueue(ctx context.Context, db gorp.SqlExecutor, store cache.Store, filter QueueFilter) (sdk.WorkflowNodeJobRunCount, error)

CountNodeJobRunQueue count all workflow_node_run_job accessible

func CountNodeJobRunQueueByGroupIDs

func CountNodeJobRunQueueByGroupIDs(ctx context.Context, db gorp.SqlExecutor, store cache.Store, filter QueueFilter, groupIDs []int64) (sdk.WorkflowNodeJobRunCount, error)

func CountNotPendingWorkflowRunsByWorkflowID

func CountNotPendingWorkflowRunsByWorkflowID(db gorp.SqlExecutor, workflowID int64) (int64, error)

func CountPipeline

func CountPipeline(db gorp.SqlExecutor, pipelineID int64) (bool, error)

CountPipeline Count the number of workflow that use the given pipeline

func CountRepositoryWebHooksByApplication

func CountRepositoryWebHooksByApplication(db gorp.SqlExecutor, appID int64) (int64, error)

CountRepositoryWebHooksByApplication count repository webhooks by application id

func CountRunSecretsByWorkflowRunID added in v0.52.0

func CountRunSecretsByWorkflowRunID(ctx context.Context, db gorp.SqlExecutor, workflowRunID int64) (int64, error)

func CountWorkflowRunsMarkToDelete

func CountWorkflowRunsMarkToDelete(ctx context.Context, db gorp.SqlExecutor, workflowRunsMarkToDelete *stats.Int64Measure) int64

func CreateBuiltinWorkflowHookModels

func CreateBuiltinWorkflowHookModels(db *gorp.DbMap) error

CreateBuiltinWorkflowHookModels insert all builtin hook models in database

func CreateBuiltinWorkflowOutgoingHookModels

func CreateBuiltinWorkflowOutgoingHookModels(db *gorp.DbMap) error

CreateBuiltinWorkflowOutgoingHookModels insert all builtin hook models in database

func CreateRun

CreateRun creates a new workflow run and insert it

func DefaultPayload

func DefaultPayload(ctx context.Context, db gorpmapper.SqlExecutorWithTx, store cache.Store, proj sdk.Project, wf *sdk.Workflow) (interface{}, error)

DefaultPayload returns the default payload for the workflow root

func Delete

Delete workflow

func DeleteIntegrationsFromWorkflow

func DeleteIntegrationsFromWorkflow(db gorp.SqlExecutor, workflowID int64) error

DeleteIntegrationsFromWorkflow remove a project integration on a workflow

func DeleteNodeJobRun

func DeleteNodeJobRun(db gorp.SqlExecutor, nodeRunJob int64) error

DeleteNodeJobRun deletes the given workflow_node_run_job

func DeleteNodeJobRuns

func DeleteNodeJobRuns(db gorp.SqlExecutor, nodeID int64) error

DeleteNodeJobRuns deletes all workflow_node_run_job for a given workflow_node_run

func DeleteNotifications

func DeleteNotifications(db gorp.SqlExecutor, workflowID int64) error

func DeleteRunSecretsByWorkflowRunID added in v0.52.0

func DeleteRunSecretsByWorkflowRunID(ctx context.Context, db gorpmapper.SqlExecutorWithTx, workflowRunID int64) error

func DeleteWorkflowData

func DeleteWorkflowData(db gorp.SqlExecutor, wf sdk.Workflow) error

DeleteWorkflowData delete the relation representation of the workflow

func Exists

func Exists(ctx context.Context, db gorp.SqlExecutor, key string, name string) (bool, error)

Exists checks if a workflow exists

func ExistsID

func ExistsID(ctx context.Context, db gorp.SqlExecutor, key string, id int64) (bool, error)

ExistsID checks if a workflow exists for given ID and project

func Export

func Export(ctx context.Context, db gorp.SqlExecutor, cache cache.Store, proj sdk.Project, name string, opts ...v2.ExportOptions) (exportentities.Workflow, error)

Export a workflow

func FindOldestWorkflowRunsWithResultToSync added in v0.52.0

func FindOldestWorkflowRunsWithResultToSync(ctx context.Context, dbmap *gorp.DbMap) ([]int64, error)

func FreeNodeJobRun

func FreeNodeJobRun(ctx context.Context, store cache.Store, id int64) error

FreeNodeJobRun Free a job for a hatchery

func GetNodeRunBuildCommits

func GetNodeRunBuildCommits(ctx context.Context, db gorpmapper.SqlExecutorWithTx, store cache.Store, proj sdk.Project, wf sdk.Workflow, wNodeName string, number int64, nodeRun *sdk.WorkflowNodeRun, app *sdk.Application, env *sdk.Environment) ([]sdk.VCSCommit, sdk.BuildNumberAndHash, error)

GetNodeRunBuildCommits gets commits for given node run and return current vcs info

func GetRunResultKey

func GetRunResultKey(runID int64, t sdk.WorkflowRunResultType, fileName string) string

func GetTagsAndValue

func GetTagsAndValue(db gorp.SqlExecutor, key, name string) (map[string][]string, error)

GetTagsAndValue returns a map of tags and all the values available on all runs of a workflow

func Import

func Import(ctx context.Context, db gorpmapper.SqlExecutorWithTx, store cache.Store, proj sdk.Project, oldW, w *sdk.Workflow, consumer *sdk.AuthUserConsumer, opts ImportOptions, msgChan chan<- sdk.Message) error

Import is able to create a new workflow and all its components

func Initialize

func Initialize(ctx context.Context, DBFunc func() *gorp.DbMap, store cache.Store, uiURL, confDefaultOS, confDefaultArch string, maxLogSize int64)

Initialize starts goroutines for workflows

func Insert

Insert inserts a new workflow

func InsertAudit

func InsertAudit(db gorp.SqlExecutor, a *sdk.AuditWorkflow) error

InsertAudit insert a workflow audit

func InsertHookModel

func InsertHookModel(db gorp.SqlExecutor, m *sdk.WorkflowHookModel) error

InsertHookModel inserts a hook model in database

func InsertNotification

func InsertNotification(db gorp.SqlExecutor, w *sdk.Workflow, n *sdk.WorkflowNotification) error

func InsertOutgoingHookModel

func InsertOutgoingHookModel(db gorp.SqlExecutor, m *sdk.WorkflowHookModel) error

InsertOutgoingHookModel inserts a hook model in database

func InsertRunNum

func InsertRunNum(db gorp.SqlExecutor, w *sdk.Workflow, num int64) error

InsertRunNum Insert run number for the given workflow

func InsertRunSecret

func InsertRunSecret(ctx context.Context, db gorpmapper.SqlExecutorWithTx, wrSecret *sdk.WorkflowRunSecret) error

func InsertWorkflowData

func InsertWorkflowData(db gorp.SqlExecutor, w *sdk.Workflow) error

InsertWorkflowData insert workflow data

func InsertWorkflowRunTags

func InsertWorkflowRunTags(db gorp.SqlExecutor, runID int64, runTags []sdk.WorkflowRunTag) error

InsertWorkflowRunTags inserts new tags in database

func IsDeploymentIntegrationUsed

func IsDeploymentIntegrationUsed(db gorp.SqlExecutor, projectID int64, appID int64, pfName string) (bool, error)

IsDeploymentIntegrationUsed checks if a deployment integration is used on any workflow

func IsFavorite

func IsFavorite(db gorp.SqlExecutor, w *sdk.Workflow, uID string) (bool, error)

func LabelWorkflow

func LabelWorkflow(db gorp.SqlExecutor, labelID, workflowID int64) error

LabelWorkflow link a label on a workflow given his workflow id

func Load

func Load(ctx context.Context, db gorp.SqlExecutor, _ cache.Store, proj sdk.Project, name string, opts LoadOptions) (*sdk.Workflow, error)

Load loads a workflow for a given user (ie. checking permissions)

func LoadAll

func LoadAll(ctx context.Context, db gorp.SqlExecutor, projectKey string) (sdk.Workflows, error)

LoadAll loads all workflows for a project. All users in a project can list all workflows in a project

func LoadAllByIDs

func LoadAllByIDs(ctx context.Context, db gorp.SqlExecutor, ids []int64) (sdk.Workflows, error)

LoadAllByIDs returns all workflows by ids.

func LoadAllHooks

func LoadAllHooks(db gorp.SqlExecutor) ([]sdk.NodeHook, error)

LoadAllHooks returns all hooks

func LoadAllNames

func LoadAllNames(db gorp.SqlExecutor, projID int64) (sdk.IDNames, error)

LoadAllNames loads all workflow names for a project.

func LoadAllNamesByProjectIDs

func LoadAllNamesByProjectIDs(_ context.Context, db gorp.SqlExecutor, projectIDs []int64) ([]sdk.WorkflowName, error)

LoadAllNamesByProjectIDs returns all workflow for given project ids.

func LoadAndLockNodeJobRunSkipLocked

func LoadAndLockNodeJobRunSkipLocked(ctx context.Context, db gorp.SqlExecutor, store cache.Store, id int64) (*sdk.WorkflowNodeJobRun, error)

LoadAndLockNodeJobRunSkipLocked load for update a NodeJobRun given its ID

func LoadAndLockNodeJobRunWait

func LoadAndLockNodeJobRunWait(ctx context.Context, db gorp.SqlExecutor, store cache.Store, id int64) (*sdk.WorkflowNodeJobRun, error)

LoadAndLockNodeJobRunWait load for update a NodeJobRun given its ID

func LoadAndLockNodeRunByID

func LoadAndLockNodeRunByID(ctx context.Context, db gorp.SqlExecutor, id int64) (*sdk.WorkflowNodeRun, error)

LoadAndLockNodeRunByID load and lock a specific node run on a workflow

func LoadAndLockNodeRunByJobID

func LoadAndLockNodeRunByJobID(ctx context.Context, db gorp.SqlExecutor, jobID int64) (*sdk.WorkflowNodeRun, error)

LoadAndLockNodeRunByJobID load and lock a specific node run on a workflow

func LoadAndLockRunByID

func LoadAndLockRunByID(ctx context.Context, db gorp.SqlExecutor, id int64, loadOpts LoadRunOptions) (*sdk.WorkflowRun, error)

LoadAndLockRunByID loads run by ID

func LoadAndLockRunByJobID

func LoadAndLockRunByJobID(ctx context.Context, db gorp.SqlExecutor, id int64, loadOpts LoadRunOptions) (*sdk.WorkflowRun, error)

LoadAndLockRunByJobID loads a run by a job id

func LoadAndLockTerminatedNodeJobRun added in v0.53.1

func LoadAndLockTerminatedNodeJobRun(ctx context.Context, db gorp.SqlExecutor, limit int) ([]sdk.WorkflowNodeJobRun, error)

func LoadApplicationSecrets

func LoadApplicationSecrets(ctx context.Context, db gorp.SqlExecutor, id int64) ([]sdk.Variable, error)

func LoadAudit

func LoadAudit(db gorp.SqlExecutor, auditID int64, workflowID int64) (sdk.AuditWorkflow, error)

LoadAudit Load audit for the given workflow

func LoadAudits

func LoadAudits(db gorp.SqlExecutor, workflowID int64) ([]sdk.AuditWorkflow, error)

LoadAudits Load audits for the given workflow

func LoadByApplicationName

func LoadByApplicationName(ctx context.Context, db gorp.SqlExecutor, projectKey string, appName string) ([]sdk.WorkflowName, error)

LoadByApplicationName loads a workflow for a given project key and application name

func LoadByEnvName

func LoadByEnvName(ctx context.Context, db gorp.SqlExecutor, projectKey string, envName string) ([]sdk.WorkflowName, error)

LoadByEnvName loads a workflow for a given project key and environment name (ie. checking permissions)

func LoadByID

func LoadByID(ctx context.Context, db gorp.SqlExecutor, _ cache.Store, proj sdk.Project, id int64, opts LoadOptions) (*sdk.Workflow, error)

LoadByID loads a workflow

func LoadByPipelineName

func LoadByPipelineName(ctx context.Context, db gorp.SqlExecutor, projectKey string, pipName string) ([]sdk.WorkflowName, error)

LoadByPipelineName loads a workflow for a given project key and pipeline name

func LoadByRepo

func LoadByRepo(ctx context.Context, db gorp.SqlExecutor, proj sdk.Project, repo string, opts LoadOptions) (*sdk.Workflow, error)

func LoadByWorkflowTemplateID

func LoadByWorkflowTemplateID(ctx context.Context, db gorp.SqlExecutor, templateID int64) ([]sdk.WorkflowName, error)

LoadByWorkflowTemplateID load all workflow names linked to a workflow template

func LoadCraftingWorkflowRunIDs added in v0.53.1

func LoadCraftingWorkflowRunIDs(db gorp.SqlExecutor) ([]int64, error)

func LoadCurrentRunNum

func LoadCurrentRunNum(db gorp.SqlExecutor, projectkey, workflowname string) (int64, error)

LoadCurrentRunNum load the current num from workflow_sequences table

func LoadDeadNodeJobRun

func LoadDeadNodeJobRun(ctx context.Context, db gorp.SqlExecutor, store cache.Store) ([]sdk.WorkflowNodeJobRun, error)

LoadDeadNodeJobRun load a NodeJobRun which is Building but without worker

func LoadDecryptSecrets

func LoadDecryptSecrets(ctx context.Context, db gorp.SqlExecutor, wr *sdk.WorkflowRun, nodeRun *sdk.WorkflowNodeRun) (sdk.WorkflowRunSecrets, error)

LoadDecryptSecrets loads all secrets for a job run

func LoadEnvironmentSecrets

func LoadEnvironmentSecrets(db gorp.SqlExecutor, id int64) ([]sdk.Variable, error)

func LoadHookByUUID

func LoadHookByUUID(db gorp.SqlExecutor, uuid string) (sdk.NodeHook, error)

LoadHookByUUID load a hook by his uuid

func LoadHookModelByID

func LoadHookModelByID(db gorp.SqlExecutor, id int64) (*sdk.WorkflowHookModel, error)

LoadHookModelByID returns a hook model by it's id, if not found, it returns an error

func LoadHookModelByName

func LoadHookModelByName(db gorp.SqlExecutor, name string) (*sdk.WorkflowHookModel, error)

LoadHookModelByName returns a hook model by it's name, if not found, it returns an error

func LoadHookModels

func LoadHookModels(db gorp.SqlExecutor) ([]sdk.WorkflowHookModel, error)

LoadHookModels returns all hook models available

func LoadLabels

func LoadLabels(db gorp.SqlExecutor, workflowIDs ...int64) ([]sdk.Label, error)

LoadLabels return list of labels given a workflow ID

func LoadLastRun

func LoadLastRun(ctx context.Context, db gorp.SqlExecutor, projectkey, workflowname string, loadOpts LoadRunOptions) (*sdk.WorkflowRun, error)

LoadLastRun returns the last run for a workflow

func LoadLastRuns

func LoadLastRuns(ctx context.Context, db gorp.SqlExecutor, workflowIDs []int64, limit int) ([]sdk.WorkflowRun, error)

LoadLastRuns returns the last run per workflowIDs

func LoadNodeJobRun

func LoadNodeJobRun(ctx context.Context, db gorp.SqlExecutor, store cache.Store, id int64) (*sdk.WorkflowNodeJobRun, error)

LoadNodeJobRun load a NodeJobRun given its ID

func LoadNodeJobRunIDByNodeRunID

func LoadNodeJobRunIDByNodeRunID(db gorp.SqlExecutor, runNodeID int64) ([]int64, error)

LoadNodeJobRunIDByNodeRunID Load node run job id by node run id

func LoadNodeJobRunQueue

func LoadNodeJobRunQueue(ctx context.Context, db gorp.SqlExecutor, store cache.Store, filter QueueFilter) ([]sdk.WorkflowNodeJobRun, error)

LoadNodeJobRunQueue load all workflow_node_run_job accessible

func LoadNodeJobRunQueueByGroupIDs

func LoadNodeJobRunQueueByGroupIDs(ctx context.Context, db gorp.SqlExecutor, store cache.Store, filter QueueFilter, groupIDs []int64) ([]sdk.WorkflowNodeJobRun, error)

LoadNodeJobRunQueueByGroupIDs load all workflow_node_run_job accessible

func LoadNodeRun

func LoadNodeRun(db gorp.SqlExecutor, projectkey, workflowname string, noderunID int64, loadOpts LoadRunOptions) (*sdk.WorkflowNodeRun, error)

LoadNodeRun load a specific node run on a workflow

func LoadNodeRunByID

func LoadNodeRunByID(ctx context.Context, db gorp.SqlExecutor, id int64, loadOpts LoadRunOptions) (*sdk.WorkflowNodeRun, error)

LoadNodeRunByID load a specific node run on a workflow

func LoadNodeRunByNodeJobID

func LoadNodeRunByNodeJobID(db gorp.SqlExecutor, nodeJobRunID int64, loadOpts LoadRunOptions) (*sdk.WorkflowNodeRun, error)

LoadNodeRunByNodeJobID load a specific node run on a workflow from a node job run id

func LoadNodeRunDistinctExecutionIDs

func LoadNodeRunDistinctExecutionIDs(db gorp.SqlExecutor) ([]string, error)

func LoadNodeRunJobInfo

func LoadNodeRunJobInfo(ctx context.Context, db gorp.SqlExecutor, nodeRunID int64, jobID int64) ([]sdk.SpawnInfo, error)

LoadNodeRunJobInfo load infos (workflow_node_run_job_infos) for a job (workflow_node_run_job)

func LoadNotificationsByWorkflowIDs

func LoadNotificationsByWorkflowIDs(db gorp.SqlExecutor, ids []int64) (map[int64][]sdk.WorkflowNotification, error)

func LoadOutgoingHookModelByID

func LoadOutgoingHookModelByID(db gorp.SqlExecutor, id int64) (*sdk.WorkflowHookModel, error)

LoadOutgoingHookModelByID returns a hook model by it's id, if not found, it returns an error

func LoadOutgoingHookModelByName

func LoadOutgoingHookModelByName(db gorp.SqlExecutor, name string) (*sdk.WorkflowHookModel, error)

LoadOutgoingHookModelByName returns a hook model by it's name, if not found, it returns an error

func LoadOutgoingHookModels

func LoadOutgoingHookModels(db gorp.SqlExecutor) ([]sdk.WorkflowHookModel, error)

LoadOutgoingHookModels returns all hook models available

func LoadRun

func LoadRun(ctx context.Context, db gorp.SqlExecutor, projectkey, workflowname string, number int64, loadOpts LoadRunOptions) (*sdk.WorkflowRun, error)

LoadRun returns a specific run

func LoadRunByID

func LoadRunByID(ctx context.Context, db gorp.SqlExecutor, id int64, loadOpts LoadRunOptions) (*sdk.WorkflowRun, error)

LoadRunByID loads run by ID

func LoadRunByIDAndProjectKey

func LoadRunByIDAndProjectKey(ctx context.Context, db gorp.SqlExecutor, projectkey string, id int64, loadOpts LoadRunOptions) (*sdk.WorkflowRun, error)

LoadRunByIDAndProjectKey returns a specific run

func LoadRunByJobID

func LoadRunByJobID(ctx context.Context, db gorp.SqlExecutor, id int64, loadOpts LoadRunOptions) (*sdk.WorkflowRun, error)

LoadRunByJobID loads a run by a job id

func LoadRunResultsByNodeRunID

func LoadRunResultsByNodeRunID(ctx context.Context, db gorp.SqlExecutor, nodeRunID int64) (sdk.WorkflowRunResults, error)

func LoadRunResultsByRunID

func LoadRunResultsByRunID(ctx context.Context, db gorp.SqlExecutor, runID int64) (sdk.WorkflowRunResults, error)

func LoadRunResultsByRunIDFilterByIDs added in v0.52.0

func LoadRunResultsByRunIDFilterByIDs(ctx context.Context, db gorp.SqlExecutor, runID int64, resultIDs ...string) (sdk.WorkflowRunResults, error)

func LoadRunResultsByRunIDUnique added in v0.52.0

func LoadRunResultsByRunIDUnique(ctx context.Context, db gorp.SqlExecutor, runID int64) (sdk.WorkflowRunResults, error)

func LoadRunsIDByTag

func LoadRunsIDByTag(db gorp.SqlExecutor, projectKey, workflowName, tag, tagValue string) ([]int64, error)

LoadRunsIDByTag load workflow run ids for given tag and his value

func LoadRunsIDsCreatedBefore added in v0.52.0

func LoadRunsIDsCreatedBefore(ctx context.Context, db gorp.SqlExecutor, date time.Time, limit int64) ([]int64, error)

LoadRunsIDsCreatedBefore returns the first workflow runs created before given date.

func LoadRunsIDsToDelete

func LoadRunsIDsToDelete(db gorp.SqlExecutor, offset int64, limit int64) ([]int64, int64, int64, int64, error)

func LoadRunsSummaries

func LoadRunsSummaries(ctx context.Context, db gorp.SqlExecutor, projectkey, workflowname string, offset, limit int, tagFilter map[string]string) ([]sdk.WorkflowRunSummary, int, int, int, error)

LoadRunsSummaries loads a short version of workflow runs It returns runs, offset, limit count and an error

func LoadWorkflowFromWorkflowRunID

func LoadWorkflowFromWorkflowRunID(db gorp.SqlExecutor, wrID int64) (sdk.Workflow, error)

LoadWorkflowFromWorkflowRunID loads the workflow for the given workfloxw run id

func LoadWorkflowIntegrationsByWorkflowID

func LoadWorkflowIntegrationsByWorkflowID(ctx context.Context, db gorp.SqlExecutor, id int64) ([]sdk.WorkflowProjectIntegration, error)

LoadWorkflowIntegrationsByWorkflowID load workflow integrations by workflowid

func MarkAsDelete

func MarkAsDelete(ctx context.Context, db gorpmapper.SqlExecutorWithTx, cache cache.Store, proj sdk.Project, wkf *sdk.Workflow) error

MarkAsDelete marks a workflow to be deleted

func MarkAsDeleteWithDependencies

func MarkAsDeleteWithDependencies(ctx context.Context, db gorpmapper.SqlExecutorWithTx, cache cache.Store, proj sdk.Project, wf *sdk.Workflow) error

func MarkWorkflowRunsAsDelete

func MarkWorkflowRunsAsDelete(db gorp.SqlExecutor, ids []int64) error

MarkWorkflowRunsAsDelete marks workflow runs to be deleted

func MaxSubNumber

func MaxSubNumber(workflowNodeRuns map[int64][]sdk.WorkflowNodeRun) int64

MaxSubNumber returns the MaxSubNumber of workflowNodeRuns

func NextRunNumber

func NextRunNumber(db gorp.SqlExecutor, workflowID int64) (int64, error)

func NodeBuildParametersFromRun

func NodeBuildParametersFromRun(wr sdk.WorkflowRun, id int64) ([]sdk.Parameter, error)

NodeBuildParametersFromRun return build parameters from previous workflow run

func NodeBuildParametersFromWorkflow

func NodeBuildParametersFromWorkflow(proj sdk.Project, wf *sdk.Workflow, refNode *sdk.Node, ancestorsIds []int64) ([]sdk.Parameter, error)

NodeBuildParametersFromWorkflow returns build_parameters for a node given its id

func Parse

func Parse(ctx context.Context, proj sdk.Project, oldW *sdk.Workflow, ew exportentities.Workflow) (*sdk.Workflow, error)

Parse parse an exportentities.workflow and return the parsed workflow

func ParseAndImport

ParseAndImport parse an exportentities.workflow and insert or update the workflow in database

func PrepareSpawnInfos

func PrepareSpawnInfos(infos []sdk.SpawnInfo) []sdk.SpawnInfo

PrepareSpawnInfos helps yoi to create sdk.SpawnInfo array

func PreviousNodeRun

func PreviousNodeRun(db gorp.SqlExecutor, nr sdk.WorkflowNodeRun, nodeName string, workflowID int64) (*sdk.WorkflowNodeRun, error)

PreviousNodeRun find previous node run

func PreviousNodeRunVCSInfos

func PreviousNodeRunVCSInfos(ctx context.Context, db gorp.SqlExecutor, projectKey string, wf sdk.Workflow, nodeName string, current sdk.BuildNumberAndHash, appID int64, envID int64) (sdk.BuildNumberAndHash, error)

PreviousNodeRunVCSInfos returns a struct with BuildNumber, Commit Hash, Branch, Remote, Remote_url for the current node run and the previous one on the same branch. Returned value may be zero if node run are not found If you don't have environment linked set envID to 0 or -1

func ProcessRunResultPromotionByRunID added in v0.52.0

func ProcessRunResultPromotionByRunID(ctx context.Context, db gorpmapper.SqlExecutorWithTx, workflowRunID int64, promotionType sdk.WorkflowRunResultPromotionType, promotionRequest sdk.WorkflowRunResultPromotionRequest) error

func Pull

Pull a workflow with all it dependencies; it writes a tar buffer in the writer

func PurgeAllWorkflowRunsByWorkflowID

func PurgeAllWorkflowRunsByWorkflowID(ctx context.Context, db gorp.SqlExecutor, id int64) (int, error)

PurgeAllWorkflowRunsByWorkflowID marks all workflow to delete given a workflow

func PurgeAudits

func PurgeAudits(ctx context.Context, db gorp.SqlExecutor) error

func PurgeWorkflowRun

func PurgeWorkflowRun(ctx context.Context, db gorp.SqlExecutor, wf sdk.Workflow) error

PurgeWorkflowRun mark all workflow run to delete

func ReadCDSFiles

func ReadCDSFiles(files map[string][]byte) (*tar.Reader, error)

ReadCDSFiles reads CDS files

func RemoveIntegrationFromWorkflow

func RemoveIntegrationFromWorkflow(db gorp.SqlExecutor, workflowInteg sdk.WorkflowProjectIntegration) error

RemoveIntegrationFromWorkflow remove a project integration on a workflow

func RenameNode

func RenameNode(ctx context.Context, db gorp.SqlExecutor, w *sdk.Workflow) error

func Resync

func Resync(ctx context.Context, db gorp.SqlExecutor, store cache.Store, proj sdk.Project, wr *sdk.WorkflowRun) error

Resync a workflow in the given workflow run

func ResyncCommitStatus

func ResyncCommitStatus(ctx context.Context, db *gorp.DbMap, store cache.Store, proj sdk.Project, wr *sdk.WorkflowRun, cdsUIURL string) error

ResyncCommitStatus resync commit status for a workflow run

func ResyncNodeRunsWithCommits

func ResyncNodeRunsWithCommits(ctx context.Context, db *gorp.DbMap, store cache.Store, proj sdk.Project, report *ProcessorReport)

ResyncNodeRunsWithCommits load commits build in this node run and save it into node run

func ResyncWorkflowRunResultsRoutine added in v0.52.0

func ResyncWorkflowRunResultsRoutine(ctx context.Context, DBFunc func() *gorp.DbMap, store cache.Store, delay time.Duration)

func RunExist

func RunExist(db gorp.SqlExecutor, projectKey string, workflowID int64, hash string) (bool, error)

RunExist Check if run exist or not

func SetMaxRuns

func SetMaxRuns(confMaxRuns int64)

func SetRunReadOnlyByID added in v0.52.0

func SetRunReadOnlyByID(ctx context.Context, db gorpmapper.SqlExecutorWithTx, workflowRunID int64) error

SetRunReadOnly set read only flag of a workflow run, this run cannot be restarted anymore.

func Sort

func Sort(w *sdk.Workflow)

Sort sorts all the workflow tree

func SortNode

func SortNode(n *sdk.Node)

SortNode sort the content of a node

func SyncNodeRunRunJob

func SyncNodeRunRunJob(ctx context.Context, db gorp.SqlExecutor, nodeRun *sdk.WorkflowNodeRun, nodeJobRun sdk.WorkflowNodeJobRun) (bool, error)

SyncNodeRunRunJob sync step status and spawnInfos in a specific run job

func SyncRunResultArtifactManagerByRunID added in v0.52.0

func SyncRunResultArtifactManagerByRunID(ctx context.Context, db gorpmapper.SqlExecutorWithTx, workflowRunID int64) error

func UnLabelWorkflow

func UnLabelWorkflow(db gorp.SqlExecutor, labelID, workflowID int64) error

UnLabelWorkflow unlink a label on a workflow given his workflow id

func Update

func Update(ctx context.Context, db gorpmapper.SqlExecutorWithTx, store cache.Store, proj sdk.Project, wf *sdk.Workflow, uptOption UpdateOptions) error

Update updates a workflow

func UpdateCraftedWorkflowRun

func UpdateCraftedWorkflowRun(db gorp.SqlExecutor, id int64) error

func UpdateFavorite

func UpdateFavorite(db gorp.SqlExecutor, workflowID int64, u string, add bool) error

UpdateFavorite add or delete workflow from user favorites

func UpdateFromRepository

func UpdateFromRepository(db gorp.SqlExecutor, workflowID int64, fromRepository string) error

UpdateFromRepository update the from_repository of a workflow

func UpdateHookModel

func UpdateHookModel(db gorp.SqlExecutor, m *sdk.WorkflowHookModel) error

UpdateHookModel updates a hook model in database

func UpdateIcon

func UpdateIcon(db gorp.SqlExecutor, workflowID int64, icon string) error

UpdateIcon update the icon of a workflow

func UpdateMaxRunsByID

func UpdateMaxRunsByID(db gorp.SqlExecutor, workflowID int64, maxRuns int64) error

func UpdateMetadata

func UpdateMetadata(db gorp.SqlExecutor, workflowID int64, metadata sdk.Metadata) error

UpdateMetadata update the metadata of a workflow

func UpdateNodeJobRun

func UpdateNodeJobRun(ctx context.Context, db gorp.SqlExecutor, j *sdk.WorkflowNodeJobRun) error

UpdateNodeJobRun updates a workflow_node_run_job

func UpdateNodeRun

func UpdateNodeRun(db gorp.SqlExecutor, n *sdk.WorkflowNodeRun) error

UpdateNodeRun updates in table workflow_node_run

func UpdateNodeRunBuildParameters

func UpdateNodeRunBuildParameters(db gorp.SqlExecutor, nodeID int64, buildParameters []sdk.Parameter) error

UpdateNodeRunBuildParameters updates build_parameters in table workflow_node_run

func UpdateNodeRunStatusAndStage

func UpdateNodeRunStatusAndStage(db gorp.SqlExecutor, nodeRun *sdk.WorkflowNodeRun) error

UpdateNodeRunStatusAndStage update just noderun status and stage

func UpdateOutgoingHookModel

func UpdateOutgoingHookModel(db gorp.SqlExecutor, m *sdk.WorkflowHookModel) error

UpdateOutgoingHookModel updates a hook model in database

func UpdateRunNum

func UpdateRunNum(db gorp.SqlExecutor, w *sdk.Workflow, num int64) error

UpdateRunNum Update run number for the given workflow

func UpdateRunResult added in v0.52.0

func UpdateRunResult(ctx context.Context, db gorp.SqlExecutor, result *sdk.WorkflowRunResult) error

func UpdateWorkflowRun

func UpdateWorkflowRun(ctx context.Context, db gorp.SqlExecutor, wr *sdk.WorkflowRun) error

UpdateWorkflowRun updates in table "workflow_run""

func UpdateWorkflowRunStatus

func UpdateWorkflowRunStatus(db gorp.SqlExecutor, wr *sdk.WorkflowRun) error

UpdateWorkflowRunStatus update status of a workflow run

func UpdateWorkflowRunTags

func UpdateWorkflowRunTags(db gorp.SqlExecutor, r *sdk.WorkflowRun) error

UpdateWorkflowRunTags updates new tags in database

func UserFavoriteWorkflowIDs

func UserFavoriteWorkflowIDs(db gorp.SqlExecutor, uID string) ([]int64, error)

UserFavoriteWorkflowIDs returns the list of workflow ID

Types

type ArtifactSignature added in v0.53.0

type ArtifactSignature map[string]string

type ImportOptions

type ImportOptions struct {
	Force              bool
	WorkflowName       string
	FromRepository     string
	IsDefaultBranch    bool
	FromBranch         string
	VCSServer          string
	RepositoryName     string
	RepositoryStrategy sdk.RepositoryStrategy
	HookUUID           string
}

ImportOptions is option to parse a workflow

type JobRun

type JobRun struct {
	ProjectID          int64             `db:"project_id"`
	ID                 int64             `db:"id"`
	WorkflowNodeRunID  int64             `db:"workflow_node_run_id"`
	Job                sql.NullString    `db:"job"`
	Parameters         sql.NullString    `db:"variables"`
	Status             string            `db:"status"`
	Retry              int               `db:"retry"`
	Queued             time.Time         `db:"queued"`
	Start              time.Time         `db:"start"`
	Done               time.Time         `db:"done"`
	Model              string            `db:"model"`
	ExecGroups         sql.NullString    `db:"exec_groups"`
	BookedBy           sdk.BookedBy      `db:"-"`
	Region             *string           `db:"region"`
	ContainsService    bool              `db:"contains_service"`
	ModelType          sql.NullString    `db:"model_type"`
	Header             sql.NullString    `db:"header"`
	HatcheryName       string            `db:"hatchery_name"`
	WorkerName         string            `db:"worker_name"`
	IntegrationPlugins sql.NullString    `db:"integration_plugins"`
	Contexts           sdk.JobRunContext `db:"contexts"`
}

JobRun is a gorp wrapper around sdk.WorkflowNodeJobRun

func (*JobRun) ToJobRun

func (j *JobRun) ToJobRun(jr *sdk.WorkflowNodeJobRun) (err error)

ToJobRun transform the JobRun with data of the provided sdk.WorkflowNodeJobRun

func (JobRun) WorkflowNodeRunJob

func (j JobRun) WorkflowNodeRunJob() (sdk.WorkflowNodeJobRun, error)

WorkflowNodeRunJob returns a sdk.WorkflowNodeRunJob

type LoadAllWorkflowsOptionsFilters

type LoadAllWorkflowsOptionsFilters struct {
	ProjectKey                   string
	WorkflowName                 string
	VCSServer                    string
	ApplicationRepository        string
	FromRepository               string
	GroupIDs                     []int64
	WorkflowIDs                  []int64
	DisableFilterDeletedWorkflow bool
	AsCode                       bool
}

type LoadAllWorkflowsOptionsLoaders

type LoadAllWorkflowsOptionsLoaders struct {
	WithApplications       bool
	WithPipelines          bool
	WithDeepPipelines      bool
	WithEnvironments       bool
	WithIntegrations       bool
	WithIcon               bool
	WithAsCodeUpdateEvents bool
	WithTemplate           bool
	WithLabels             bool
	WithAudits             bool
	WithFavoritesForUserID string
	WithRuns               int
}

type LoadOptions

type LoadOptions struct {
	Minimal                bool
	DeepPipeline           bool
	WithLabels             bool
	WithIcon               bool
	WithAsCodeUpdateEvent  bool
	WithIntegrations       bool
	WithTemplate           bool
	WithFavoritesForUserID string
}

LoadOptions custom option for loading workflow

func (LoadOptions) GetWorkflowDAO

func (loadOpts LoadOptions) GetWorkflowDAO() WorkflowDAO

type LoadRunOptions

type LoadRunOptions struct {
	WithTests               bool
	WithLightTests          bool
	WithDeleted             bool
	DisableDetailledNodeRun bool
}

LoadRunOptions are options for loading a run (node or workflow)

type NodeRun

type NodeRun struct {
	WorkflowID             sql.NullInt64      `db:"workflow_id"`
	WorkflowRunID          int64              `db:"workflow_run_id"`
	ApplicationID          sql.NullInt64      `db:"application_id"`
	ID                     int64              `db:"id"`
	WorkflowNodeID         int64              `db:"workflow_node_id"`
	WorkflowNodeName       string             `db:"workflow_node_name"`
	Number                 int64              `db:"num"`
	SubNumber              int64              `db:"sub_num"`
	Status                 string             `db:"status"`
	Start                  time.Time          `db:"start"`
	Done                   time.Time          `db:"done"`
	LastModified           time.Time          `db:"last_modified"`
	HookEvent              sql.NullString     `db:"hook_event"`
	Manual                 sql.NullString     `db:"manual"`
	SourceNodeRuns         sql.NullString     `db:"source_node_runs"`
	Payload                sql.NullString     `db:"payload"`
	PipelineParameters     sql.NullString     `db:"pipeline_parameters"`
	BuildParameters        sql.NullString     `db:"build_parameters"`
	Tests                  sql.NullString     `db:"tests"`
	Commits                sql.NullString     `db:"commits"`
	Stages                 sql.NullString     `db:"stages"`
	TriggersRun            sql.NullString     `db:"triggers_run"`
	VCSRepository          sql.NullString     `db:"vcs_repository"`
	VCSBranch              sql.NullString     `db:"vcs_branch"`
	VCSTag                 sql.NullString     `db:"vcs_tag"`
	VCSHash                sql.NullString     `db:"vcs_hash"`
	VCSServer              sql.NullString     `db:"vcs_server"`
	Header                 sql.NullString     `db:"header"`
	UUID                   sql.NullString     `db:"uuid"`
	OutgoingHook           sql.NullString     `db:"outgoinghook"`
	HookExecutionTimestamp sql.NullInt64      `db:"hook_execution_timestamp"`
	ExecutionID            sql.NullString     `db:"execution_id"`
	Callback               sql.NullString     `db:"callback"`
	Contexts               sdk.NodeRunContext `db:"contexts"`
}

NodeRun is a gorp wrapper around sdk.WorkflowNodeRun

type Notification

type Notification sdk.WorkflowNotification

Notification is a gorp wrapper around sdk.WorkflowNotification

func (*Notification) PostGet

func (no *Notification) PostGet(db gorp.SqlExecutor) error

PostGet is a db hook

func (*Notification) PostInsert

func (no *Notification) PostInsert(db gorp.SqlExecutor) error

PostInsert is a db hook

type ProcessorReport

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

ProcessorReport represents the state of the workflow processor

func ResyncWorkflowRunStatus

func ResyncWorkflowRunStatus(ctx context.Context, db gorp.SqlExecutor, wr *sdk.WorkflowRun) (*ProcessorReport, error)

ResyncWorkflowRunStatus resync the status of workflow if you stop a node run when workflow run is building

func StopWorkflowNodeRun

func StopWorkflowNodeRun(ctx context.Context, dbFunc func() *gorp.DbMap, store cache.Store, proj sdk.Project, workflowRun sdk.WorkflowRun, workflowNodeRun sdk.WorkflowNodeRun, stopInfos sdk.SpawnInfo) (*ProcessorReport, error)

StopWorkflowNodeRun to stop a workflow node run with a specific spawn info

func TakeNodeJobRun

func TakeNodeJobRun(ctx context.Context, db gorpmapper.SqlExecutorWithTx, store cache.Store, proj sdk.Project, jobID int64,
	workerModel, workerName, workerID string, infos []sdk.SpawnInfo, hatcheryName string) (*sdk.WorkflowNodeJobRun, *ProcessorReport, error)

TakeNodeJobRun Take an a job run for update

func UpdateNodeJobRunStatus

func UpdateNodeJobRunStatus(ctx context.Context, db gorpmapper.SqlExecutorWithTx, store cache.Store, proj sdk.Project, job *sdk.WorkflowNodeJobRun, status string) (*ProcessorReport, error)

UpdateNodeJobRunStatus Update status of an workflow_node_run_job.

func UpdateOutgoingHookRunStatus

func UpdateOutgoingHookRunStatus(ctx context.Context, db gorpmapper.SqlExecutorWithTx, store cache.Store, proj sdk.Project, wr *sdk.WorkflowRun, hookRunID string, callback sdk.WorkflowNodeOutgoingHookRunCallback) (*ProcessorReport, error)

UpdateOutgoingHookRunStatus updates the status and callback of a outgoing hook run, and then it reprocess the whole workflow

func UpdateParentWorkflowRun

func UpdateParentWorkflowRun(ctx context.Context, tx gorpmapper.SqlExecutorWithTx, store cache.Store, wr *sdk.WorkflowRun, parentProj sdk.Project, parentWR *sdk.WorkflowRun) (*ProcessorReport, error)

UpdateParentWorkflowRun updates the workflow which triggered the current workflow

func (*ProcessorReport) Add

func (r *ProcessorReport) Add(ctx context.Context, i ...interface{})

Add something to the report

func (*ProcessorReport) All

func (r *ProcessorReport) All() []interface{}

All returns all the objects in the reports

func (*ProcessorReport) Errors

func (r *ProcessorReport) Errors() []error

Errors return errors

func (*ProcessorReport) Jobs

func (*ProcessorReport) Merge

func (r *ProcessorReport) Merge(ctx context.Context, r1 *ProcessorReport)

Merge to the provided report and the current report

func (*ProcessorReport) Nodes

func (r *ProcessorReport) Nodes() []sdk.WorkflowNodeRun

func (*ProcessorReport) WorkflowRuns

func (r *ProcessorReport) WorkflowRuns() []sdk.WorkflowRun

WorkflowRuns returns the list of concerned workflow runs

func (*ProcessorReport) Workflows

func (r *ProcessorReport) Workflows() []sdk.WorkflowRun

type PushOption

type PushOption struct {
	VCSServer          string
	FromRepository     string
	Branch             string
	IsDefaultBranch    bool
	RepositoryName     string
	RepositoryStrategy sdk.RepositoryStrategy
	HookUUID           string
	Force              bool
	OldWorkflow        sdk.Workflow
}

PushOption is the set of options for workflow push

type PushSecrets

type PushSecrets struct {
	ApplicationsSecrets map[int64][]sdk.Variable
	EnvironmentdSecrets map[int64][]sdk.Variable
}

func CreateFromRepository

func CreateFromRepository(ctx context.Context, db *gorp.DbMap, store cache.Store, p *sdk.Project, wf *sdk.Workflow,
	opts sdk.WorkflowRunPostHandlerOption, u sdk.AuthUserConsumer, decryptFunc keys.DecryptFunc, emailFunc keys.EmailFunc) (*PushSecrets, []sdk.Message, error)

CreateFromRepository a workflow from a repository.

func Push

Push push a workflow from cds files

func RetrieveSecrets

func RetrieveSecrets(ctx context.Context, db gorp.SqlExecutor, wf sdk.Workflow) (*PushSecrets, error)

type QueueFilter

type QueueFilter struct {
	ModelType  []string
	Rights     int
	Since      *time.Time
	Until      *time.Time
	Limit      *int
	Statuses   []string
	Regions    []string
	SkipBooked bool
}

QueueFilter contains all criteria used to fetch queue

func NewQueueFilter

func NewQueueFilter() QueueFilter

type Run

type Run sdk.WorkflowRun

Run is a gorp wrapper around sdk.WorkflowRun

func (*Run) PostInsert

func (r *Run) PostInsert(db gorp.SqlExecutor) error

PostInsert is a db hook on WorkflowRun

func (*Run) PostUpdate

func (r *Run) PostUpdate(db gorp.SqlExecutor) error

PostUpdate is a db hook on WorkflowRun

type RunTag

type RunTag sdk.WorkflowRunTag

RunTag is a gorp wrapper around sdk.WorkflowRunTag

type UpdateOptions

type UpdateOptions struct {
	DisableHookManagement bool
}

UpdateOptions is option to parse a workflow

type VCSEventMessenger

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

func (*VCSEventMessenger) SendVCSEvent

func (e *VCSEventMessenger) SendVCSEvent(ctx context.Context, db *gorp.DbMap, store cache.Store, proj sdk.Project, wr sdk.WorkflowRun, nodeRun sdk.WorkflowNodeRun, cdsUIURL string) error

type Workflow

type Workflow struct {
	sdk.Workflow
	ProjectKey string `db:"project_key"`
}

Workflow is a gorp wrapper around sdk.WorkflowData

func (*Workflow) Get

func (w *Workflow) Get() sdk.Workflow

func (*Workflow) PostGet

func (w *Workflow) PostGet(db gorp.SqlExecutor) error

PostGet is a db hook

func (*Workflow) PostInsert

func (w *Workflow) PostInsert(db gorp.SqlExecutor) error

PostInsert is a db hook

func (*Workflow) PostUpdate

func (w *Workflow) PostUpdate(db gorp.SqlExecutor) error

PostUpdate is a db hook

func (*Workflow) PreInsert

func (w *Workflow) PreInsert(db gorp.SqlExecutor) error

PreInsert is a db hook

func (*Workflow) PreUpdate

func (w *Workflow) PreUpdate(_ gorp.SqlExecutor) error

PreUpdate is a db hook

type WorkflowDAO

type WorkflowDAO struct {
	Filters   LoadAllWorkflowsOptionsFilters
	Loaders   LoadAllWorkflowsOptionsLoaders
	Offset    int
	Limit     int
	Ascending bool
	Lock      bool
}

func (WorkflowDAO) GetLoaders

func (dao WorkflowDAO) GetLoaders() []gorpmapping.GetOptionFunc

func (WorkflowDAO) Load

func (WorkflowDAO) LoadAll

func (dao WorkflowDAO) LoadAll(ctx context.Context, db gorp.SqlExecutor) (sdk.Workflows, error)

func (WorkflowDAO) Query

func (dao WorkflowDAO) Query() gorpmapping.Query

type Workflows

type Workflows []Workflow

func (Workflows) Get

func (ws Workflows) Get() sdk.Workflows

Jump to

Keyboard shortcuts

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