tools

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: Apache-2.0 Imports: 28 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(cacheFS *fshelper.OSFS, script string) (string, error)

func ResolveActions added in v0.5.0

func ResolveActions(
	rc dukkha.TaskExecContext,
	x dukkha.Resolvable,
	actionsFieldName string,
	actionsTagName string,
) ([]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"`

	// Run checks running condition, only run this action when set to true
	//
	// Defaults to `true`
	Run *bool `yaml:"if"`

	// Idle does nothing but serves as a placeholder for preparation purpose
	// recommended usage of Idle action is to apply renderers like `tpl`
	// 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(run bool) 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:"-"`

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

	ContinueOnErrorFlag bool `yaml:"continue_on_error"`

	CacheFS *fshelper.OSFS `yaml:"-"`
	// 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) Init added in v0.7.0

func (t *BaseTask) Init(cacheFS *fshelper.OSFS) error

func (*BaseTask) InitBaseTask

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

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

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

	CacheFS *fshelper.OSFS `yaml:"-"`
	// contains filtered or unexported fields
}

func (*BaseTool) AddTasks added in v0.5.1

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

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

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(
	defaultExecutable string,
	cacheFS *fshelper.OSFS,
	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) Run

Run task

type ShellTool added in v0.7.0

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

	ToolName dukkha.ToolName `yaml:"name"`

	BaseTool `yaml:",inline"`
}

func (*ShellTool) GetExecSpec added in v0.7.0

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

GetExecSpec is a helper func for shells

func (*ShellTool) Init added in v0.7.0

func (t *ShellTool) Init(cacheFS *fshelper.OSFS) error

func (*ShellTool) Key added in v0.7.0

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

func (*ShellTool) Kind added in v0.7.0

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

func (*ShellTool) Name added in v0.7.0

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

type TaskExecRequest

type TaskExecRequest struct {
	Context dukkha.TaskExecContext

	Tool dukkha.Tool
	Task dukkha.Task

	IgnoreError bool

	// DryRun do not actually run any thing, just evaluate values
	DryRun 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