executor

package
v1.134.3 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MPL-2.0 Imports: 55 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrArtifactsPathOutsideWorkingDir = errors.New("path is outside of CIRRUS_WORKING_DIR")
View Source
var (
	ErrStepExit = errors.New("executor step requested to terminate execution")
)
View Source
var TimeOutError = errors.New("timed out")

Functions

func BoundedCommands added in v1.6.0

func BoundedCommands(commands []*api.Command, fromName, toName string) []*api.Command

BoundedCommands bounds a slice of commands with unique names to a half-open range [fromName, toName).

func CloneRepository added in v1.110.0

func CloneRepository(
	ctx context.Context,
	logUploader io.Writer,
	env *environment.Environment,
) bool

func ConvertAnnotations

func ConvertAnnotations(annotations []model.Annotation) []*api.Annotation

func DeduplicatePaths added in v1.15.0

func DeduplicatePaths(paths []string) (result []string)

func EnsureFolderExists

func EnsureFolderExists(path string)

func EnvMapAsSlice added in v1.68.0

func EnvMapAsSlice(env map[string]string) []string

func FetchCache

func FetchCache(
	ctx context.Context,
	logUploader *LogUploader,
	commandName string,
	cacheHost string,
	cacheKey string,
) (*os.File, time.Duration, error)

func InitializeLogSaveClient

func InitializeLogSaveClient(
	ctx context.Context,
	taskIdentification *api.TaskIdentification,
	commandName string,
	raw bool,
) (api.CirrusCIService_SaveLogsClient, error)

func InitializeLogStreamClient

func InitializeLogStreamClient(ctx context.Context, taskIdentification *api.TaskIdentification, commandName string, raw bool) (api.CirrusCIService_StreamLogsClient, error)

func ShellCommandsAndWait

func ShellCommandsAndWait(
	ctx context.Context,
	scripts []string,
	custom_env *environment.Environment,
	handler ShellOutputHandler,
	shouldKillProcesses bool,
) (*exec.Cmd, error)

return true if executed successful

func TempFileName

func TempFileName(prefix, suffix string) (*os.File, error)

func UploadCacheFile

func UploadCacheFile(ctx context.Context, cacheURL string, cacheFile *os.File) error

Types

type ArtifactUploader added in v1.95.0

type ArtifactUploader interface {
	Upload(ctx context.Context, artifact io.Reader, relativeArtifactPath string, size int64) error
	Finish(ctx context.Context) error
}

func NewGRPCUploader added in v1.95.0

func NewGRPCUploader(
	ctx context.Context,
	taskIdentification *api.TaskIdentification,
	artifacts *Artifacts,
) (ArtifactUploader, error)

func NewHTTPSUploader added in v1.95.0

func NewHTTPSUploader(
	ctx context.Context,
	taskIdentification *api.TaskIdentification,
	artifacts *Artifacts,
) (ArtifactUploader, error)

type Artifacts added in v1.95.0

type Artifacts struct {
	Name   string
	Type   string
	Format string
	// contains filtered or unexported fields
}

func NewArtifacts added in v1.95.0

func NewArtifacts(
	name string,
	artifactsInstruction *api.ArtifactsInstruction,
	customEnv *environment.Environment,
) (*Artifacts, error)

func (*Artifacts) UploadableFiles added in v1.96.0

func (artifacts *Artifacts) UploadableFiles() []*api.ArtifactFileInfo

type Cache

type Cache struct {
	Name                     string
	Key                      string
	BaseFolder               string
	PartiallyExpandedFolders []string
	FileHasher               *hasher.Hasher
	SkipUpload               bool
	CacheAvailable           bool
}

func FindCache

func FindCache(cacheName string) *Cache

type CacheAttempts added in v1.47.0

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

func NewCacheAttempts added in v1.47.0

func NewCacheAttempts() *CacheAttempts

func (*CacheAttempts) Failed added in v1.47.0

func (ca *CacheAttempts) Failed(key string, error string)

func (*CacheAttempts) Hit added in v1.47.0

func (ca *CacheAttempts) Hit(key string, size uint64, downloadedIn, extractedIn time.Duration)

func (*CacheAttempts) Miss added in v1.47.0

func (ca *CacheAttempts) Miss(key string, size uint64, archivedIn, uploadedIn time.Duration)

func (*CacheAttempts) PopulatedIn added in v1.47.0

func (ca *CacheAttempts) PopulatedIn(key string, populatedIn time.Duration)

func (*CacheAttempts) ToProto added in v1.47.0

func (ca *CacheAttempts) ToProto() map[string]*api.CacheRetrievalAttempt

type CommandAndLogs

type CommandAndLogs struct {
	Name string
	Cmd  *exec.Cmd
	Logs *LogUploader
}

type Executor

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

func NewExecutor

func NewExecutor(
	taskId int64,
	clientToken,
	serverToken string,
	commandFrom string,
	commandTo string,
	preCreatedWorkingDir string,
) *Executor

func (*Executor) CreateFile

func (executor *Executor) CreateFile(
	ctx context.Context,
	logUploader *LogUploader,
	instruction *api.FileInstruction,
	env *environment.Environment,
) bool

func (*Executor) DownloadCache added in v1.45.0

func (executor *Executor) DownloadCache(
	ctx context.Context,
	logUploader *LogUploader,
	commandName string,
	cacheHost string,
	instruction *api.CacheInstruction,
	custom_env *environment.Environment,
) bool

func (*Executor) ExecuteScriptsAndStreamLogs

func (executor *Executor) ExecuteScriptsAndStreamLogs(
	ctx context.Context,
	logUploader *LogUploader,
	scripts []string,
	env *environment.Environment,
) (*exec.Cmd, error)

func (*Executor) ExecuteScriptsStreamLogsAndWait

func (executor *Executor) ExecuteScriptsStreamLogsAndWait(
	ctx context.Context,
	logUploader *LogUploader,
	commandName string,
	scripts []string,
	env *environment.Environment) (*exec.Cmd, error)

func (*Executor) RunBuild

func (executor *Executor) RunBuild(ctx context.Context)

func (*Executor) UploadArtifacts added in v1.45.0

func (executor *Executor) UploadArtifacts(
	ctx context.Context,
	logUploader *LogUploader,
	name string,
	artifactsInstruction *api.ArtifactsInstruction,
	customEnv *environment.Environment,
) bool

func (*Executor) UploadCache added in v1.45.0

func (executor *Executor) UploadCache(
	ctx context.Context,
	logUploader *LogUploader,
	commandName string,
	cacheHost string,
	instruction *api.UploadCacheInstruction,
) bool

type GRPCUploader added in v1.95.0

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

func (*GRPCUploader) Finish added in v1.95.0

func (uploader *GRPCUploader) Finish(ctx context.Context) error

func (*GRPCUploader) Upload added in v1.95.0

func (uploader *GRPCUploader) Upload(ctx context.Context, artifact io.Reader, relativeArtifactPath string, _ int64) error

type HTTPSUploader added in v1.95.0

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

func (*HTTPSUploader) Finish added in v1.95.0

func (uploader *HTTPSUploader) Finish(ctx context.Context) error

func (*HTTPSUploader) Upload added in v1.95.0

func (uploader *HTTPSUploader) Upload(ctx context.Context, artifact io.Reader, relativeArtifactPath string, size int64) error

type InstantiateArtifactUploaderFunc added in v1.95.0

type InstantiateArtifactUploaderFunc func(
	ctx context.Context,
	taskIdentification *api.TaskIdentification,
	artifacts *Artifacts,
) (ArtifactUploader, error)

type LogUploader

type LogUploader struct {

	// Fields related to the CIRRUS_LOG_TIMESTAMP behavioral environment variable
	LogTimestamps bool
	GetTimestamp  func() time.Time
	OweTimestamp  bool
	// contains filtered or unexported fields
}

func NewLogUploader

func NewLogUploader(ctx context.Context, executor *Executor, commandName string) (*LogUploader, error)

func (*LogUploader) Finalize

func (uploader *LogUploader) Finalize()

func (*LogUploader) ReadAvailableChunks

func (uploader *LogUploader) ReadAvailableChunks() ([]byte, bool)

func (*LogUploader) StreamLogs

func (uploader *LogUploader) StreamLogs()

func (*LogUploader) UploadStoredOutput

func (uploader *LogUploader) UploadStoredOutput(ctx context.Context) error

func (*LogUploader) WithTimestamps added in v1.17.0

func (uploader *LogUploader) WithTimestamps(input []byte) []byte

func (*LogUploader) Write

func (uploader *LogUploader) Write(bytes []byte) (int, error)

func (*LogUploader) WriteChunk

func (uploader *LogUploader) WriteChunk(bytesToWrite []byte) (int, error)

type ProcessedPath added in v1.71.0

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

type ProcessedPattern added in v1.95.0

type ProcessedPattern struct {
	Pattern string
	Paths   []*ProcessedPath
}

type ShellCommands

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

func NewShellCommands added in v1.45.0

func NewShellCommands(
	ctx context.Context,
	scripts []string,
	custom_env *environment.Environment,
	handler ShellOutputHandler,
) (*ShellCommands, error)

type ShellOutputHandler

type ShellOutputHandler func(bytes []byte) (int, error)

type ShellOutputWriter

type ShellOutputWriter struct {
	io.Writer
	// contains filtered or unexported fields
}

func (ShellOutputWriter) Write

func (writer ShellOutputWriter) Write(bytes []byte) (int, error)

type StepResult added in v1.45.1

type StepResult struct {
	Success        bool
	SignaledToExit bool
	Duration       time.Duration
}

type UploadDescriptor added in v1.95.0

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

Jump to

Keyboard shortcuts

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