manager

package
v1.0.1-gitspaces-beta Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

WireSet provides a wire set for this package.

Functions

func ConvertFromDroneLine

func ConvertFromDroneLine(l *drone.Line) *livelog.Line

func ConvertFromDroneStage

func ConvertFromDroneStage(stage *drone.Stage) *types.Stage

func ConvertFromDroneStep

func ConvertFromDroneStep(step *drone.Step) *types.Step

func ConvertFromDroneSteps

func ConvertFromDroneSteps(steps []*drone.Step) []*types.Step

func ConvertToDroneBuild

func ConvertToDroneBuild(execution *types.Execution) *drone.Build

func ConvertToDroneFile

func ConvertToDroneFile(file *file.File) *client.File

func ConvertToDroneNetrc

func ConvertToDroneNetrc(netrc *Netrc) *drone.Netrc

func ConvertToDroneRepo

func ConvertToDroneRepo(repo *types.Repository, repoIsPublic bool) *drone.Repo

func ConvertToDroneSecret

func ConvertToDroneSecret(secret *types.Secret) *drone.Secret

func ConvertToDroneSecrets

func ConvertToDroneSecrets(secrets []*types.Secret) []*drone.Secret

func ConvertToDroneStage

func ConvertToDroneStage(stage *types.Stage) *drone.Stage

func ConvertToDroneStep

func ConvertToDroneStep(step *types.Step) *drone.Step

func ConvertToDroneSteps

func ConvertToDroneSteps(steps []*types.Step) []*drone.Step

func NewEmbeddedClient

func NewEmbeddedClient(
	manager ExecutionManager,
	urlProvider url.Provider,
	config *types.Config,
) client.Client

func ProvideExecutionClient

func ProvideExecutionClient(
	manager ExecutionManager,
	urlProvider url.Provider,
	config *types.Config,
) client.Client

ProvideExecutionClient provides a client implementation to interact with the execution manager. We use an embedded client here.

Types

type Config

type Config struct {
	Data string `json:"data"`
	Kind string `json:"kind"`
}

Config represents a pipeline config file.

type ExecutionContext

type ExecutionContext struct {
	Repo         *types.Repository `json:"repository"`
	RepoIsPublic bool              `json:"repository_is_public,omitempty"`
	Execution    *types.Execution  `json:"build"`
	Stage        *types.Stage      `json:"stage"`
	Secrets      []*types.Secret   `json:"secrets"`
	Config       *file.File        `json:"config"`
	Netrc        *Netrc            `json:"netrc"`
}

ExecutionContext represents the minimum amount of information required by the runner to execute a build.

type ExecutionManager

type ExecutionManager interface {
	// Request requests the next available build stage for execution.
	Request(ctx context.Context, args *Request) (*types.Stage, error)

	// Watch watches for build cancellation requests.
	Watch(ctx context.Context, executionID int64) (bool, error)

	// Accept accepts the build stage for execution.
	Accept(ctx context.Context, stage int64, machine string) (*types.Stage, error)

	// Write writes a line to the build logs.
	Write(ctx context.Context, step int64, line *livelog.Line) error

	// Details returns details about stage.
	Details(ctx context.Context, stageID int64) (*ExecutionContext, error)

	// UploadLogs uploads the full logs.
	UploadLogs(ctx context.Context, step int64, r io.Reader) error

	// BeforeStep signals the build step is about to start.
	BeforeStep(ctx context.Context, step *types.Step) error

	// AfterStep signals the build step is complete.
	AfterStep(ctx context.Context, step *types.Step) error

	// BeforeStage signals the build stage is about to start.
	BeforeStage(ctx context.Context, stage *types.Stage) error

	// AfterStage signals the build stage is complete.
	AfterStage(ctx context.Context, stage *types.Stage) error
}

ExecutionManager encapsulates complex build operations and provides a simplified interface for build runners.

func ProvideExecutionManager

func ProvideExecutionManager(
	config *types.Config,
	executionStore store.ExecutionStore,
	pipelineStore store.PipelineStore,
	urlProvider url.Provider,
	sseStreamer sse.Streamer,
	fileService file.Service,
	converterService converter.Service,
	logStore store.LogStore,
	logStream livelog.LogStream,
	checkStore store.CheckStore,
	repoStore store.RepoStore,
	scheduler scheduler.Scheduler,
	secretStore store.SecretStore,
	stageStore store.StageStore,
	stepStore store.StepStore,
	userStore store.PrincipalStore,
	publicAccess publicaccess.Service,
) ExecutionManager

ProvideExecutionManager provides an execution manager.

type Manager

type Manager struct {
	Executions       store.ExecutionStore
	Config           *types.Config
	FileService      file.Service
	ConverterService converter.Service
	Pipelines        store.PipelineStore

	Checks store.CheckStore
	// Converter  store.ConvertService
	SSEStreamer sse.Streamer
	// Globals    store.GlobalSecretStore
	Logs store.LogStore
	Logz livelog.LogStream
	// Netrcs     store.NetrcService
	Repos     store.RepoStore
	Scheduler scheduler.Scheduler
	Secrets   store.SecretStore
	// Status  store.StatusService
	Stages store.StageStore
	Steps  store.StepStore
	// System  *store.System
	Users store.PrincipalStore
	// contains filtered or unexported fields
}

Manager provides a simplified interface to the build runner so that it can more easily interact with the server.

func New

func New(
	config *types.Config,
	executionStore store.ExecutionStore,
	pipelineStore store.PipelineStore,
	urlProvider urlprovider.Provider,
	sseStreamer sse.Streamer,
	fileService file.Service,
	converterService converter.Service,
	logStore store.LogStore,
	logStream livelog.LogStream,
	checkStore store.CheckStore,
	repoStore store.RepoStore,
	scheduler scheduler.Scheduler,
	secretStore store.SecretStore,
	stageStore store.StageStore,
	stepStore store.StepStore,
	userStore store.PrincipalStore,
	publicAccess publicaccess.Service,
) *Manager

func (*Manager) Accept

func (m *Manager) Accept(_ context.Context, id int64, machine string) (*types.Stage, error)

Accept accepts the build stage for execution. It is possible for multiple agents to pull the same stage from the queue.

func (*Manager) AfterStage

func (m *Manager) AfterStage(_ context.Context, stage *types.Stage) error

AfterAll signals the build stage is complete.

func (*Manager) AfterStep

func (m *Manager) AfterStep(_ context.Context, step *types.Step) error

After signals the build step is complete.

func (*Manager) BeforeStage

func (m *Manager) BeforeStage(_ context.Context, stage *types.Stage) error

BeforeAll signals the build stage is about to start.

func (*Manager) BeforeStep

func (m *Manager) BeforeStep(_ context.Context, step *types.Step) error

Before signals the build step is about to start.

func (*Manager) Details

func (m *Manager) Details(_ context.Context, stageID int64) (*ExecutionContext, error)

Details provides details about the stage.

func (*Manager) Request

func (m *Manager) Request(ctx context.Context, args *Request) (*types.Stage, error)

Request requests the next available build stage for execution.

func (*Manager) UploadLogs

func (m *Manager) UploadLogs(ctx context.Context, step int64, r io.Reader) error

UploadLogs uploads the full logs.

func (*Manager) Watch

func (m *Manager) Watch(ctx context.Context, executionID int64) (bool, error)

Watch watches for build cancellation requests.

func (*Manager) Write

func (m *Manager) Write(ctx context.Context, step int64, line *livelog.Line) error

Write writes a line to the build logs.

type Netrc

type Netrc struct {
	Machine  string `json:"machine"`
	Login    string `json:"login"`
	Password string `json:"password"`
}

Netrc contains login and initialization information used by an automated login process.

type Request

type Request struct {
	Kind    string            `json:"kind"`
	Type    string            `json:"type"`
	OS      string            `json:"os"`
	Arch    string            `json:"arch"`
	Variant string            `json:"variant"`
	Kernel  string            `json:"kernel"`
	Labels  map[string]string `json:"labels,omitempty"`
}

Request provides filters when requesting a pending build from the queue. This allows an agent, for example, to request a build that matches its architecture and kernel.

Jump to

Keyboard shortcuts

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