tools

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetScriptCache

func GetScriptCache(cacheDir, script string) (string, error)

func RunTask

func RunTask(req *TaskExecRequest) (err error)

nolint:gocyclo

Types

type Action

type Action struct {
	rs.BaseField

	// Name of this action, optional
	Name string `yaml:"name"`

	// Env specific to this action
	Env dukkha.Env `yaml:"env"`

	// Task reference of this action
	//
	// Task, Cmd, EmbeddedShell, ExternalShell are mutually exclusive
	Task string `yaml:"task"`

	// EmbeddedShell using embedded shell
	//
	// Task, Cmd, EmbeddedShell, ExternalShell are mutually exclusive
	EmbeddedShell string `yaml:"shell"`

	// EmbeddedShell script for this action
	//
	// Task, Cmd, EmbeddedShell, ExternalShell are mutually exclusive
	ExternalShell map[string]string `rs:"other"`

	// Cmd execution, not in any shell
	//
	// Task, Cmd, EmbeddedShell, ExternalShell are mutually exclusive
	Cmd []string `yaml:"cmd"`

	// Chdir change working directory before executing command
	// this option only applies to Cmd, EmbeddedShell, ExternalShell action
	Chdir string `yaml:"chdir"`

	// ContuineOnError ignores error occurred in this action and continue
	// following actions in list (if any)
	ContinueOnError bool `yaml:"continue_on_error"`
	// contains filtered or unexported fields
}

func (*Action) DoAfterFieldResolved

func (act *Action) DoAfterFieldResolved(mCtx dukkha.TaskExecContext, do func(h *Action) error) error

func (*Action) GenSpecs

func (act *Action) GenSpecs(
	ctx dukkha.TaskExecContext, index int,
) (dukkha.RunTaskOrRunCmd, error)

type BaseTask

type BaseTask struct {
	rs.BaseField

	TaskName string      `yaml:"name"`
	Env      dukkha.Env  `yaml:"env"`
	Matrix   matrix.Spec `yaml:"matrix"`
	Hooks    TaskHooks   `yaml:"hooks"`

	ContinueOnErrorFlag bool `yaml:"continue_on_error"`
	// contains filtered or unexported fields
}

func (*BaseTask) ContinueOnError

func (t *BaseTask) ContinueOnError() bool

func (*BaseTask) DoAfterFieldsResolved

func (t *BaseTask) DoAfterFieldsResolved(
	ctx dukkha.RenderingContext,
	depth int,
	do func() error,
	fieldNames ...string,
) error

func (*BaseTask) GetHookExecSpecs

func (t *BaseTask) GetHookExecSpecs(
	taskCtx dukkha.TaskExecContext,
	stage dukkha.TaskExecStage,
) ([]dukkha.RunTaskOrRunCmd, error)

func (*BaseTask) GetMatrixSpecs

func (t *BaseTask) GetMatrixSpecs(rc dukkha.RenderingContext) ([]matrix.Entry, error)

func (*BaseTask) InitBaseTask

func (t *BaseTask) InitBaseTask(
	k dukkha.ToolKind,
	n dukkha.ToolName,
	tk dukkha.TaskKind,
	impl dukkha.Task,
)

func (*BaseTask) Key

func (t *BaseTask) Key() dukkha.TaskKey

func (*BaseTask) Kind

func (t *BaseTask) Kind() dukkha.TaskKind

func (*BaseTask) Name

func (t *BaseTask) Name() dukkha.TaskName

func (*BaseTask) ToolKind

func (t *BaseTask) ToolKind() dukkha.ToolKind

func (*BaseTask) ToolName

func (t *BaseTask) ToolName() dukkha.ToolName

type BaseTool

type BaseTool struct {
	rs.BaseField

	ToolName string     `yaml:"name"`
	Env      dukkha.Env `yaml:"env"`
	Cmd      []string   `yaml:"cmd"`

	// Whether to run this tool in shell and which shell to use
	UsingShell     bool   `yaml:"use_shell"`
	UsingShellName string `yaml:"shell_name"`
	// contains filtered or unexported fields
}

func (*BaseTool) DoAfterFieldsResolved

func (t *BaseTool) DoAfterFieldsResolved(
	ctx dukkha.TaskExecContext,
	depth int,
	do func() error,
	fieldNames ...string,
) error

func (*BaseTool) GetCmd

func (t *BaseTool) GetCmd() []string

func (*BaseTool) GetEnv

func (t *BaseTool) GetEnv() dukkha.Env

func (*BaseTool) GetTask

func (t *BaseTool) GetTask(k dukkha.TaskKey) (dukkha.Task, bool)

func (*BaseTool) InitBaseTool

func (t *BaseTool) InitBaseTool(
	kind dukkha.ToolKind,
	defaultExecutable,
	cacheDir string,
	impl dukkha.Tool,
) error

InitBaseTool must be called in your own version of Init() with correct defaultExecutable name

MUST be called when in Init

func (*BaseTool) Key

func (t *BaseTool) Key() dukkha.ToolKey

func (*BaseTool) Kind

func (t *BaseTool) Kind() dukkha.ToolKind

func (*BaseTool) Name

func (t *BaseTool) Name() dukkha.ToolName

func (*BaseTool) ResolveTasks

func (t *BaseTool) ResolveTasks(tasks []dukkha.Task) error

ResolveTasks accepts all tasks, override this function if your tool need different handling of tasks

func (*BaseTool) Run

func (t *BaseTool) Run(taskCtx dukkha.TaskExecContext) error

Run task

func (*BaseTool) ShellName

func (t *BaseTool) ShellName() string

func (*BaseTool) UseShell

func (t *BaseTool) UseShell() bool

type BaseToolWithInit

type BaseToolWithInit struct {
	rs.BaseField

	BaseTool `yaml:",inline"`
}

func (*BaseToolWithInit) GetExecSpec

func (t *BaseToolWithInit) GetExecSpec(
	toExec []string, isFilePath bool,
) (env dukkha.Env, cmd []string, err error)

GetExecSpec is a helper func for shells

func (*BaseToolWithInit) Init

func (t *BaseToolWithInit) Init(kind dukkha.ToolKind, cacheDir string) error

type TaskExecRequest

type TaskExecRequest struct {
	Context dukkha.TaskExecContext

	Tool dukkha.Tool
	Task dukkha.Task

	IgnoreError bool
}

type TaskHooks

type TaskHooks struct {
	rs.BaseField

	// Before runs before the task execution start
	// if this hook failed, the whole task execution is canceled
	// and will run `After` hooks
	//
	// This hook MUST NOT have any reference to matrix information
	Before []Action `yaml:"before"`

	// Before a specific matrix execution start
	//
	// This hook May have reference to matrix information
	BeforeMatrix []Action `yaml:"before:matrix"`

	// AfterMatrixSuccess runs after a successful matrix execution
	//
	// This hook May have reference to matrix information
	AfterMatrixSuccess []Action `yaml:"after:matrix:success"`

	// AfterMatrixFailure runs after a failed matrix execution
	//
	// This hook May have reference to matrix information
	AfterMatrixFailure []Action `yaml:"after:matrix:failure"`

	// AfterMatrix runs after at any condition of the matrix execution
	// including success, failure
	//
	// This hook May have reference to matrix information
	AfterMatrix []Action `yaml:"after:matrix"`

	// AfterSuccess runs after a successful task execution
	// requires all matrix executions are successful
	//
	// This hook MUST NOT have any reference to matrix information
	AfterSuccess []Action `yaml:"after:success"`

	// AfterFailure runs after a failed task execution
	// any failed matrix execution will cause this hook to run
	//
	// This hook MUST NOT have any reference to matrix information
	AfterFailure []Action `yaml:"after:failure"`

	// After any condition of the task execution
	// including success, failure, canceled (hook `before` failure)
	//
	// This hook MUST NOT have any reference to matrix information
	After []Action `yaml:"after"`
}

func (*TaskHooks) GenSpecs

func (h *TaskHooks) GenSpecs(
	taskCtx dukkha.TaskExecContext,
	stage dukkha.TaskExecStage,
) ([]dukkha.RunTaskOrRunCmd, error)

func (*TaskHooks) GetFieldNameByStage

func (*TaskHooks) GetFieldNameByStage(stage dukkha.TaskExecStage) string

Directories

Path Synopsis
Package golang provides golang toolchain (go) support for dukkha
Package golang provides golang toolchain (go) support for dukkha

Jump to

Keyboard shortcuts

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