Documentation ¶
Index ¶
- type ExecutionContext
- type ExecutionContextOption
- type Opts
- type Runner
- type TaskCompiler
- type TaskRunner
- func (r *TaskRunner) Cancel()
- func (r *TaskRunner) Finish()
- func (r *TaskRunner) Run(t *task.Task) error
- func (r *TaskRunner) SetContexts(contexts map[string]*ExecutionContext) *TaskRunner
- func (r *TaskRunner) SetVariables(vars variables.Container) *TaskRunner
- func (r *TaskRunner) WithVariable(key, value string) *TaskRunner
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExecutionContext ¶
type ExecutionContext struct { Executable *utils.Binary Dir string Env variables.Container Variables variables.Container Quote string // contains filtered or unexported fields }
ExecutionContext allow you to set up execution environment, variables, binary which will run your task, up/down commands etc.
func DefaultContext ¶
func DefaultContext() *ExecutionContext
DefaultContext creates default ExecutionContext instance
func NewExecutionContext ¶
func NewExecutionContext(executable *utils.Binary, dir string, env variables.Container, up, down, before, after []string, options ...ExecutionContextOption) *ExecutionContext
NewExecutionContext creates new ExecutionContext instance
func (*ExecutionContext) After ¶
func (c *ExecutionContext) After() error
After executes tasks defined to run after every usage of the context
func (*ExecutionContext) Before ¶
func (c *ExecutionContext) Before() error
Before executes tasks defined to run before every usage of the context
func (*ExecutionContext) Down ¶
func (c *ExecutionContext) Down()
Down executes tasks defined to run once after last usage of the context
func (*ExecutionContext) Up ¶
func (c *ExecutionContext) Up() error
Up executes tasks defined to run once before first usage of the context
type ExecutionContextOption ¶ added in v1.2.1
type ExecutionContextOption func(c *ExecutionContext)
ExecutionContextOption is a functional option to configure ExecutionContext
func WithQuote ¶ added in v1.2.1
func WithQuote(quote string) ExecutionContextOption
WithQuote is functional option to set Quote for ExecutionContext
type Opts ¶
type Opts func(*TaskRunner)
Opts is a task runner configuration function.
func WithContexts ¶
func WithContexts(contexts map[string]*ExecutionContext) Opts
WithContexts adds provided contexts to task runner
func WithVariables ¶
WithVariables adds provided variables to task runner
type TaskCompiler ¶ added in v1.0.6
type TaskCompiler struct {
// contains filtered or unexported fields
}
TaskCompiler compiles tasks into jobs for executor
func NewTaskCompiler ¶ added in v1.0.6
func NewTaskCompiler() *TaskCompiler
NewTaskCompiler create new TaskCompiler instance
func (*TaskCompiler) CompileCommand ¶ added in v1.0.6
func (tc *TaskCompiler) CompileCommand( command string, executionCtx *ExecutionContext, dir string, timeout *time.Duration, stdin io.Reader, stdout, stderr io.Writer, env, vars variables.Container, ) (*executor.Job, error)
CompileCommand compiles command into Job
func (*TaskCompiler) CompileTask ¶ added in v1.0.6
func (tc *TaskCompiler) CompileTask(t *task.Task, executionContext *ExecutionContext, stdin io.Reader, stdout, stderr io.Writer, env, vars variables.Container) (*executor.Job, error)
CompileTask compiles task into Job (linked list of commands) executed by Executor
type TaskRunner ¶
type TaskRunner struct { Executor executor.Executor DryRun bool Stdin io.Reader Stdout, Stderr io.Writer OutputFormat string // contains filtered or unexported fields }
TaskRunner run tasks
func NewTaskRunner ¶
func NewTaskRunner(opts ...Opts) (*TaskRunner, error)
NewTaskRunner creates new TaskRunner instance
func (*TaskRunner) Run ¶
func (r *TaskRunner) Run(t *task.Task) error
Run run provided task. TaskRunner first compiles task into linked list of Jobs, then passes those jobs to Executor
Example ¶
t := taskpkg.FromCommands("go fmt ./...", "go build ./..") r, err := NewTaskRunner() if err != nil { return } err = r.Run(t) if err != nil { fmt.Println(err, t.ExitCode, t.ErrorMessage()) } fmt.Println(t.Output())
Output:
func (*TaskRunner) SetContexts ¶
func (r *TaskRunner) SetContexts(contexts map[string]*ExecutionContext) *TaskRunner
SetContexts sets task runner's contexts
func (*TaskRunner) SetVariables ¶
func (r *TaskRunner) SetVariables(vars variables.Container) *TaskRunner
SetVariables sets task runner's variables
func (*TaskRunner) WithVariable ¶
func (r *TaskRunner) WithVariable(key, value string) *TaskRunner
WithVariable adds variable to task runner's variables list. It creates new instance of variables container.