runner

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 20, 2020 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTaskExists is returned when a task or
	// task name is expect to not exist but does.
	ErrTaskExists = errors.New("task exists")

	// ErrTaskNotExists is returned when a task is
	// expected to exists but doesn't.
	ErrTaskNotExists = errors.New("task does not exist")

	// ErrExecPhase is returned if the operation is not supported
	// during execution phase. That is, the TaskManager's Run()
	// method is called.
	ErrExecPhase = errors.New("operation not supported during execution phase")
)

Functions

This section is empty.

Types

type Hooker

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

Hooker allows to register before and after task execution hooks. It implements the actions.Hooker interface.

func NewHooker

func NewHooker() *Hooker

NewHooker creates and returns a new hooker.

func (*Hooker) ExecuteAfter

func (h *Hooker) ExecuteAfter(ctx context.Context, task string, actionPerformed bool, errResult error)

ExecuteAfter executes all AfterFunc that have been registered for task.

func (*Hooker) ExecuteBefore

func (h *Hooker) ExecuteBefore(ctx context.Context, task string) (context.Context, error)

ExecuteBefore executes all BeforeFunc that have been registered for task. It aborts as soon as a function returns an error.

func (*Hooker) RunAfter

func (h *Hooker) RunAfter(task string, fn actions.AfterTaskFunc) error

RunAfter registeres fn to be executed after task.

func (*Hooker) RunBefore

func (h *Hooker) RunBefore(task string, fn actions.BeforeTaskFunc) error

RunBefore registeres fn to be executed before task.

type Runner

type Runner struct {
	*TaskManager
	*Hooker
	// contains filtered or unexported fields
}

Runner executes a set of targets in order and aborts on the first error.

func NewRunner

func NewRunner(l actions.Logger, targets []deploy.Task) (*Runner, error)

NewRunner creates a new runner for the given targets.

func (*Runner) Deploy

func (r *Runner) Deploy(ctx context.Context) error

Deploy runs all deploy targets and aborts and returns the first error encountered.

type Task

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

func (*Task) Execute

func (t *Task) Execute(ctx context.Context, log actions.Logger) (bool, error)

Execute executes all actions of the task in the order they are defined. It returns true if any of the actions returned true and aborts on the first error encountered.

func (*Task) Prepare

func (t *Task) Prepare(graph actions.ExecGraph) error

Prepare calls the perpare method of each action defined in the task.

type TaskManager

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

TaskManager is responsible for managing tasks and implements the actions.TaskManager interface.

func NewTaskManager

func NewTaskManager(l actions.Logger) *TaskManager

NewTaskManager returns a new task manager.

func (*TaskManager) AddTask

func (tm *TaskManager) AddTask(name string, target deploy.Task) error

AddTask adds a new task to task manager.

func (*TaskManager) DisableTask

func (tm *TaskManager) DisableTask(task string) error

DisableTask disables a task so it won't be executed during perperation and execution phase. Once disabled, a task cannot be enabled again. Refer to the actions.TaskManager interface for more information.

func (*TaskManager) HasTask

func (tm *TaskManager) HasTask(task string) bool

HasTask returns true if task exists.

func (*TaskManager) IsAfter

func (tm *TaskManager) IsAfter(task1, task2 string) (bool, error)

IsAfter returns true if task1 is executed after task2.

func (*TaskManager) IsBefore

func (tm *TaskManager) IsBefore(task1, task2 string) (bool, error)

IsBefore returns true if task1 is executed before task2.

func (*TaskManager) IsMasked

func (tm *TaskManager) IsMasked(task string) (bool, error)

IsMasked returns true if task is masked from execution.

func (*TaskManager) MaskTask

func (tm *TaskManager) MaskTask(task string) error

MaskTask masks a task from execution.

func (*TaskManager) UnmaskTask

func (tm *TaskManager) UnmaskTask(task string) error

UnmaskTask unmasks a task for execution.

Jump to

Keyboard shortcuts

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