tools

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2021 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTaskMatrixContext added in v0.4.0

CreateTaskMatrixContext creates a per matrix entry task exec options with context resolved

func GetScriptCache

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

func ResolveActions added in v0.5.0

func ResolveActions(
	rc dukkha.TaskExecContext,
	x dukkha.Resolvable,
	actionsFieldName string,
	actionsTagName string,
	options dukkha.TaskMatrixExecOptions,
) ([]dukkha.TaskExecSpec, error)

func RunTask

func RunTask(req *TaskExecRequest) (err error)

nolint:gocyclo

Types

type Action

type Action struct {
	rs.BaseField `yaml:"-"`

	// Name of this action
	//
	// if set, can be used as value for `Next`
	//
	// Defaults to `#i` where i is the index of this action in slice (starting from 0)
	//
	// this field MUST NOT use any kind of rendering suffix, or will be set
	// to default
	Name string `yaml:"name"`

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

	// Idle does nothing but serves as a placeholder for preparation purpose
	// recommended usage of Idle action is to apply renderers like `template`
	// to do some task execution state related operation (e.g. set global
	// value with `dukkha.SetValue`)
	Idle interface{} `yaml:"idle,omitempty"`

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

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

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

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

	// 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"`

	// Next action name
	// NOTE: this field is resolved after execution finished (right before leaving this action)
	//
	// Defaults to the next action in the same list
	Next *string `yaml:"next"`
	// contains filtered or unexported fields
}

Action is a collection of all kinds of work can be done in a single step but only one kind of work is allowed in a single step

func (*Action) DoAfterFieldResolved

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

func (*Action) GenSpecs

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

type Actions added in v0.5.0

type Actions []*Action

type BaseTask

type BaseTask struct {
	rs.BaseField `yaml:"-"`

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

	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,
	resolveEnv bool,
	do func() error,
	tagNames ...string,
) error

func (*BaseTask) GetHookExecSpecs

func (t *BaseTask) GetHookExecSpecs(
	taskCtx dukkha.TaskExecContext,
	stage dukkha.TaskExecStage,
) ([]dukkha.TaskExecSpec, 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 `yaml:"-"`

	ToolName dukkha.ToolName `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) AllTasks added in v0.4.0

func (t *BaseTool) AllTasks() map[dukkha.TaskKey]dukkha.Task

func (*BaseTool) DoAfterFieldsResolved

func (t *BaseTool) DoAfterFieldsResolved(
	ctx dukkha.RenderingContext,
	depth int,
	resolveEnv bool,
	do func() error,
	tagNames ...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

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 `yaml:"-"`

	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 `yaml:"-"`

	// 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 Actions `yaml:"before,omitempty"`

	// Before a specific matrix execution start
	//
	// This hook May have reference to matrix information
	BeforeMatrix Actions `yaml:"before:matrix,omitempty"`

	// AfterMatrixSuccess runs after a successful matrix execution
	//
	// This hook May have reference to matrix information
	AfterMatrixSuccess Actions `yaml:"after:matrix:success,omitempty"`

	// AfterMatrixFailure runs after a failed matrix execution
	//
	// This hook May have reference to matrix information
	AfterMatrixFailure Actions `yaml:"after:matrix:failure,omitempty"`

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

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

	// 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 Actions `yaml:"after:failure,omitempty"`

	// 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 Actions `yaml:"after,omitempty"`
}

func (*TaskHooks) DoAfterFieldsResolved added in v0.5.0

func (h *TaskHooks) DoAfterFieldsResolved(
	ctx dukkha.RenderingContext, depth int, resolveEnv bool, do func() error, names ...string,
) error

func (*TaskHooks) GenSpecs

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

Directories

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

Jump to

Keyboard shortcuts

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