executor

package
v0.23.3 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Overview

Package executor provides the ability for Vela to integrate with different supported operating systems.

Usage:

import "github.com/go-vela/worker/executor"

Index

Constants

This section is empty.

Variables

View Source
var Flags = []cli.Flag{

	&cli.StringFlag{
		EnvVars:  []string{"VELA_EXECUTOR_DRIVER", "EXECUTOR_DRIVER"},
		FilePath: "/vela/executor/driver",
		Name:     "executor.driver",
		Usage:    "driver to be used for the executor",
		Value:    constants.DriverLinux,
	},
	&cli.UintFlag{
		EnvVars:  []string{"VELA_EXECUTOR_MAX_LOG_SIZE", "EXECUTOR_MAX_LOG_SIZE"},
		FilePath: "/vela/executor/max_log_size",
		Name:     "executor.max_log_size",
		Usage:    "maximum log size (in bytes)",
	},
	&cli.DurationFlag{
		EnvVars: []string{"WORKER_LOG_STREAMING_TIMEOUT", "VELA_LOG_STREAMING_TIMEOUT", "LOG_STREAMING_TIMEOUT"},
		Name:    "executor.log_streaming_timeout",
		Usage:   "maximum amount of time to wait for log streaming after build completes",
		Value:   5 * time.Minute,
	},
	&cli.BoolFlag{
		EnvVars:  []string{"VELA_EXECUTOR_ENFORCE_TRUSTED_REPOS", "EXECUTOR_ENFORCE_TRUSTED_REPOS"},
		FilePath: "/vela/executor/enforce_trusted_repos",
		Name:     "executor.enforce-trusted-repos",
		Usage:    "enforce trusted repo restrictions for privileged images",
		Value:    true,
	},
}

Flags represents all supported command line interface (CLI) flags for the executor.

https://pkg.go.dev/github.com/urfave/cli#Flag

Functions

func WithContext added in v0.11.0

func WithContext(c context.Context, e Engine) context.Context

WithContext inserts the executor Engine into the context.Context.

func WithGinContext added in v0.11.0

func WithGinContext(c *gin.Context, e Engine)

WithGinContext inserts the executor Engine into the gin.Context.

Types

type Engine

type Engine interface {

	// Driver defines a function that outputs
	// the configured executor driver.
	Driver() string

	// GetBuild defines a function for the API
	// that gets the current build in execution.
	GetBuild() (*library.Build, error)
	// GetPipeline defines a function for the API
	// that gets the current pipeline in execution.
	GetPipeline() (*pipeline.Build, error)
	// GetRepo defines a function for the API
	// that gets the current repo in execution.
	GetRepo() (*library.Repo, error)
	// CancelBuild defines a function for the API
	// that Cancels the current build in execution.
	CancelBuild() (*library.Build, error)

	// CreateBuild defines a function that
	// configures the build for execution.
	CreateBuild(context.Context) error
	// PlanBuild defines a function that
	// handles the resource initialization process
	// for the build.
	PlanBuild(context.Context) error
	// AssembleBuild defines a function that
	// prepares the containers within a build
	// for execution.
	AssembleBuild(context.Context) error
	// ExecBuild defines a function that
	// runs a pipeline for a build.
	ExecBuild(context.Context) error
	// StreamBuild defines a function that receives a StreamRequest
	// and then runs StreamService or StreamStep in a goroutine.
	StreamBuild(context.Context) error
	// DestroyBuild defines a function that
	// cleans up the build after execution.
	DestroyBuild(context.Context) error

	// CreateService defines a function that
	// configures the service for execution.
	CreateService(context.Context, *pipeline.Container) error
	// PlanService defines a function that
	// prepares the service for execution.
	PlanService(context.Context, *pipeline.Container) error
	// ExecService defines a function that
	// runs a service.
	ExecService(context.Context, *pipeline.Container) error
	// StreamService defines a function that
	// tails the output for a service.
	StreamService(context.Context, *pipeline.Container) error
	// DestroyService defines a function that
	// cleans up the service after execution.
	DestroyService(context.Context, *pipeline.Container) error

	// CreateStage defines a function that
	// configures the stage for execution.
	CreateStage(context.Context, *pipeline.Stage) error
	// PlanStage defines a function that
	// prepares the stage for execution.
	PlanStage(context.Context, *pipeline.Stage, *sync.Map) error
	// ExecStage defines a function that
	// runs a stage.
	ExecStage(context.Context, *pipeline.Stage, *sync.Map) error
	// DestroyStage defines a function that
	// cleans up the stage after execution.
	DestroyStage(context.Context, *pipeline.Stage) error

	// CreateStep defines a function that
	// configures the step for execution.
	CreateStep(context.Context, *pipeline.Container) error
	// PlanStep defines a function that
	// prepares the step for execution.
	PlanStep(context.Context, *pipeline.Container) error
	// ExecStep defines a function that
	// runs a step.
	ExecStep(context.Context, *pipeline.Container) error
	// StreamStep defines a function that
	// tails the output for a step.
	StreamStep(context.Context, *pipeline.Container) error
	// DestroyStep defines a function that
	// cleans up the step after execution.
	DestroyStep(context.Context, *pipeline.Container) error
}

Engine represents the interface for Vela integrating with the different supported operating systems.

func FromContext

func FromContext(c context.Context) Engine

FromContext retrieves the executor Engine from the context.Context.

func FromGinContext added in v0.11.0

func FromGinContext(c *gin.Context) Engine

FromGinContext retrieves the executor Engine from the gin.Context.

func New added in v0.11.0

func New(s *Setup) (Engine, error)

New creates and returns a Vela engine capable of integrating with the configured executor.

Currently the following executors are supported:

* linux * local .

type Setup added in v0.11.0

type Setup struct {
	// https://pkg.go.dev/github.com/sirupsen/logrus#Entry
	Logger *logrus.Entry

	// Mock should only be true for tests.
	Mock bool

	// specifies the executor driver to use
	Driver string
	// specifies the maximum log size
	MaxLogSize uint
	// specifies how long to wait after the build finishes
	// for log streaming to complete
	LogStreamingTimeout time.Duration
	// specifies a list of privileged images to use
	PrivilegedImages []string
	// configuration for enforcing that only trusted repos may run privileged images
	EnforceTrustedRepos bool
	// specifies the executor hostname
	Hostname string
	// specifies the executor version
	Version string
	// API client for sending requests to Vela
	Client *vela.Client
	// engine used for creating runtime resources
	Runtime runtime.Engine

	// resource for storing build information in Vela
	Build *library.Build
	// resource for storing pipeline information in Vela
	Pipeline *pipeline.Build
	// resource for storing repo information in Vela
	Repo *library.Repo
	// resource for storing user information in Vela
	User *library.User
}

Setup represents the configuration necessary for creating a Vela engine capable of integrating with a configured executor.

func (*Setup) Darwin added in v0.11.0

func (s *Setup) Darwin() (Engine, error)

Darwin creates and returns a Vela engine capable of integrating with a Darwin executor.

func (*Setup) Linux added in v0.11.0

func (s *Setup) Linux() (Engine, error)

Linux creates and returns a Vela engine capable of integrating with a Linux executor.

func (*Setup) Local added in v0.11.0

func (s *Setup) Local() (Engine, error)

Local creates and returns a Vela engine capable of integrating with a local executor.

func (*Setup) Validate added in v0.11.0

func (s *Setup) Validate() error

Validate verifies the necessary fields for the provided configuration are populated correctly.

func (*Setup) Windows added in v0.11.0

func (s *Setup) Windows() (Engine, error)

Windows creates and returns a Vela engine capable of integrating with a Windows executor.

Directories

Path Synopsis
Package linux provides the ability for Vela to integrate with a Linux as an operating system.
Package linux provides the ability for Vela to integrate with a Linux as an operating system.
Package local provides the ability for Vela to integrate with the local system.
Package local provides the ability for Vela to integrate with the local system.

Jump to

Keyboard shortcuts

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