workflow

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TYPE_STRING = "string"
	TYPE_INT    = "int"
	TYPE_FLOAT  = "float"
	TYPE_BOOL   = "bool"
)

Parameter data types

View Source
const (
	LOG_QUIET   = 0 //just show print messages
	LOG_INFO    = 1 //show Action messages
	LOG_VERBOSE = 2 //show Action messages and LogLevel messages
)

Log Level constants

Variables

View Source
var (
	//ErrEndWorkflow is the error that is returned when the workflow is ended
	//Use this error to end the workflow but not return an error to the caller
	ErrEndWorkflow = errors.New("end workflow")
)

Functions

func CreateLoopStack

func CreateLoopStack() loopStack

CreateLoopStack creates a new loop stack returns the loop stack

Types

type Action

type Action struct {
	Key         string `json:"key,omitempty" yaml:"key,omitempty" flag:"key k" desc:"key for the job or global action"`
	Description string `json:"description,omitempty" yaml:"description,omitempty" flag:"desc" desc:"description for the job"`
	Action      string `json:"action" yaml:"action" flag:"-"`
	//Label           string                 `json:"label" yaml:"label"`
	Fail            string                 `json:"fail,omitempty" yaml:"fail,omitempty" flag:"fail" desc:"The action to run if this action fails"`
	ContinueOnError interface{}            `` /* 204-byte string literal not displayed */
	Config          map[string]interface{} `json:"config,omitempty" yaml:"config,omitempty"`
	Disabled        interface{}            `` /* 150-byte string literal not displayed */
}

Action is the struct that defines an action

func CreateAction

func CreateAction(opts ...ActionOption) *Action

CreateAction creates a new action

func (*Action) GetConfig

func (m *Action) GetConfig(key string) interface{}

GetConfig returns the Action config as an interface Key is the name of the config returns the config as an interface

func (*Action) GetConfigBool

func (m *Action) GetConfigBool(key string) bool

GetConfigBool returns the Action config as a bool Key is the name of the config returns the config as a bool

func (*Action) GetConfigFloat64

func (m *Action) GetConfigFloat64(key string) float64

GetConfigInt returns the Action config as an int Key is the name of the config returns the config as an int

func (*Action) GetConfigInt

func (m *Action) GetConfigInt(key string) int

GetConfigInt returns the Action config as an int Key is the name of the config returns the config as an int

func (*Action) GetConfigString

func (m *Action) GetConfigString(key string) string

GetConfigString returns the Action config as a string Key is the name of the config returns the config as a string

type ActionFunc

type ActionFunc func(w *Workflow, m *TemplateData) error

ActionFunc is the function definition that needs to be implemented to be able to execute an action, this is called by the workflow - w: the workflow - m: the template data returns an error if the action fails

type ActionOption

type ActionOption func(*Action)

ActionOption is a function that sets an option on the action

func OptionActionAction

func OptionActionAction(v string) ActionOption

OptionActionAction sets the action on the action

func OptionActionConfig

func OptionActionConfig(v map[string]interface{}) ActionOption

OptionActionConfig sets the config on the action

func OptionActionContinueOnError

func OptionActionContinueOnError(v interface{}) ActionOption

OptionActionContinueOnError sets the continue on error flag on the action

func OptionActionDescription

func OptionActionDescription(v string) ActionOption

OptionActionDescription sets the description on the action

func OptionActionDisabled

func OptionActionDisabled(v bool) ActionOption

OptionActionDisabled sets the disabled flag on the action

func OptionActionFail

func OptionActionFail(v string) ActionOption

OptionActionFail sets the fail flag on the action

func OptionActionKey

func OptionActionKey(v string) ActionOption

OptionActionKey sets the key on the action

type ActionSchema

type ActionSchema struct {
	Short  string
	Long   string
	Target string //The module and target that the action is for e.g action_git_target
	//Config         map[string]interface{}
	ConfigSchema   map[string]*Schema
	ProcessResults bool            //Uses the process results function to process the results so auto add the results to the template data
	InlineParams   bool            //If true then the params are passed as a string in the action name e.g action: "print;Hello World"
	InlineFormat   InlineFormatter //If InlineParams is true then this is used to format the inline params into a string this will need to be implemented by user
	Action         ActionFunc      //The action function that is called to execute the action
}

ActionSchema is the schema definition for the action plugin

type Answer

type Answer struct {
	Key         string      `` /* 127-byte string literal not displayed */
	Title       string      `json:"title,omitempty" yaml:"title,omitempty" flag:"title t" desc:"title for the parameter, used as the parameter title"`
	Description string      `` /* 143-byte string literal not displayed */
	InputType   string      `` /* 127-byte string literal not displayed */
	Value       interface{} `json:"value" yaml:"value" flag:"value v" desc:"value of the parameter, must be a string, int, float, or bool"`
}

type Answers

type Answers struct {
	Name    string   `json:"package_name" yaml:"package_name"`
	Version string   `json:"package_version" yaml:"package_version"`
	Answers []Answer `json:"answers" yaml:"answers"`
}

func (*Answers) GetPackageProjectName

func (m *Answers) GetPackageProjectName() string

func (*Answers) Save

func (m *Answers) Save(file_name string) error

type DeleteConfigFunc

type DeleteConfigFunc func(key string, custom ...string) error

DeleteConfigFunc is the function definition that needs to be implemented to be able to delete config values to the config store of choice - key: the key to delete - custom: the custom data that is used to to pass data to the config function

type EventFunc

type EventFunc func(w *Workflow) error

EventFunc is the function definition is used as part of the workflow event system Start and a cleanup function can be added to the workflow and you implement code to handle the event - w: the workflow returns an error if the event fails

type FunctionSchema

type FunctionSchema struct {
	Cmd             string
	Description     string
	Target          string //The module that the function is for e.g action_git
	ParameterSchema map[string]*Schema
	Function        any //The function that is called to execute the function
}

type InlineFormatter

type InlineFormatter func(cfg map[string]interface{}) string

InlineFormatter is used with the action schema to format the inline params inline params as passed with the action name e.g action "print;Hello World" Normally params are passed as a map[string]interface{} in the action config but if the action schema has InlineParams set to true then the params are passed as a string - cfg: the config map returns the formatted string

type Job

type Job struct {
	Key           string               `json:"key" yaml:"key" flag:"key k" desc:"key for the job, must be unique within the workflow, used as the job name"`
	Title         string               `json:"title" yaml:"title" flag:"title t" desc:"title for the job"`
	Description   string               `json:"description" yaml:"description" flag:"desc d" desc:"description for the job"`
	Actions       []Action             `json:"actions" yaml:"actions" flag:"actions a" desc:"list of actions for the job"`
	IsSubWorkflow bool                 `json:"is_sub_workflow" yaml:"is_sub_workflow" flag:"sub s" desc:"set to true if this is a sub workflow"`
	Inputs        map[string]Parameter `json:"inputs,omitempty" yaml:"inputs,omitempty" flag:"inputs i" desc:"inputs for the job"`
}

Job is a workflow job

func CreateJob

func CreateJob(opts ...JobOption) *Job

CreateJob creates a new job opts are the options to set on the job returns the job

func (*Job) ActionExists

func (m *Job) ActionExists(key string) bool

ActionExists returns true if the action exists - key is the name of the action - returns true if the action exists

func (*Job) ActionKeyExists

func (m *Job) ActionKeyExists(key string) bool

ActionKeyExists returns true if the action exists - key is the name of the action - returns true if the action exists

func (*Job) GetActionByKey

func (m *Job) GetActionByKey(key string) *Action

GetActionByKey returns the action with the given key - key is the name of the action - returns the action

func (*Job) GetInput

func (m *Job) GetInput(key string) *Parameter

GetInput returns the Job input as an interface - key is the name of the parameter - returns the parameter

func (*Job) GetKeyIndex

func (m *Job) GetKeyIndex(key string) int

GetKeyIndex returns the index of the action with the given key - key is the name of the action - returns the index of the action

func (*Job) SetInputAnswer

func (m *Job) SetInputAnswer(key string, value interface{}) error

SetInputAnswer sets the answer for the input parameter - key is the name of the parameter - value is the answer - returns an error if the input does not exist

type JobOption

type JobOption func(*Job)

JobOption is a function that sets an option on the job

func OptionJobActions

func OptionJobActions(v []Action) JobOption

OptionJobActions sets the actions on the job v is the actions as a slice of Action

func OptionJobDescription

func OptionJobDescription(v string) JobOption
OptionJobDescription sets the description on the job

v is the description

func OptionJobKey

func OptionJobKey(v string) JobOption

OptionJobKey sets the key on the job v is the key

func OptionJobTitle

func OptionJobTitle(v string) JobOption

OptionJobTitle sets the title on the job v is the title

type Manifest

type Manifest struct {
	Meta       MetaData               `json:"meta_data" yaml:"meta_data"`
	Actions    []Action               `json:"actions" yaml:"actions"`
	Jobs       []Job                  `json:"jobs" yaml:"jobs"`
	Parameters []Parameter            `json:"parameters" yaml:"parameters"`
	Data       map[string]interface{} `json:"data" yaml:"data"`
}

Manifest is a workflow manifest and contains all the information needed to run a workflow

func CreateManifest

func CreateManifest(opts ...ManifestOption) *Manifest

CreateManifest creates a new manifest opts are the options to set on the manifest returns the manifest

func (*Manifest) DataModel

func (m *Manifest) DataModel() *go_data_chain.Data

DataModel returns the data model for the manifest returns the data model for the manifest as a data chain

func (*Manifest) GetGlobalAction

func (m *Manifest) GetGlobalAction(key string) *Action

GetJob gets a job from the manifest key is the key of the job returns the job or nil if it does not exist

func (*Manifest) GetJob

func (m *Manifest) GetJob(key string) *Job

GetJob gets a job from the manifest key is the key of the job returns the job or nil if it does not exist

func (*Manifest) GetParameter

func (m *Manifest) GetParameter(key string) *Parameter

GetParameter gets a parameter key is the key of the parameter returns the parameter or nil if it does not exist

func (*Manifest) GlobalActionKeyExists

func (m *Manifest) GlobalActionKeyExists(key string) bool

func (*Manifest) ParameterExists

func (m *Manifest) ParameterExists(key string) bool

ParameterExists checks if a parameter exists key is the key of the parameter returns true if the parameter exists

type ManifestOption

type ManifestOption func(*Manifest)

ManifestOption is a function that sets an option on the manifest

func OptionManifestData

func OptionManifestData(v map[string]interface{}) ManifestOption

OptionManifestData sets the data on the manifest v is the data as a map[string]interface{}

func OptionManifestJobs

func OptionManifestJobs(v []Job) ManifestOption

OptionManifestJobs sets the jobs on the manifest v is the slice of jobs

func OptionManifestMeta

func OptionManifestMeta(v MetaData) ManifestOption

OptionManifestMeta sets the meta data on the manifest v is the meta data

func OptionManifestParameters

func OptionManifestParameters(v []Parameter) ManifestOption

OptionManifestParameters sets the parameters on the manifest v is the slice of parameters

type MetaData

type MetaData struct {
	Name        string                 `json:"name" yaml:"name" flag:"name n" desc:"Project Name"`
	Description string                 `json:"description" yaml:"description" flag:"description d" desc:"Project Description"`
	Version     string                 `json:"version" yaml:"version" flag:"version v" desc:"Project Version"`
	Author      string                 `json:"author" yaml:"author" flag:"author a" desc:"Project Author"`
	Contact     string                 `json:"contact" yaml:"contact" flag:"contact c" desc:"Contact Details"`
	CreatedDate string                 `json:"create_date" yaml:"create_date" flag:"create_date" desc:"Created Date"`
	UpdateDate  string                 `json:"update_date" yaml:"update_date" flag:"update_date" desc:"Updated Date"`
	Vars        map[string]interface{} `json:"vars" yaml:"vars"`
}

MetaData is the metadata for a workflow

func CreateMetaData

func CreateMetaData(opts ...MetaDataOption) *MetaData

CreateMetaData creates a new metadata opts are the options to set on the metadata returns the metadata

type MetaDataOption

type MetaDataOption func(*MetaData)

MetaDataOption is a function that sets an option on the metadata

func OptionMetaDataAuthor

func OptionMetaDataAuthor(v string) MetaDataOption

OptionMetaDataAuthor sets the author on the metadata v is the author

func OptionMetaDataContact

func OptionMetaDataContact(v string) MetaDataOption

OptionMetaDataContact sets the contact on the metadata v is the contact

func OptionMetaDataCreatedDate

func OptionMetaDataCreatedDate(v string) MetaDataOption

OptionMetaDataCreatedDate sets the created date on the metadata v is the created date

func OptionMetaDataDescription

func OptionMetaDataDescription(v string) MetaDataOption

OptionMetaDataDescription sets the description on the metadata v is the description

func OptionMetaDataName

func OptionMetaDataName(v string) MetaDataOption

OptionMetaDataName sets the name on the metadata v is the name

func OptionMetaDataUpdateDate

func OptionMetaDataUpdateDate(v string) MetaDataOption

OptionMetaDataUpdateDate sets the update date on the metadata v is the update date

func OptionMetaDataVars

func OptionMetaDataVars(v map[string]interface{}) MetaDataOption

OptionMetaDataVars sets the vars on the metadata v is the vars

func OptionMetaDataVersion

func OptionMetaDataVersion(v string) MetaDataOption

OptionMetaDataVersion sets the version on the metadata v is the version

type Parameter

type Parameter struct {
	Key         string      `` /* 127-byte string literal not displayed */
	Title       string      `json:"title" yaml:"title" flag:"title t" desc:"title for the parameter, used as the parameter title"`
	Description string      `json:"description" yaml:"description" flag:"desc d" desc:"description for the parameter, used as the parameter description"`
	InputType   string      `json:"type" yaml:"type" flag:"type y" desc:"type of the parameter, must be one of string, int, float, bool"`
	Value       interface{} `json:"value" yaml:"value" flag:"value v" desc:"value of the parameter, must be a string, int, float, or bool"`
	// contains filtered or unexported fields
}

Parameter is a struct that holds the information for a parameter

func CreateParameter

func CreateParameter(opts ...ParameterOption) *Parameter

func (*Parameter) GetValue

func (m *Parameter) GetValue() interface{}

GetValue returns the value of the parameter returns the value of the parameter

func (*Parameter) SetAnswer

func (m *Parameter) SetAnswer(answer interface{})

SetAnswer sets the answer of the parameter - answer is the answer to set

func (*Parameter) ValueBool

func (m *Parameter) ValueBool() bool

ValueBool returns the value of the parameter as a bool returns the value of the parameter as a bool

func (*Parameter) ValueFloat

func (m *Parameter) ValueFloat() float64

ValueFloat returns the value of the parameter as a float64 returns the value of the parameter as a float64

func (*Parameter) ValueInt

func (m *Parameter) ValueInt() int

ValueInt returns the value of the parameter as an int returns the value of the parameter as an int

func (*Parameter) ValueString

func (m *Parameter) ValueString() string

ValueString returns the value of the parameter as a string returns the value of the parameter as a string

type ParameterOption

type ParameterOption func(*Parameter)

ParameterOption is a function that sets a parameter option

func OptionParameterDescription

func OptionParameterDescription(v string) ParameterOption

OptionParameterDescription sets the description of the parameter - v is the description of the parameter

func OptionParameterKey

func OptionParameterKey(v string) ParameterOption

OptionParameterKey sets the key of the parameter - v is the key of the parameter

func OptionParameterTitle

func OptionParameterTitle(v string) ParameterOption

OptionParameterTitle sets the title of the parameter - v is the title of the parameter

func OptionParameterType

func OptionParameterType(v string) ParameterOption

OptionParameterType sets the type of the parameter - v is the type of the parameter

func OptionParameterValue

func OptionParameterValue(v string) ParameterOption

OptionParameterValue sets the value of the parameter - v is the value of the parameter

type ReadConfigFunc

type ReadConfigFunc func(key string, data_type string, custom ...string) (interface{}, error)

ReadConfigFunc is the function definition that needs to be implemented for when you want to get config values from the config store of choice - key: the key to get - data_type: the data type to convert the value to - custom: the custom data that is used to to pass data to the config function returns the value of the config or nil if the config does not exist returns an error

type Schema

type Schema struct {
	Type        ValueType
	Partial     bool
	Required    bool
	Description string
	ConfigKey   string
	Short       string
	Default     interface{}
	Value       string
}

Schema is the schema definition for the action plugin

type SchemaEndpoint

type SchemaEndpoint interface {
	GetTargetSchema() map[string]TargetSchema  //Get the target schema
	GetActionSchema() map[string]ActionSchema  //Get the action schema
	GetFunctionMap() map[string]FunctionSchema //Get the custom function map for the template

}

SchemaEndpoint is the interface that needs to be implemented by the plugin

type TargetMapFunc

type TargetMapFunc func(w *Workflow, m interface{}, target interface{}) (interface{}, error)

TargetMapFunc is the function that is called to map config values to a target type - w: the workflow - m: the config values - target: the target type

type TargetSchema

type TargetSchema struct {
	Action string      //The action that the target is used for e.g action_git
	Short  string      //The short name of the target
	Long   string      //The long name of the target
	Target interface{} //The target type
}

TargetSchema is the schema definition for the target plugin

func BuildTargetConfig

func BuildTargetConfig(short string, long string, target interface{}) TargetSchema

BuildTargetConfig is a helper function to build a target schema - short: the short name of the target - long: the long name of the target - target: the target type returns the target schema

func (*TargetSchema) GetTargetMap

func (m *TargetSchema) GetTargetMap() map[string]interface{}

type TemplateData

type TemplateData struct {
	Meta          *MetaData
	Manifest      *Manifest
	CurrentAction *Action
	Data          map[string]interface{}
}

TemplateData is the data that is passed to the template engine

func (*TemplateData) SetAction

func (m *TemplateData) SetAction(current_action *Action)

SetAction sets the current action current_action - the current action

type ValueOperand

type ValueOperand int

type ValueType

type ValueType int
const (
	TypeInvalid ValueType = iota
	TypeBool
	TypeInt
	TypeFloat
	TypeString
	TypeList
	TypeMap
	TypeSet
	TypeObject
	TypeWorkflow
)

func (ValueType) String

func (v ValueType) String() string

type Workflow

type Workflow struct {
	LogLevel       int64
	Manifest       Manifest                  //the manifest that is used for the workflow
	InitFunc       EventFunc                 //the function that is called when the workflow is initialized
	CleanFunc      EventFunc                 //the function that is called when the workflow is cleaned up
	ActionList     map[string]ActionFunc     //the list of actions that are available
	ReadConfigFunc map[string]ReadConfigFunc //the function that can be called to get config values for an action
	TargetMapFunc  TargetMapFunc             //Called to map config values to a target type
	// contains filtered or unexported fields
}

Workflow is the main struct for the workflow

func CreateWorkflow

func CreateWorkflow(opts ...WorkflowOption) *Workflow

createWorkflow creates a new workflow - opts: the workflow options returns: the workflow

func (*Workflow) ActionProcessResults

func (w *Workflow) ActionProcessResults(m *TemplateData, data interface{}) error

ActionProcessResults processes the results of the action - m is the template data model - data is the data to process - returns an error if there is an error

func (*Workflow) AddActionSchema

func (m *Workflow) AddActionSchema(sch SchemaEndpoint)

AddActionSchema adds an action and target schema to the client and adds the action to the workflow

func (*Workflow) BuildAnswerFile

func (m *Workflow) BuildAnswerFile() (*Answers, error)

func (*Workflow) BuildPath

func (m *Workflow) BuildPath(file_path string) string

BuildPath will build a path from the base path and the file path file_path - the file path to build returns the full path

func (*Workflow) BuildStoreMap

func (m *Workflow) BuildStoreMap(key string, custom ...string) map[string]interface{}

BuildStoreMap will build a map of values to store in the data bucket or from key/value pairs as string `key=value` key - the key of the data bucket custom - the custom values to add to the map Returns the map of values

func (*Workflow) ClearDataBucket

func (m *Workflow) ClearDataBucket(key string)

ClearDataBucket values from the data bucket - key is the name of the bucket

func (*Workflow) ClearDataBuckets

func (m *Workflow) ClearDataBuckets()

ClearDataBuckets clears the data bucket

func (*Workflow) CountArray

func (m *Workflow) CountArray(v []interface{}) int

func (*Workflow) CreateJSEngine

func (m *Workflow) CreateJSEngine() *goja.Runtime

CreateJSEngine creates a new js engine this is used to run the js code returns a new js engine

func (*Workflow) CreateSubWorkflowEngine

func (m *Workflow) CreateSubWorkflowEngine() *Workflow

CreateSubWorkflowEngine creates a new workflow engine from the current workflow engine This is useful for creating sub workflows

func (*Workflow) CreateTemplateData

func (m *Workflow) CreateTemplateData(current_action *Action) *TemplateData

CreateTemplateData creates the template data current_action - the current action returns the template data

func (*Workflow) FileTemplate

func (m *Workflow) FileTemplate(file string, custom ...interface{}) (string, error)

FileTemplate will read a file and parse the tokens file - the file to read custom - the custom data to use Returns the parsed string Returns an error if the file could not be read

func (*Workflow) GenerateToken

func (m *Workflow) GenerateToken(password string) (string, error)

GenerateToken will generate a token from a password password - the password to generate the token from Returns the token Returns an error if the token could not be generated

func (*Workflow) GetConfigToken

func (m *Workflow) GetConfigToken(key string, model *TemplateData) (interface{}, error)

GetConfigToken will get the config token from the action and replaces its tokens key - the key of the config model - the template data Returns the value of the config as an interface Returns an error if the key is not found

func (*Workflow) GetConfigTokenBool

func (m *Workflow) GetConfigTokenBool(key string, model *TemplateData, required bool) (bool, error)

GetConfigTokenBool will get the config token from the action and replaces its tokens and converts to a bool key - the key of the config model - the template data required - if the key should exist and a value should be returned Returns the value of the config as a bool Returns an error if the key is not found

func (*Workflow) GetConfigTokenFloat

func (m *Workflow) GetConfigTokenFloat(key string, model *TemplateData, required bool) (float64, error)

GetConfigTokenInt will get the config token from the action and replaces its tokens and converts to an int key - the key of the config model - the template data required - if the key should exist and a value should be returned Returns the value of the config as an int Returns an error if the key is not found

func (*Workflow) GetConfigTokenInt

func (m *Workflow) GetConfigTokenInt(key string, model *TemplateData, required bool) (int, error)

GetConfigTokenInt will get the config token from the action and replaces its tokens and converts to an int key - the key of the config model - the template data required - if the key should exist and a value should be returned Returns the value of the config as an int Returns an error if the key is not found

func (*Workflow) GetConfigTokenInterface

func (m *Workflow) GetConfigTokenInterface(key string, model *TemplateData, required bool) (interface{}, error)

GetConfigTokenInterface will get the config token from the action and replaces its tokens and returns it as an interface key - the key of the config model - the template data required - if the key should exist and a value should be returned Returns the value of the config as an interface Returns an error if the key is not found

func (*Workflow) GetConfigTokenInterfaceArray

func (m *Workflow) GetConfigTokenInterfaceArray(key string, model *TemplateData, required bool) ([]interface{}, error)

GetConfigTokenMap will get the config token map from the action and replaces its tokens key - the key of the config model - the template data required - if the key is required returns the value of the map with the tokens replaced returns an error if the key is not found

func (*Workflow) GetConfigTokenMap

func (m *Workflow) GetConfigTokenMap(key string, model *TemplateData, required bool) (map[string]interface{}, error)

GetConfigTokenMap will get the config token map from the action and replaces its tokens key - the key of the config model - the template data required - if the key is required returns the value of the map with the tokens replaced returns an error if the key is not found

func (*Workflow) GetConfigTokenMapArray

func (m *Workflow) GetConfigTokenMapArray(key string, model *TemplateData, required bool) ([]map[string]interface{}, error)

GetConfigTokenMap will get the config token map from the action and replaces its tokens key - the key of the config model - the template data required - if the key is required returns the value of the map with the tokens replaced returns an error if the key is not found

func (*Workflow) GetConfigTokenString

func (m *Workflow) GetConfigTokenString(key string, model *TemplateData, required bool) (string, error)

GetConfigTokenString will get the config token from the action and replaces its tokens as a string key - the key of the config model - the template data required - if the key should exist and a value should be returned Returns the value of the config as a string Returns an error if the key is not found

func (*Workflow) GetConfigTokenStringArray

func (m *Workflow) GetConfigTokenStringArray(key string, model *TemplateData, required bool) ([]string, error)

GetConfigTokenMap will get the config token map from the action and replaces its tokens key - the key of the config model - the template data required - if the key is required returns the value of the map with the tokens replaced returns an error if the key is not found

func (*Workflow) GetConfigValue

func (w *Workflow) GetConfigValue(config_target string, key string, data_type string, custom ...string) (interface{}, error)

GetConfigValue will return the value of the config with the given key key - the key of the config to return data_type - the type of the config to return custom - custom values to pass to the config function returns the value of the config or nil if the config does not exist returns an error if the config function is not set

func (*Workflow) GetCurrentActionIndex

func (m *Workflow) GetCurrentActionIndex() int

GetCurrentActionIndex will get the current action index returns the current action index

func (*Workflow) GetCurrentJob

func (m *Workflow) GetCurrentJob() *Job

GetCurrentJob returns the current job

func (*Workflow) GetDataBucket

func (m *Workflow) GetDataBucket() map[string]map[string]interface{}

GetDataBucket returns the data bucket

func (*Workflow) GetDataBucketContent

func (m *Workflow) GetDataBucketContent(key string) map[string]interface{}

GetDataBucketItem returns the Map from the data bucket - key is the name of the bucket returns Bucket Content nil if the bucket does not exist

func (*Workflow) GetDataFromString

func (m *Workflow) GetDataFromString(path string) (interface{}, error)

Gets the data from the template using a string

func (*Workflow) GetDataItem

func (m *Workflow) GetDataItem(item string) *go_data_chain.Data

GetDataItem returns the data item with the given name item: the name of the data item to return returns the data item or nil if the item does not exist

func (*Workflow) GetInbuiltTemplateFuncMap

func (m *Workflow) GetInbuiltTemplateFuncMap() template.FuncMap

GetTemplateFuncMap will return the template function map

func (*Workflow) GetInputValue

func (m *Workflow) GetInputValue(key string) interface{}

GetInputValue will return the value of the job input key - the key of the parameter to return returns the value of the parameter or nil if the parameter does not exist

func (*Workflow) GetParamValue

func (m *Workflow) GetParamValue(key string) interface{}

GetParamValue will return the value of the parameter with the given key key - the key of the parameter to return returns the value of the parameter or nil if the parameter does not exist

func (*Workflow) GetRuntimeVar

func (m *Workflow) GetRuntimeVar(key string) (interface{}, error)

Get Runtime vars from the workflow using key key - the key of the parameter to return returns the value of the parameter or nil if the parameter does not exist

func (*Workflow) GetStackVariable

func (m *Workflow) GetStackVariable(variable_name string) int

GetStackVariable gets the value of a variable from the stack variable_name - the name of the variable returns the value of the variable as an int or -1 if the variable is not found

func (*Workflow) GetTemplateFuncMap

func (m *Workflow) GetTemplateFuncMap() template.FuncMap

func (*Workflow) GetTokenBool

func (m *Workflow) GetTokenBool(value interface{}, model *TemplateData) (bool, error)

GetTokenBool will parse the token string and convert to a bool value - the value to parse model - the template data Returns the parsed bool Returns an error if the value is not a bool

func (*Workflow) GetTokenFloat64

func (m *Workflow) GetTokenFloat64(value interface{}, model *TemplateData) (float64, error)

GetTokenInt will parse the token string and convert to an int value - the value to parse model - the template data Returns the parsed int Returns an error if the value is not an int

func (*Workflow) GetTokenInt

func (m *Workflow) GetTokenInt(value interface{}, model *TemplateData) (int, error)

GetTokenInt will parse the token string and convert to an int value - the value to parse model - the template data Returns the parsed int Returns an error if the value is not an int

func (*Workflow) GetTokenString

func (m *Workflow) GetTokenString(value interface{}, model *TemplateData) (string, error)

GetTokenString will parse the token string value - the value to parse model - the template data Returns the parsed string Returns an error if the value is not a string

func (*Workflow) GetValueFromDataBucket

func (m *Workflow) GetValueFromDataBucket(key string, name string) interface{}

GetValueFromDataBucket returns the value from the data bucket - key is the name of the bucket - name is the name of the value The value is the data or nil if the value does not exist

func (*Workflow) GetValueFromDataBucketAsBool

func (m *Workflow) GetValueFromDataBucketAsBool(key string, name string) bool

GetValueFromDataBucketAsBool returns the value from the data bucket as a bool - key is the name of the bucket - name is the name of the value The value is the data or nil if the value does not exist

func (*Workflow) GetValueFromDataBucketAsFloat

func (m *Workflow) GetValueFromDataBucketAsFloat(key string, name string) float64

GetValueFromDataBucketAsFloat returns the value from the data bucket as a float - key is the name of the bucket - name is the name of the value The value is the data or nil if the value does not exist

func (*Workflow) GetValueFromDataBucketAsInt

func (m *Workflow) GetValueFromDataBucketAsInt(key string, name string) int

GetValueFromDataBucketAsInt returns the value from the data bucket as an int - key is the name of the bucket - name is the name of the value The value is the data or nil if the value does not exist

func (*Workflow) GetValueFromDataBucketAsStrings

func (m *Workflow) GetValueFromDataBucketAsStrings(key string, name string) string

GetValueFromDataBucketAsStrings returns the value from the data bucket as a string - key is the name of the bucket - name is the name of the value The value is the data or nil if the value does not exist

func (*Workflow) GetWorkflow

func (m *Workflow) GetWorkflow() *Workflow

GetWorkflow will return the workflow

func (*Workflow) KeyPair

func (m *Workflow) KeyPair(key string, value interface{}) string

KeyPair will return a key pair when string is passed as `key=value` key - the key value - the value Returns the key pair

func (*Workflow) KeyPairMap

func (m *Workflow) KeyPairMap(custom ...string) map[string]interface{}

KeyPairMap will return a map of the key pairs when string is passed as `key=value` custom - the key pairs

func (*Workflow) LoadAnswerFile

func (m *Workflow) LoadAnswerFile(answer_file string) error

LoadAnswerFile loads the answers from the given file answer_file: the file to load the answers from returns an error if the answers are not valid

func (*Workflow) LoadManifest

func (m *Workflow) LoadManifest(package_path string) error

LoadManifest loads the manifest package_path: the path to the manifest file returns an error if the manifest is not valid

func (*Workflow) LoadManifestFromString

func (m *Workflow) LoadManifestFromString(manifest_string string) error

LoadManifestFromString loads the manifest from a string manifest_string: the manifest as a string returns an error if the manifest is not valid

func (*Workflow) ManifestAddActionToJob

func (m *Workflow) ManifestAddActionToJob(job_key string, action_obj *Action) error

AddActionToJob adds an action to a job job_key: the key of the job to add the action to action_obj: the action to add

func (*Workflow) ManifestAddGlobalAction

func (m *Workflow) ManifestAddGlobalAction(action_obj *Action) error

AddActionToJob adds an action to a job job_key: the key of the job to add the action to action_obj: the action to add

func (*Workflow) ManifestAddJob

func (m *Workflow) ManifestAddJob(job *Job) error

AddJob adds a job to the manifest job: the job to add returns an error if the job already exists or if the job key is empty

func (*Workflow) ManifestCreateMeta

func (m *Workflow) ManifestCreateMeta(meta *MetaData)

AddMeta adds the meta data to the manifest overwriting any existing meta data meta: the meta data to add

func (*Workflow) ManifestCreateParameter

func (m *Workflow) ManifestCreateParameter(param *Parameter) error

ManifestCreateParameter creates a parameter in the manifest param: the parameter to create returns an error if the parameter already exists

func (*Workflow) ManifestDeleteActionFromJob

func (m *Workflow) ManifestDeleteActionFromJob(job_key string, action_key string) error

DeleteActionFromJob deletes an action from a job by key job_key: the key of the job to delete the action from action_key: the key of the action to delete returns an error if the job or action does not exist

func (*Workflow) ManifestDeleteJob

func (m *Workflow) ManifestDeleteJob(job_key string) error

DeleteJob delete a job from the manifest job_key: the key of the job to delete returns an error if the job does not exist

func (*Workflow) ManifestDeleteParameter

func (m *Workflow) ManifestDeleteParameter(param_key string) error

ManifestDeleteParameter deletes a parameter from the manifest param_key: the key of the parameter to delete returns an error if the parameter does not exist

func (*Workflow) ManifestGetJob

func (m *Workflow) ManifestGetJob(job_key string) *Job

func (*Workflow) ManifestUpdateMeta

func (m *Workflow) ManifestUpdateMeta(meta *MetaData)

UpdateMeta updates the meta data of the manifest meta: the meta data to update

func (*Workflow) MapTargetConfigValue

func (w *Workflow) MapTargetConfigValue(m interface{}, target interface{}) (interface{}, error)

MapTargetConfigValue will call the target config mapper function m - the template data target - the target to map returns the mapped target returns an error if the mapper function is not set

func (*Workflow) MapValuesToInput

func (m *Workflow) MapValuesToInput(map_data map[string]interface{}) error

MapValuesToInput will map the values in the map to the input of the current job map_data - the map of values to map to the input

func (*Workflow) ParseInterfaceMap

func (m *Workflow) ParseInterfaceMap(model *TemplateData, val map[string]interface{}) map[string]interface{}

ParseInterfaceMap will parse the interface map and replace its tokens model - the template data val - the map to parse returns the value of the map with the tokens replaced returns an error if the key is not found

func (*Workflow) ParseToken

func (m *Workflow) ParseToken(data *TemplateData, value string) (string, error)

ParseToken will parse the token string and replace any tokens with the values from the model data - the template data value - the value to parse Returns the parsed string Returns an error if the key is not found

func (*Workflow) RunAction

func (m *Workflow) RunAction(current_action *Action) error

RunAction will run the action - current_action - the action to run - returns - error

func (*Workflow) RunJob

func (m *Workflow) RunJob(key string, run_time_vars map[string]interface{}, params map[string]interface{}) error

RunJob will run the job with the given key key - the key of the job to run returns - error

func (*Workflow) RunSubWorkflow

func (m *Workflow) RunSubWorkflow(key string, inputs map[string]interface{}) error

RunSubWorkflow will run a SubWorkflow job with the given key key - the key of the job to run inputs - the inputs to the job returns - error

func (*Workflow) SaveManifest

func (m *Workflow) SaveManifest(file_name string) error

SaveManifest saves the manifest file_name: the name of the file to save returns an error if the manifest is not valid

func (*Workflow) SetAnswers

func (m *Workflow) SetAnswers(answers map[string]interface{})

SetAnswers will set the answers for the workflow answers - the answers to set

func (*Workflow) SetBasePath

func (m *Workflow) SetBasePath(base_path string)

SetBasePath will set the base path of the manifest file base_path - the base path of the manifest file

func (*Workflow) SetCurrentActionIndex

func (m *Workflow) SetCurrentActionIndex(index int) error

SetCurrentActionIndex will set the current action index index - the index to set returns an error if the index is out of range or if the index is greater than the next action

func (*Workflow) SetTemplateFuncMap

func (m *Workflow) SetTemplateFuncMap(f template.FuncMap)

SetTemplateFuncMap sets the template function map

func (*Workflow) SetValueToDataBucket

func (m *Workflow) SetValueToDataBucket(key string, name string, value interface{})

dataBucket is a map of maps that can be used to store data between actions - key is the name of the bucket - name is the name of the value - value is the data to store

func (*Workflow) Template

func (m *Workflow) Template(val string, custom ...interface{}) (string, error)

Template will parse the token string and replace the tokens with the custom data val - the value to parse custom - the custom data to use as a string `key=value` or a map Returns the parsed string Returns an error if the value could not be parsed

func (*Workflow) TemplateMap

func (m *Workflow) TemplateMap(val string, custom map[string]interface{}) (string, error)

TemplateMap will parse the token string and replace the tokens with the custom data val - the value to parse custom - the custom data to use Returns the parsed string Returns an error if the value could not be parsed

func (*Workflow) UpdateWorkflow

func (m *Workflow) UpdateWorkflow(opts ...WorkflowOption) *Workflow

UpdateWorkflow updates the workflow - opts: the workflow options returns: the workflow

type WorkflowOption

type WorkflowOption func(*Workflow)

WorkflowOption is a function that sets a workflow option

func OptionWorkflowLogLevel

func OptionWorkflowLogLevel(v int64) WorkflowOption

OptionWorkflowLogLevel sets the LogLevel option 0 = quiet 1 = info 2 = LogLevel

func OptionWorkflowManifest

func OptionWorkflowManifest(v Manifest) WorkflowOption

OptionWorkflowManifest sets the manifest option - v: the manifest

type WriteConfigFunc

type WriteConfigFunc func(key string, value interface{}, custom ...string) error

WriteConfigFunc is the function definition that needs to be implemented to be able to write config values to the config store of choice - key: the key to write - value: the value to write - custom: the custom data that is used to to pass data to the config function

Jump to

Keyboard shortcuts

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