runner

package
v0.0.0-...-de93790 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 24 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunAll

func RunAll(ctx context.Context, params *RunAllParams) error

RunAll executes all plans and features in parallel

Types

type Command

type Command []string

Command contains a list of arguments for a given command

type CommandGroup

type CommandGroup struct {
	Image      string    // Image to pull and run commands in. Ignored if BuildContext is set.
	Entrypoint Command   // Entrypoint to run in container. Only used if BuildContext or Image is set.
	Commands   []Command // Commands to run
}

CommandGroup describes how to run a set of [Command]s. Commands run in a container if Image or BuildContext is set. Otherwise, commands run in a local shell.

type EnvironmentConfiguration

type EnvironmentConfiguration struct {
	Env        map[string]string // map of environment variables to set
	Stdout     io.Writer         // where to send stdout to
	Stderr     io.Writer         // where to send stderr to
	WorkingDir string            // working directory to run commands from
	FileMaps   []*FileMap        // FileMaps to make available to commands
	Reuse      bool              // if true, reuse the same environment between executions
}

EnvironmentConfiguration describes an environment to run commands in

type ExecutionType

type ExecutionType string

ExecutionType allows the caller to force shell or docker execution of the action

const (
	// ExecutionTypeShell configures commands to run in a local shell
	ExecutionTypeShell ExecutionType = "shell"
	// ExecutionTypeDocker configures commands to run in a Docker container
	ExecutionTypeDocker ExecutionType = "docker"
	// ExecutionTypeFinch configures commands to run in a Finch container
	ExecutionTypeFinch ExecutionType = "finch"
)

func DefaultExecutionType

func DefaultExecutionType() ExecutionType

DefaultExecutionType determines the appropriate default

type Feature

type Feature func(ctx context.Context, plan Plan, execution PlanExecutor) error

Feature applies a feature to a run plan before and/or after the execution

type FeaturesProvider

type FeaturesProvider interface {
	Features(Plan) ([]Feature, error)
}

FeaturesProvider returns a list of [Feature]s for a given Plan

type FileMap

type FileMap struct {
	SourcePath string //
	TargetPath string
	Type       FileMapType
}

FileMap describes a mapping between a source path and a target path in the command runner

type FileMapType

type FileMapType string

FileMapType describes the type of FileMap. Valid values are copy and mount.

const (
	// FileMapTypeCopyInWithGitignore copies files, excluding the .gitignore files
	FileMapTypeCopyInWithGitignore FileMapType = "copy_in_with_gitignore"
	// FileMapTypeCopyIn copies files
	FileMapTypeCopyIn FileMapType = "copy_in"
	// FileMapTypeBind mounts a directory
	FileMapTypeBind FileMapType = "bind"
	// FileMapTypeCopyOut copies files out of a container
	FileMapTypeCopyOut FileMapType = "copy_out"
)

type MockPlan

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

MockPlan provides a mock plan

func (*MockPlan) AddCommandGroup

func (mp *MockPlan) AddCommandGroup(commandGroups ...*CommandGroup) *MockPlan

AddCommandGroup provides access to add a new commandGroup

func (*MockPlan) AddDependsOn

func (mp *MockPlan) AddDependsOn(dependencies ...string)

AddDependsOn provides access to add a new dependency

func (*MockPlan) CommandGroups

func (mp *MockPlan) CommandGroups() []*CommandGroup

CommandGroups provides access to the [CommandGroups] for this plan

func (*MockPlan) DependsOn

func (mp *MockPlan) DependsOn() []string

DependsOn provides access to the [DependsOn] for this plan

func (*MockPlan) EnvironmentConfiguration

func (mp *MockPlan) EnvironmentConfiguration() *EnvironmentConfiguration

EnvironmentConfiguration provides access to the [EnviromentConfiguration] for this plan

func (*MockPlan) ID

func (mp *MockPlan) ID() string

ID provides access to the ID for this plan

func (*MockPlan) WithID

func (mp *MockPlan) WithID(id string) *MockPlan

WithID allows you to configure the ID of this plan

type MockPlanExecutor

type MockPlanExecutor struct {
	mock.Mock
	// contains filtered or unexported fields
}

MockPlanExecutor provides a mechanism to test Feature execution

func (*MockPlanExecutor) Execute

func (m *MockPlanExecutor) Execute(ctx context.Context, feature Feature) error

Execute executes the provided feature with the provided plan

func (*MockPlanExecutor) OnExecute

func (m *MockPlanExecutor) OnExecute(ctx interface{}) *mock.Call

OnExecute provides a mechanism to mock the call to Execute()

func (*MockPlanExecutor) WithExecutor

func (m *MockPlanExecutor) WithExecutor(executor common.Executor) *MockPlanExecutor

WithExecutor allows you to test a feature with a given executor providing behaviors wrapped by the Feature

func (*MockPlanExecutor) WithPlan

func (m *MockPlanExecutor) WithPlan(plan Plan) *MockPlanExecutor

WithPlan uses the provided plan during execution

type Plan

type Plan interface {
	EnvironmentConfiguration() *EnvironmentConfiguration
	CommandGroups() []*CommandGroup
	ID() string
	DependsOn() []string
	AddDependsOn(...string)
}

Plan describes how the [Runner] should run

type PlanExecutor

type PlanExecutor func(ctx context.Context) error

PlanExecutor describes the execution argument passed to a Feature

type PlansProvider

type PlansProvider interface {
	Plans(ctx context.Context) ([]Plan, error)
}

PlansProvider returns a list of [Plan]s

type RunAllParams

type RunAllParams struct {
	Namespace     string           // namespace for this execution
	Plans         PlansProvider    // provider for the list of plans to run
	Features      FeaturesProvider // provider for the features to apply to each plan
	Concurrency   int              // number of plans to run concurrently
	ExecutionType ExecutionType    // executor to use for running commands
}

RunAllParams contains the input parameters for the RunAll function

Jump to

Keyboard shortcuts

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