manager

package
v0.0.0-...-e99cc0b Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildManager

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

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

	// Netrc returns a valid netrc for execution.
	Netrc(ctx context.Context, repo int64) (*core.Netrc, error)

	// Details fetches build details
	Details(ctx context.Context, stage int64) (*Context, error)

	// Before signals the build step is about to start.
	Before(ctxt context.Context, step *core.Step) error

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

	// Before signals the build stage is about to start.
	BeforeAll(ctxt context.Context, stage *core.Stage) error

	// After signals the build stage is complete.
	AfterAll(ctx context.Context, stage *core.Stage) error

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

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

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

	// UploadBytes uploads the full logs
	UploadBytes(ctx context.Context, step int64, b []byte) error
}

BuildManager encapsulets complex build operations and provides a simplified interface for build runners.

func New

func New(
	builds core.BuildStore,
	config core.ConfigService,
	converter core.ConvertService,
	events core.Pubsub,
	logs core.LogStore,
	logz core.LogStream,
	netrcs core.NetrcService,
	repos core.RepositoryStore,
	scheduler core.Scheduler,
	secrets core.SecretStore,
	globals core.GlobalSecretStore,
	status core.StatusService,
	stages core.StageStore,
	steps core.StepStore,
	system *core.System,
	users core.UserStore,
	webhook core.WebhookSender,
) BuildManager

New returns a new Manager.

type Context

type Context struct {
	Repo    *core.Repository `json:"repository"`
	Build   *core.Build      `json:"build"`
	Stage   *core.Stage      `json:"stage"`
	Config  *core.File       `json:"config"`
	Secrets []*core.Secret   `json:"secrets"`
	System  *core.System     `json:"system"`
}

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

type Manager

type Manager struct {
	Builds    core.BuildStore
	Config    core.ConfigService
	Converter core.ConvertService
	Events    core.Pubsub
	Globals   core.GlobalSecretStore
	Logs      core.LogStore
	Logz      core.LogStream
	Netrcs    core.NetrcService
	Repos     core.RepositoryStore
	Scheduler core.Scheduler
	Secrets   core.SecretStore
	Status    core.StatusService
	Stages    core.StageStore
	Steps     core.StepStore
	System    *core.System
	Users     core.UserStore
	Webhook   core.WebhookSender
}

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

func (*Manager) Accept

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

Accept accepts the build stage for execution. It is possible for multiple agents to pull the same stage from the queue. The system uses optimistic locking at the database-level to prevent multiple agents from executing the same stage.

func (*Manager) After

func (m *Manager) After(ctx context.Context, step *core.Step) error

After signals the build step is complete.

func (*Manager) AfterAll

func (m *Manager) AfterAll(ctx context.Context, stage *core.Stage) error

AfterAll signals the build stage is complete.

func (*Manager) Before

func (m *Manager) Before(ctx context.Context, step *core.Step) error

Before signals the build step is about to start.

func (*Manager) BeforeAll

func (m *Manager) BeforeAll(ctx context.Context, stage *core.Stage) error

BeforeAll signals the build stage is about to start.

func (*Manager) Details

func (m *Manager) Details(ctx context.Context, id int64) (*Context, error)

Details fetches build details.

func (*Manager) Netrc

func (m *Manager) Netrc(ctx context.Context, id int64) (*core.Netrc, error)

Netrc returns netrc file with a valid, non-expired token that can be used to clone the repository.

func (*Manager) Request

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

Request requests the next available build stage for execution.

func (*Manager) Upload

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

Upload uploads the full logs.

func (*Manager) UploadBytes

func (m *Manager) UploadBytes(ctx context.Context, step int64, data []byte) error

UploadBytes uploads the full logs.

func (*Manager) Watch

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

Watch watches for build cancellation requests.

func (*Manager) Write

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

Write writes a line to the build logs.

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 provildes 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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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