impl

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: MPL-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UP_RUNTIME_TASK_LAYER_NUMBER   = "up_runtime_task_layer_number"
	UP_RUNTIME_TASKER_LAYER_NUMBER = "up_runtime_tasker_layer_number"
)
View Source
const (
	FUNC_SHELL = "shell"
	FUNC_CALL  = "call"
	FUNC_BLOCK = "block"
	FUNC_CMD   = "cmd"
)

Variables

View Source
var (
	TaskerStack   = stack.New("tasker")
	UpRunTimeVars = core.NewCache()
	BaseDir       string
)

Functions

func BlockFlowRun

func BlockFlowRun(flow *Steps, execVars *core.Cache)

func BlockStack

func BlockStack() *stack.ExecStack

func ConfigRuntime

func ConfigRuntime() *utils.UpConfig

func DecryptAndRegister

func DecryptAndRegister(securetag *u.SecureSetting, dvar *Dvar, contextVars *core.Cache, mergeTarget *core.Cache)

func DryRunAndSkip

func DryRunAndSkip(mark string, allowedErrors []string, continueFunc ContinueFunc, mustCondition MustConditionToContinueFunc)

if there is NoFault, then continue or if there is a fault in the allowed list, then skip rest, do not run continueFunc else the fault is not ignorable, then if use DryRunOrExitFunc

func DryRunOrExit

func DryRunOrExit(mark string, mustCondition MustConditionToContinueFunc, conditionDesc string)

func ExecTask

func ExecTask(fulltaskname string, callerVars *core.Cache)

func FuncMapInit

func FuncMapInit()

func GetBaseModuleName

func GetBaseModuleName() string

func GlobalVarsMergedWithDvars

func GlobalVarsMergedWithDvars(scope *Scope) (vars *core.Cache)

func InitDefaultSkeleton

func InitDefaultSkeleton()

func IsAtRootTaskLevel

func IsAtRootTaskLevel() (called bool)

func IsCalledTask

func IsCalledTask() (called bool)

func ListAllFuncs

func ListAllFuncs()

func ListAllModules

func ListAllModules()

probing modules list all modules, including the main direct modules and the all indirect modules

func Render

func Render(tstr string, obj interface{}) string

func ScopeVarsMergedWithDvars

func ScopeVarsMergedWithDvars(scope *Scope, contextMergedVars *core.Cache) *core.Cache

func SetBaseDir

func SetBaseDir(dir string)

func SetDryrun

func SetDryrun()

func StepStack

func StepStack() *stack.ExecStack

func ToJson

func ToJson(str string) string

func VarsMergedWithDvars

func VarsMergedWithDvars(mark string, baseVars *core.Cache, dvars *Dvars, contextMergedVars *core.Cache) *core.Cache

given vars as base vars space to expand from, expand dvars against contextVars

Types

type BlockFuncAction

type BlockFuncAction struct {
	Do        interface{}
	Vars      *core.Cache
	Tasknames []string
	Steps     *Steps
}

func (*BlockFuncAction) Adapt

func (f *BlockFuncAction) Adapt()

func (*BlockFuncAction) Exec

func (f *BlockFuncAction) Exec()

type BlockRuntimeContext

type BlockRuntimeContext struct {
	BlockBaseVars *core.Cache
}

type CallFuncAction

type CallFuncAction struct {
	Do        interface{}
	Vars      *core.Cache
	Tasknames []string
}

func (*CallFuncAction) Adapt

func (f *CallFuncAction) Adapt()

adapt the abstract step.Do to concrete ShellFuncAction Cmds

func (*CallFuncAction) Exec

func (f *CallFuncAction) Exec()

type CmdCmd

type CmdCmd struct {
	Name  string
	Desc  string
	Cmd   interface{}
	Cmdx  interface{}
	Flags []string
}

type CmdCmds

type CmdCmds []CmdCmd

type CmdFuncAction

type CmdFuncAction struct {
	Do   interface{}
	Vars *core.Cache
	Cmds *CmdCmds
}

func (*CmdFuncAction) Adapt

func (f *CmdFuncAction) Adapt()

func (*CmdFuncAction) Exec

func (f *CmdFuncAction) Exec()

type ContextInstances

type ContextInstances []ScopeContext

type ContinueFunc

type ContinueFunc func()

type Dvar

type Dvar struct {
	Name         string
	Value        string
	Desc         string
	Expand       int
	Flags        []string //supported: vvvv, to_object,envvar,
	Rendered     string
	Secure       *u.SecureSetting
	Ref          string
	RefDir       string
	DataKey      string
	DataPath     string
	DataTemplate string
}

type Dvars

type Dvars []Dvar

func (*Dvars) Expand

func (dvars *Dvars) Expand(mark string, contextVars *core.Cache) *core.Cache

given a dvars with the vars context, it expands with rendered result

func (*Dvars) ValidateAndLoading

func (dvars *Dvars) ValidateAndLoading(contextVars *core.Cache)

type GeneralCmd

type GeneralCmd struct {
	Name  string
	Value string
}

type LoopItem

type LoopItem struct {
	Index  int
	Index1 int
	Item   interface{}
}

type MustConditionToContinueFunc

type MustConditionToContinueFunc func() bool

type Scope

type Scope struct {
	Name    string
	Ref     string
	RefDir  string
	Members []string
	Vars    core.Cache
	Dvars   Dvars
}

type ScopeContext

type ScopeContext map[string]*core.Cache

type Scopes

type Scopes []Scope

func (*Scopes) GetInstanceVars

func (ss *Scopes) GetInstanceVars(instanceName string) *core.Cache

get instance vars from scope definition, eg dev

type ShellFuncAction

type ShellFuncAction struct {
	Do     interface{}
	Vars   *core.Cache
	Cmds   []string
	Result u.ExecResult
}

func (*ShellFuncAction) Adapt

func (f *ShellFuncAction) Adapt()

adapt the abstract step.Do to concrete ShellFuncAction Cmds

func (*ShellFuncAction) Exec

func (f *ShellFuncAction) Exec()

type Step

type Step struct {
	Name     string
	Do       interface{} //FuncImpl
	Dox      interface{}
	Func     string
	Vars     core.Cache
	Dvars    Dvars
	Desc     string
	Reg      string
	Flags    []string
	If       string
	Else     interface{}
	Loop     interface{}
	Until    string
	RefDir   string
	VarsFile string
}

func (*Step) Exec

func (step *Step) Exec(fromBlock bool)

func (*Step) ExecTest

func (step *Step) ExecTest()

type StepRuntimeContext

type StepRuntimeContext struct {
	Stepname string
	Result   *u.ExecResult
}

func StepRuntime

func StepRuntime() *StepRuntimeContext

type Steps

type Steps []Step

func (*Steps) Exec

func (steps *Steps) Exec(fromBlock bool)

func (*Steps) ExecFlow

func (flow *Steps) ExecFlow()

type TaskRuntimeContext

type TaskRuntimeContext struct {
	Taskname           string
	TasknameLayered    string
	ExecbaseVars       *core.Cache
	TaskVars           *core.Cache
	ReturnVars         *core.Cache
	IsCalledExternally bool
}

func TaskRuntime

func TaskRuntime() *TaskRuntimeContext

type Tasker

type Tasker struct {
	TaskYmlRoot      *viper.Viper
	Tasks            *model.Tasks
	InstanceName     string
	Dryrun           bool
	TaskStack        *stack.ExecStack
	StepStack        *stack.ExecStack
	BlockStack       *stack.ExecStack
	TaskBreak        bool
	Config           *u.UpConfig
	GroupMembersList []string
	MemberGroupMap   map[string]string
	//expanded context only contains group and global scope, but not each instance vars
	ExpandedContext ScopeContext
	ScopeProfiles   *Scopes
	//this is the merged vars from within scope: global, groups level (if there is), instance varss, then global runtime vars
	RuntimeVarsMerged *core.Cache
	//this is the merged vars and dvars to a vars cache from within scope: global, groups level (if there is), instance varss, then global runtime vars
	//this vars should be used instead of RuntimeVarsMerged as it include both runtime vars and dvars except the local vars and dvars
	RuntimeVarsAndDvarsMerged *core.Cache
	RuntimeGlobalVars         *core.Cache
	RuntimeGlobalDvars        *Dvars
}

func NewTasker

func NewTasker(instanceId string, cfg *u.UpConfig) *Tasker

func (*Tasker) CleanModules

func (t *Tasker) CleanModules()

func (*Tasker) ExecTask

func (t *Tasker) ExecTask(taskname string, callerVars *core.Cache, isExternalCall bool)

func (*Tasker) InitContextInstances

func (t *Tasker) InitContextInstances(ss *Scopes)

func (*Tasker) InspectTask

func (tasker *Tasker) InspectTask(taskname string, branch treeprint.Tree, level *int) bool

func (*Tasker) ListAllTasks

func (t *Tasker) ListAllTasks()

func (*Tasker) ListMainModules

func (t *Tasker) ListMainModules()

list tasker modules

func (*Tasker) ListTask

func (tasker *Tasker) ListTask(taskname string)

func (*Tasker) ListTasks

func (t *Tasker) ListTasks()

func (*Tasker) LockModules

func (t *Tasker) LockModules()

func (*Tasker) PullModules

func (t *Tasker) PullModules()

func (*Tasker) SetRuntimeGlobalMergedWithDvars

func (t *Tasker) SetRuntimeGlobalMergedWithDvars()

func (*Tasker) SetRuntimeVarsMerged

func (t *Tasker) SetRuntimeVarsMerged(runtimeid string)

This will generate a one off vars merged from top level down to runtime global and merge them all together,the result vars will be used to finally merge with local func vars to be used in runtime execution time

pass in runtime id, if runtime id is in member list, eg dev -> nonprod then merge runtimevars to group(nonprod)'s varss,

if runtime id (nonname) is not in member list, then merge runtimevars to global varss,

This has chained dvar expansion through global to group then to instance level and finally merge with global var, except the global dvars

func (*Tasker) Unset

func (t *Tasker) Unset()

clear up everything in scope and cache

func (*Tasker) ValidateAllModules

func (t *Tasker) ValidateAllModules() bool

func (*Tasker) ValidateTask

func (t *Tasker) ValidateTask(taskname string)

type TaskerRuntimeContext

type TaskerRuntimeContext struct {
	Tasker       *Tasker
	TaskerCaller *Tasker
}

func TaskerRuntime

func TaskerRuntime() *TaskerRuntimeContext

Jump to

Keyboard shortcuts

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