pipeline

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: MPL-2.0 Imports: 38 Imported by: 0

Documentation

Overview

Package pipeline implements functionality related to Phobos pipelines.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionOutput

type ActionOutput struct {
	Name  string
	Type  []byte
	Value []byte
}

ActionOutput defines an output for a pipeline action

type ActionStatusChangeEvent

type ActionStatusChangeEvent struct {
	ActionPath string
	Status     statemachine.NodeStatus
}

ActionStatusChangeEvent is an event that changes the status of a pipeline action

type ApprovalEvent

type ApprovalEvent struct {
	UserID           *string
	ServiceAccountID *string
}

ApprovalEvent is the event that approves a pipeline

type CancelPipelineEvent

type CancelPipelineEvent struct {
	Caller  auth.Caller
	Version *int
	Force   bool
}

CancelPipelineEvent is an event that cancels a pipeline

type CancelPipelineInput

type CancelPipelineInput struct {
	Version *int
	ID      string
	Force   bool
}

CancelPipelineInput is the input for deleting a pipeline

type CreatePipelineInput

type CreatePipelineInput struct {
	ParentPipelineID       *string
	ParentPipelineNodePath *string
	ReleaseID              *string
	SystemVariables        map[string]cty.Value
	EnvironmentName        *string
	VariableSetRevision    *string
	When                   models.PipelineWhenCondition
	PipelineTemplateID     string
	Type                   models.PipelineType
	Variables              []Variable
	Annotations            []*models.PipelineAnnotation
	ApprovalRuleIDs        []string
}

CreatePipelineInput is the input for creating a pipeline

type CreatePipelineJWTInput

type CreatePipelineJWTInput struct {
	Expiration time.Time
	PipelineID string
	Audience   string
}

CreatePipelineJWTInput is the input for creating a pipeline JWT

type EnvironmentGatekeeper

type EnvironmentGatekeeper interface {
	// contains filtered or unexported methods
}

EnvironmentGatekeeper implements the gatekeeper for PipelineCreate operations.

func NewEnvironmentGatekeeper

func NewEnvironmentGatekeeper(
	dbClient *db.Client,
) EnvironmentGatekeeper

NewEnvironmentGatekeeper returns an instance of environmentGatekeeper

type Event

type Event struct {
	Pipeline *models.Pipeline
	Action   string
}

Event is a pipeline event

type EventHandler

type EventHandler func(ctx context.Context, pipelineID string, changes []StatusChange, event any) error

EventHandler is a function that handles pipeline events

type ForceNestedPipelineStatusChangeEvent

type ForceNestedPipelineStatusChangeEvent struct {
	Status statemachine.NodeStatus
}

ForceNestedPipelineStatusChangeEvent is an event for forcing a nested pipeline status change

type GetPipelineApprovalsInput

type GetPipelineApprovalsInput struct {
	PipelineID   string
	NodePath     *string
	ApprovalType models.PipelineApprovalType
}

GetPipelineApprovalsInput is the input for retrieving pipeline approvals.

type GetPipelinesInput

type GetPipelinesInput struct {
	// Sort specifies the field to sort on and direction
	Sort *db.PipelineSortableField
	// PaginationOptions supports cursor based pagination
	PaginationOptions *pagination.Options
	// Started filter will only return started pipelines when true
	Started *bool
	// Completed filter will only return completed pipelines when true
	Completed *bool
	// Superseded filters the pipelines by the specified superseded status.
	Superseded *bool
	// PipelineTemplateID filters the pipelines by the specified pipeline template
	PipelineTemplateID *string
	// ParentPipelineID filters the pipelines by the specified parent pipeline
	ParentPipelineID *string
	// ParentNestedPipelineNodePath filters the pipelines by the specified parent nested pipeline node path
	ParentNestedPipelineNodePath *string
	// EnvironmentName filter will only return pipelines with the specified environment name
	EnvironmentName *string
	// ReleaseID filter will only return pipelines with the specified release ID
	ReleaseID *string
	// ProjectID filters the pipelines by the specified project.
	ProjectID string
	// PipelineType filters the pipelines by the specified pipeline types.
	PipelineTypes []models.PipelineType
}

GetPipelinesInput is the input for querying a list of pipelines

type InitializationHandler added in v0.3.0

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

InitializationHandler dictates if a pipeline node requires initialization.

func NewInitializationHandler added in v0.3.0

func NewInitializationHandler(
	logger logger.Logger,
	dbClient *db.Client,
	pipelineUpdater Updater,
	pipelineTemplateStore pipelinetemplate.DataStore,
	pipelineArtifactStore Store,
) *InitializationHandler

NewInitializationHandler returns an instance of InitializationHandler.

func (*InitializationHandler) RegisterHandlers added in v0.3.0

func (i *InitializationHandler) RegisterHandlers()

RegisterHandlers registers any handlers with the PipelineUpdater used by the InitializationHandler.

type InitializeNestedPipelineEvent added in v0.3.0

type InitializeNestedPipelineEvent struct {
	Error              error
	NestedPipelinePath string
	ApprovalRuleIDs    []string
}

InitializeNestedPipelineEvent is an event that initializes a nested pipeline

type InitializeTaskEvent added in v0.3.0

type InitializeTaskEvent struct {
	Error           error
	TaskPath        string
	ApprovalRuleIDs []string
}

InitializeTaskEvent is an event that initializes a task

type JobStatusChangeEvent

type JobStatusChangeEvent struct {
	Job *models.Job
}

JobStatusChangeEvent is an event that changes the pipeline task status based on a job status change

type MetricManager

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

MetricManager manages metrics based on the pipeline's state.

func NewMetricManager

func NewMetricManager(logger logger.Logger, dbClient *db.Client, pipelineUpdater Updater) *MetricManager

NewMetricManager returns an instance of MetricsManager.

func (*MetricManager) RegisterHandlers

func (m *MetricManager) RegisterHandlers()

RegisterHandlers registers any handlers with the PipelineUpdater used by the MetricsManager.

type MockEnvironmentGatekeeper

type MockEnvironmentGatekeeper struct {
	mock.Mock
}

MockEnvironmentGatekeeper is an autogenerated mock type for the EnvironmentGatekeeper type

func NewMockEnvironmentGatekeeper

func NewMockEnvironmentGatekeeper(t mockConstructorTestingTNewMockEnvironmentGatekeeper) *MockEnvironmentGatekeeper

NewMockEnvironmentGatekeeper creates a new instance of MockEnvironmentGatekeeper. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

type MockService

type MockService struct {
	mock.Mock
}

MockService is an autogenerated mock type for the Service type

func NewMockService

func NewMockService(t mockConstructorTestingTNewMockService) *MockService

NewMockService creates a new instance of MockService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockService) ApprovePipelineNode

func (_m *MockService) ApprovePipelineNode(ctx context.Context, input *NodeApprovalInput) error

ApprovePipelineNode provides a mock function with given fields: ctx, input

func (*MockService) CancelPipeline

func (_m *MockService) CancelPipeline(ctx context.Context, input *CancelPipelineInput) (*models.Pipeline, error)

CancelPipeline provides a mock function with given fields: ctx, input

func (*MockService) CreatePipeline

func (_m *MockService) CreatePipeline(ctx context.Context, input *CreatePipelineInput) (*models.Pipeline, error)

CreatePipeline provides a mock function with given fields: ctx, input

func (*MockService) CreatePipelineJWT

func (_m *MockService) CreatePipelineJWT(ctx context.Context, input *CreatePipelineJWTInput) ([]byte, error)

CreatePipelineJWT provides a mock function with given fields: ctx, input

func (*MockService) GetPipelineActionOutputs

func (_m *MockService) GetPipelineActionOutputs(ctx context.Context, pipelineID string, actions []string) ([]*models.PipelineActionOutput, error)

GetPipelineActionOutputs provides a mock function with given fields: ctx, pipelineID, actions

func (*MockService) GetPipelineApprovals

func (_m *MockService) GetPipelineApprovals(ctx context.Context, input *GetPipelineApprovalsInput) ([]*models.PipelineApproval, error)

GetPipelineApprovals provides a mock function with given fields: ctx, input

func (*MockService) GetPipelineByID

func (_m *MockService) GetPipelineByID(ctx context.Context, id string) (*models.Pipeline, error)

GetPipelineByID provides a mock function with given fields: ctx, id

func (*MockService) GetPipelineByPRN

func (_m *MockService) GetPipelineByPRN(ctx context.Context, prn string) (*models.Pipeline, error)

GetPipelineByPRN provides a mock function with given fields: ctx, prn

func (*MockService) GetPipelineByReleaseID

func (_m *MockService) GetPipelineByReleaseID(ctx context.Context, releaseID string) (*models.Pipeline, error)

GetPipelineByReleaseID provides a mock function with given fields: ctx, releaseID

func (*MockService) GetPipelineVariables

func (_m *MockService) GetPipelineVariables(ctx context.Context, pipelineID string) ([]Variable, error)

GetPipelineVariables provides a mock function with given fields: ctx, pipelineID

func (*MockService) GetPipelines

func (_m *MockService) GetPipelines(ctx context.Context, input *GetPipelinesInput) (*db.PipelinesResult, error)

GetPipelines provides a mock function with given fields: ctx, input

func (*MockService) GetPipelinesByIDs

func (_m *MockService) GetPipelinesByIDs(ctx context.Context, idList []string) ([]models.Pipeline, error)

GetPipelinesByIDs provides a mock function with given fields: ctx, idList

func (*MockService) RetryNestedPipeline

func (_m *MockService) RetryNestedPipeline(ctx context.Context, parentPipelineID string, parentNestedPipelineNodePath string) (*models.Pipeline, error)

RetryNestedPipeline provides a mock function with given fields: ctx, parentPipelineID, parentNestedPipelineNodePath

func (*MockService) RetryPipelineTask

func (_m *MockService) RetryPipelineTask(ctx context.Context, pipelineID string, taskPath string) (*models.Pipeline, error)

RetryPipelineTask provides a mock function with given fields: ctx, pipelineID, taskPath

func (*MockService) RevokePipelineNodeApproval

func (_m *MockService) RevokePipelineNodeApproval(ctx context.Context, input *NodeApprovalInput) error

RevokePipelineNodeApproval provides a mock function with given fields: ctx, input

func (*MockService) RunPipeline

func (_m *MockService) RunPipeline(ctx context.Context, id string) (*models.Pipeline, error)

RunPipeline provides a mock function with given fields: ctx, id

func (*MockService) RunPipelineTask

func (_m *MockService) RunPipelineTask(ctx context.Context, pipelineID string, taskPath string) (*models.Pipeline, error)

RunPipelineTask provides a mock function with given fields: ctx, pipelineID, taskPath

func (*MockService) SetPipelineActionOutputs

func (_m *MockService) SetPipelineActionOutputs(ctx context.Context, pipelineID string, actionPath string, outputs []*ActionOutput) error

SetPipelineActionOutputs provides a mock function with given fields: ctx, pipelineID, actionPath, outputs

func (*MockService) SetPipelineActionStatus

func (_m *MockService) SetPipelineActionStatus(ctx context.Context, pipelineID string, actionPath string, status statemachine.NodeStatus) error

SetPipelineActionStatus provides a mock function with given fields: ctx, pipelineID, actionPath, status

func (*MockService) SetScheduledStartForPipelineNode

func (_m *MockService) SetScheduledStartForPipelineNode(ctx context.Context, input *SetPipelineNodeScheduledStartTimeInput) (*models.Pipeline, error)

SetScheduledStartForPipelineNode provides a mock function with given fields: ctx, input

func (*MockService) SubscribeToPipeline

func (_m *MockService) SubscribeToPipeline(ctx context.Context, options *SubscribeToPipelineInput) (<-chan *Event, error)

SubscribeToPipeline provides a mock function with given fields: ctx, options

func (*MockService) SubscribeToProjectPipelines

func (_m *MockService) SubscribeToProjectPipelines(ctx context.Context, options *SubscribeToProjectPipelinesInput) (<-chan *Event, error)

SubscribeToProjectPipelines provides a mock function with given fields: ctx, options

func (*MockService) UpdateNestedPipeline

func (_m *MockService) UpdateNestedPipeline(ctx context.Context, input *UpdateNestedPipelineInput) (*models.Pipeline, error)

UpdateNestedPipeline provides a mock function with given fields: ctx, input

type MockStore

type MockStore struct {
	mock.Mock
}

MockStore is an autogenerated mock type for the Store type

func NewMockStore

func NewMockStore(t mockConstructorTestingTNewMockStore) *MockStore

NewMockStore creates a new instance of MockStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockStore) GetPipelineVariables

func (_m *MockStore) GetPipelineVariables(ctx context.Context, pipelineID string) (io.ReadCloser, error)

GetPipelineVariables provides a mock function with given fields: ctx, pipelineID

func (*MockStore) UploadPipelineVariables

func (_m *MockStore) UploadPipelineVariables(ctx context.Context, pipelineID string, body io.Reader) error

UploadPipelineVariables provides a mock function with given fields: ctx, pipelineID, body

type MockUpdater

type MockUpdater struct {
	mock.Mock
}

MockUpdater is an autogenerated mock type for the Updater type

func NewMockUpdater

func NewMockUpdater(t mockConstructorTestingTNewMockUpdater) *MockUpdater

NewMockUpdater creates a new instance of MockUpdater. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockUpdater) ProcessEvent

func (_m *MockUpdater) ProcessEvent(ctx context.Context, pipelineID string, event interface{}) (*models.Pipeline, error)

ProcessEvent provides a mock function with given fields: ctx, pipelineID, event

func (*MockUpdater) RegisterEventHandler

func (_m *MockUpdater) RegisterEventHandler(handler EventHandler)

RegisterEventHandler provides a mock function with given fields: handler

type NestedPipelineStatusChangeEvent

type NestedPipelineStatusChangeEvent struct {
	NestedPipelinePath string
	Status             statemachine.NodeStatus
}

NestedPipelineStatusChangeEvent is an event that changes the status of a nested pipeline

type NodeApprovalInput

type NodeApprovalInput struct {
	NodePath   *string
	PipelineID string
	NodeType   statemachine.NodeType
}

NodeApprovalInput is the input for approval of a pipeline node.

type RetryNestedPipelineEvent

type RetryNestedPipelineEvent struct {
	NestedPipelinePath string
	NestedPipelineID   string
}

RetryNestedPipelineEvent is an event that indicates a nested pipeline should be retried

type RetryTaskEvent

type RetryTaskEvent struct {
	TaskPath string
}

RetryTaskEvent is an event that indicates a task should be retried

type RevokeApprovalEvent

type RevokeApprovalEvent struct {
	UserID           *string
	ServiceAccountID *string
}

RevokeApprovalEvent is the event that revokes approval of a pipeline

type RunNestedPipelineEvent

type RunNestedPipelineEvent struct {
	NestedPipelinePath string
}

RunNestedPipelineEvent is an event that indicates a nested pipeline is ready to be run

type RunPipelineEvent

type RunPipelineEvent struct{}

RunPipelineEvent is an event that starts a pipeline

type RunTaskEvent

type RunTaskEvent struct {
	TaskPath string
}

RunTaskEvent is an event that indicates a task is ready to be run

type ScheduleNestedPipelineEvent

type ScheduleNestedPipelineEvent struct {
	ScheduledStartTime *time.Time
	NestedPipelinePath string
}

ScheduleNestedPipelineEvent is an event that schedules a nested pipeline

type ScheduleTaskEvent

type ScheduleTaskEvent struct {
	ScheduledStartTime *time.Time
	TaskPath           string
}

ScheduleTaskEvent is an event that schedules a task

type Service

type Service interface {
	GetPipelineByID(ctx context.Context, id string) (*models.Pipeline, error)
	GetPipelineByReleaseID(ctx context.Context, releaseID string) (*models.Pipeline, error)
	GetPipelineByPRN(ctx context.Context, prn string) (*models.Pipeline, error)
	GetPipelinesByIDs(ctx context.Context, idList []string) ([]models.Pipeline, error)
	GetPipelines(ctx context.Context, input *GetPipelinesInput) (*db.PipelinesResult, error)
	GetPipelineVariables(ctx context.Context, pipelineID string) ([]Variable, error)
	CreatePipeline(ctx context.Context, input *CreatePipelineInput) (*models.Pipeline, error)
	CancelPipeline(ctx context.Context, input *CancelPipelineInput) (*models.Pipeline, error)
	SubscribeToPipeline(ctx context.Context, options *SubscribeToPipelineInput) (<-chan *Event, error)
	SubscribeToProjectPipelines(ctx context.Context, options *SubscribeToProjectPipelinesInput) (<-chan *Event, error)
	ApprovePipelineNode(ctx context.Context, input *NodeApprovalInput) error
	RevokePipelineNodeApproval(ctx context.Context, input *NodeApprovalInput) error
	SetPipelineActionStatus(ctx context.Context, pipelineID string, actionPath string, status statemachine.NodeStatus) error
	SetPipelineActionOutputs(ctx context.Context, pipelineID string, actionPath string, outputs []*ActionOutput) error
	GetPipelineActionOutputs(ctx context.Context, pipelineID string, actions []string) ([]*models.PipelineActionOutput, error)
	GetPipelineApprovals(ctx context.Context, input *GetPipelineApprovalsInput) ([]*models.PipelineApproval, error)
	CreatePipelineJWT(ctx context.Context, input *CreatePipelineJWTInput) ([]byte, error)
	RetryPipelineTask(ctx context.Context, pipelineID string, taskPath string) (*models.Pipeline, error)
	RunPipelineTask(ctx context.Context, pipelineID string, taskPath string) (*models.Pipeline, error)
	RunPipeline(ctx context.Context, id string) (*models.Pipeline, error)
	RetryNestedPipeline(ctx context.Context, parentPipelineID, parentNestedPipelineNodePath string) (*models.Pipeline, error)
	UpdateNestedPipeline(ctx context.Context, input *UpdateNestedPipelineInput) (*models.Pipeline, error)
	SetScheduledStartForPipelineNode(ctx context.Context, input *SetPipelineNodeScheduledStartTimeInput) (*models.Pipeline, error)
}

Service implements all pipeline related functionality

func NewService

func NewService(
	logger logger.Logger,
	dbClient *db.Client,
	limitChecker limits.LimitChecker,
	dataStore pipelinetemplate.DataStore,
	store Store,
	pipelineUpdater Updater,
	eventManager *events.EventManager,
	activityService activityevent.Service,
	idp *auth.IdentityProvider,
	environmentService environment.Service,
	environmentGateKeeper EnvironmentGatekeeper,
) Service

NewService returns an instance of Service maxNestedPipelineLevel is set here to the constant so that callers don't need to know the value but unit tests can override.

type SetPipelineNodeScheduledStartTimeInput

type SetPipelineNodeScheduledStartTimeInput struct {
	ScheduledStartTime *time.Time
	PipelineID         string
	NodeType           statemachine.NodeType
	NodePath           string
}

SetPipelineNodeScheduledStartTimeInput is the input for setting the scheduled start time for a pipeline node. A nil value for ScheduledStartTime will remove the scheduled start time.

type StatusChange

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

StatusChange is a struct that contains the status changes for the specified pipeline

type Store

type Store interface {
	UploadPipelineVariables(ctx context.Context, pipelineID string, body io.Reader) error
	GetPipelineVariables(ctx context.Context, pipelineID string) (io.ReadCloser, error)
}

Store interface encapsulates the logic for saving pipeline artifacts

func NewStore

func NewStore(objectStore objectstore.ObjectStore) Store

NewStore creates an instance of the Store interface

type SubscribeToPipelineInput

type SubscribeToPipelineInput struct {
	LastSeenVersion *string
	PipelineID      string
}

SubscribeToPipelineInput is the input for subscribing to a single pipeline

type SubscribeToProjectPipelinesInput

type SubscribeToProjectPipelinesInput struct {
	ProjectID string
}

SubscribeToProjectPipelinesInput is the input for subscribing to a project's pipelines

type Supervisor

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

Supervisor is responsible for managing pipelines

func NewSupervisor

func NewSupervisor(pipelineUpdater Updater, dbClient *db.Client, eventManager *events.EventManager, logger logger.Logger) *Supervisor

NewSupervisor creates a new pipeline Supervisor

func (*Supervisor) Start

func (s *Supervisor) Start(ctx context.Context)

Start starts the pipeline Supervisor

type TaskApprovalEvent

type TaskApprovalEvent struct {
	UserID           *string
	ServiceAccountID *string
	TaskPath         string
}

TaskApprovalEvent is an event that approves a pipeline task

type TaskRevokeApprovalEvent

type TaskRevokeApprovalEvent struct {
	UserID           *string
	ServiceAccountID *string
	TaskPath         string
}

TaskRevokeApprovalEvent is an event that revokes approval of a pipeline task

type ToDoItemManager

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

ToDoItemManager manages todo items based on a pipeline's state.

func NewToDoItemManager

func NewToDoItemManager(logger logger.Logger, dbClient *db.Client, pipelineUpdater Updater, emailClient email.Client) *ToDoItemManager

NewToDoItemManager returns an instance of ToDoItemManager.

func (*ToDoItemManager) RegisterHandlers

func (t *ToDoItemManager) RegisterHandlers()

RegisterHandlers registers any handlers with the PipelineUpdater used by the TodoItemManager.

type UpdateNestedPipelineEvent

type UpdateNestedPipelineEvent struct {
	NestedPipelinePath   string
	NestedPipelineID     string
	SupersededPipelineID string
}

UpdateNestedPipelineEvent is an event that indicates a nested pipeline should be updated

type UpdateNestedPipelineInput

type UpdateNestedPipelineInput struct {
	ParentPipelineID       string
	ParentPipelineNodePath string
	PipelineTemplateID     *string
	Variables              []Variable
}

UpdateNestedPipelineInput is the input for updating a nested pipeline

type UpdatePipelineTimestampEvent

type UpdatePipelineTimestampEvent struct {
	CompletedTimestamp *time.Time
	StartedTimestamp   *time.Time
}

UpdatePipelineTimestampEvent is an event that updates the timestamps of a pipeline

type Updater

type Updater interface {
	RegisterEventHandler(handler EventHandler)
	ProcessEvent(ctx context.Context, pipelineID string, event any) (*models.Pipeline, error)
}

Updater manages the execution of a pipeline

func NewUpdater

func NewUpdater(dbClient *db.Client, logger logger.Logger) Updater

NewUpdater creates a pipeline updater to manage the execution of pipelines

type Variable

type Variable struct {
	Value    string                  `json:"value"`
	Key      string                  `json:"key"`
	Category models.VariableCategory `json:"category"`
}

Variable is a pipeline variable

Jump to

Keyboard shortcuts

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