Others

Index

All Others functions

Name Function header Example Result Description Errorhandling
clone func(a interface{}) (b interface{}) [[ $result := clone "This is a test string" ]] $result = “This is a test string” copies/clones an object to another object.
coalesce func(v …interface{}) interface{} [[ $result := coalesce "" "" "This" "is" "a" "test" "string" ]] $result = “This” takes a list of values and returns the first non-empty one.
default func(d interface{}, given …interface{}) interface{} [[ $result := default "This is a test string" ]] $result = “This is a test string” sets a simple default value.
empty func(given interface{}) bool [[ $result := empty "This is a test string" ]] $result = false returns true if the given value is considered empty, and false otherwise.
env func(s string) string [[ $result := env "ENVTEST1" ]] $result = “envValue1” reads the environment variables based on the variable name.
expandenv func(s string) string [[ $result := expandenv "A ${FIELDNAME1} and $FIELDNAME2" ]] $result = “A $FIELDNAME2 X and NEW VALUE FOR field 2” expands the environment variable to present the value.
fail func(msg string) (string, error) [[ $result := fail "failed function: workflow still is running" ]] $result = fail “failed function: workflow still is running” returns an empty string and an error with the specified text.
fatal func(msg string) bool [[ $result := fatal "Fatal Ingrid: programm stopped because of error" ]] no result, Program is exited immediately stops/kills the program.
flushCache func() bool [[ $result := flushCache ]] $result = true clears the data cache.
get func(key string) interface{} [[ $result := get "SetLocal1" ]] $result = “This is a local teststring” the value of the named local variable.
getCache func(key string) interface{} [[ $result := getCache "Entry1" ]] $result = “Cache Value 1” get the value of named cached variable.
getg func(key string) interface{} [[ $result := getg "globalsimple" ]] $result = “This is a test string” get the value of a global variable.
getGlobals func() Data [[ $result := getGlobals ]] $result = “map[initiator:[ingrid-api] runtime_version:[…” get the values of all global variables.
hasCache func(key string) bool [[ $result := hasCache "datafield1" ]] $result = true or false (if named cachefield not exists) checks a data variable, if it exists.
hasgVar func(key string) bool [[ $result := hasgVar "Var1" ]] $result = true checks a global variable, if it exists.
hasVar func(key string) bool [[ $result := hasVar "_Var1" ]] $result = true checks a local variable, if it exists.
listCache func() (keys []string) [[ $result := listCache ]] $result = [datafield1] shows all data variables.
listgVar func() (keys []string) [[ $result := listgVars ]] $result = [globalvar1] shows all global variables.
listVars func() (keys []string) [[ $result := listVars ]] $result = [_Var1] shows all local variables.
nilToBlank func(err error) (msg string) no use case to use this function in a workflow ingrid always generates a error object or bool in actual release.
set func(key string, value interface{}) string [[ $result := set "_Var1" "Value 1" ]] $result = “_Var1” creates a new local field with corresponding value.
setCache func(key string, value interface{}) string [[ $result := setCache "datafield1" "Value 1" ]] $result = “datafield1” creates a new cache field with corresponding value.
setg func(key string, value interface{}) string [[ $result := setg "globalvar1" "Value 1" ]] $result = “globalvar1” creates a new gobal variable field with corresponding value.
setGlobals func(data pkgmsg.Data) bool no use case to use this function in a workflow creates a new globals field with corresponding value.
sleep func(value int) bool [[ sleep 1000 ]] sleep for 1 second or 1’000 millisecond sleeps the amount of time in milliseconds.
ternary func(vt interface{}, vf interface{}, v bool) interface{} [[ $result := ternary "This is a test string" "is not showing" true ]] $result = “This is a test string” takes two values, and a test value. If the test value is true, the first value will be returned. If the test value is empty, the second value will be returned.
until func(count int) []int [[ $result := until 5 ]] $result = [0 1 2 3 4] builds a range of integers.
untilStep func(start int, stop int, step int) []int [[ $result := untilStep 4 10 2 ]] $result = [4 6 8] is like until, untilStep generates a list of counting integers. But it allows you to define a start, stop, and step.
uuidv4 func() string [[ $result := uuidv4 ]] $result = “1483d529-221c-4ebd-b031-9ff0f4419937” can generate UUID v4 universally unique IDs.

clone

func(a interface{}) (b interface{})

The clone function copies/clones an object to another object.

Examples


[[ $result := clone "This is a test string" ]]
$result = "This is a test string"

coalesce

func(v ...interface{}) interface{}

The coalesce function takes a list of values and returns the first non-empty one.

Examples


[[ $result := coalesce "" "" "This" "is" "a" "test" "string" ]]
$result = "This"

[[ $result := coalesce 0 1 2 "Teststring" "9" ]]
$result = 1

[[ $result := coalesce "0" "1" "2" "Teststring" "9" ]]
$result = "0"

default

func(d interface{}, given ...interface{}) interface{}

The default function sets a simple default value.

Application notes / Limits:

  • The definition of “empty” depends on type:

    • Numeric: 0
    • String: “”
    • Lists: []
    • Dicts: {}
    • Boolean: false
    • And always nil (aka null)

For structs, there is no definition of empty, so a struct will never return the default.

Examples


[[ $result := default "This is a test string" ]]
$result = "This is a test string"

[[ $result := default 1234 ]]
$result = 1234

In the below:, if .Bar evaluates to a non-empty value, it will be used. But if it is empty, foo will be returned instead.
[[ $string1 := "A" ]]
[[ $result  := default 1 $string1 ]]
$result = "A"

[[ $string1 := "" ]]
[[ $result  := default 1 $string1 ]]
$result = 1

empty

func(given interface{}) bool

The empty function returns true if the given value is considered empty, and false otherwise.

Application notes / Limits:

  • Note that in Go template conditionals, emptiness is calculated for you. Thus, you rarely need if empty .Foo. Instead, just use if .Foo.

Examples


[[ $result := empty "This is a test string" ]]
$result = false

[[ $result := empty "" ]]
$result = true

env

func(s string) string

The env function reads the environment variables based on the variable name. The environment variables are the parameter to configure the workflow.

Application notes / Limits:

  • is it a container: set ENV-Paramter to start the container and workflow
  • is it a developer: you can set the ENV-parameter within the launch.json (e.g. visual code)

Examples

{
  "_comment": "example with env-parameter from launch.json",
  "env": {
    "ENVTEST1": "envValue1", 
  }
}


[[ $result := env "ENVTEST1" ]]
$result = "envValue1"

expandenv

func(s string) string

The expandenv function expands the environment variable in a string variable to present the value.

Application notes / Limits:

  • if env parameter doesn’t exists, function returns an empty string.

Examples

{
  "_comment": "example with env-parameter from launch.json",
  "env": {
    "FIELDNAME1": "$FIELDNAME2 X",
    "FIELDNAME2": "NEW VALUE FOR field 2",
  }
}


[[ $result := expandenv "A ${FIELDNAME1} and $FIELDNAME2" ]]
$result = "A $FIELDNAME2 X and NEW VALUE FOR field 2"

[[ $result := expandenv ( expandenv "A ${FIELDNAME1} and $FIELDNAME2" ) ]]
$result = "A NEW VALUE FOR field 2 X and NEW VALUE FOR field 2"

fail

func(msg string) (string, error)

The fail function returns an empty string and an error with the specified text. This is useful in scenarios where other conditionals have determined that template rendering should fail.

Examples


[[ $result  := fail "failed function: workflow still is running" ]]
$result = 
{
    "data": {
        "Code": 400,
        "Message": "template: tmpl:192:17: executing \"Activity_1o6w7at\" at <fail $string1>: error calling fail: failed function: workflow still is running",
        "Control": {},
        "Data": {},
        "List": []
    }
}

fatal

func(msg string) bool

The fatal function stops/kills the program.

Examples


[[ $result := fatal "Fatal Ingrid: programm stopped because of error" ]]
$result = Programm has stopped running. It was killed.

flushCache

func() bool

The flushCache function clears the data cache.

Application notes / Limits:

Examples


[[ $result := flushCache ]]
$result = true

get

func(key string) interface{}

The get function get the value of the named local variable.

Application notes / Limits:

Examples


[[ set "SetLocal1" "This is a local teststring" ]]
[[ $result := get "SetLocal1" ]]
$result = "This is a local teststring"

getCache

func(key string) interface{}

The getCache function get the value of named cached variable.

Application notes / Limits:

Examples


[[ setCache "Entry1" "Cache Value 1" ]]
[[ $result := getCache "Entry1" ]]
$result = "Cache Value 1"

getg

func(key string) interface{}

The getg function get the value of a global variable.

Application notes / Limits:

Examples


[[ setg "globalsimple" "This is a test string"  ]]
[[ $result := getg "globalsimple" ]]
$result = "This is a test string"

[[ setg "globalkeyvalue" (dict "name" "Muster" ) ]]
[[ $result := getg "globalkeyvalue"  ]]
$result = "map[name:Muster]"

nil as result. Need the name of the global variable to get the value.
[[ $string1 := "This is a test string" ]]
[[ setg "SetGlobal1" $string1 ]]
$result = nil

getGlobals

func() Data

The getGlobals function get the values of all global variables.

Application notes / Limits:

Examples


[[ $result := getGlobals ]]
$result = "map[initiator:[ingrid-api] runtime_version:[..."

hasCache

func(key string) bool

The hasCache function checks a data variable, if it exists.

Application notes / Limits:

Examples


[[ setCache "datafield1" "Value 1" ]]
[[ $result := hasCache "datafield1" ]]
$result = true

or false, if named cache field not exists
[[ $result := hasCache "field2" ]]
$result = false

hasgVar

func(key string) bool

The hasgVar function checks a global variable, if it exists.

Application notes / Limits:

Examples


[[ setg "Var1" "Value 1" ]]
[[ $result := hasgVar "Var1" ]]
$result = true

or false, if variable field not exists
[[ $result := hasgVar "Var2" ]]
$result = false

hasVar

func(key string) bool

The hasVar function checks a local variable, if it exists.

Application notes / Limits:

Examples


[[ set "_Var1" "Value 1" ]]
[[ $result := hasVar "_Var1" ]]
$result = true

or false, if variable field not exists
[[ $result := hasgVar "_Var2" ]]
$result = false

listCache

func() (keys []string)

The listCache function shows all data variables.

Application notes / Limits:

Examples


[[ setCache "datafield1" "Value 1" ]]
[[ $result := listCache ]]
$result = [datafield1]

listgVars

func() (keys []string)

The listgVars function shows all global variables.

Application notes / Limits:

Examples


[[ setg "globalvar1" "Value 1" ]]
[[ $result := listgVars ]]
$result = [globalvar1]

listVars

func() (keys []string)

The listVars function shows all local variables.

Application notes / Limits:

Examples


[[ set "_Var1" "Value 1" ]]
[[ $result := listVars  ]]
$result = [_Var1]

nilToBlank

func(err error) (msg string)

The nilToBlank function sets nil / null to blank.

Application notes / Limits:

  • ingrid always generates a error object or bool in actual release.
  • no use case to use this function in a workflow

Examples


we haven't done a test case.

set

func(key string, value interface{}) string

The set function creates a new local field with corresponding value.

Application notes / Limits:

Examples


[[ $result := set "_Var1" "Value 1" ]]
$result = "_Var1"

setCache

func(key string, value interface{}) string

The setCache function creates a new cache field with corresponding value.

Application notes / Limits:

Examples


[[ $result := setCache "datafield1" "Value 1" ]]
$result = "datafield1"

setg

func(key string, value interface{}) string

The setg function creates a new global variable field with corresponding value.

Application notes / Limits:

Examples


[[ $result := setg "globalvar1" "Value 1" ]]
$result = "globalvar1"

setGlobals

func(data pkgmsg.Data) bool   

The setGlobals function creates a new globals field with corresponding value.

Application notes / Limits:

Examples


we haven't done a test case.

sleep

func(value int) bool

The sleep function sleeps the amount of time in milliseconds.

Examples


[[ $result := sleep 1000 ]]
$result = true

ternary

func(vt interface{}, vf interface{}, v bool) interface{}

The ternary function takes two values, and a test value. If the test value is true, the first value will be returned. If the test value is empty, the second value will be returned.

Examples


[[ $result := ternary "This is a test string" "is not showing" true ]]
$result = "This is a test string"

[[ $result := ternary "This is a test string" "is false" false ]]
$result = "is false"


until

func(count int) []int

The until function builds a range of integers.

Examples


[[ $result := until 5 ]]
$result = [0 1 2 3 4]

untilStep

func(start int, stop int, step int) []int

The untilStep function is like until, untilStep generates a list of counting integers. But it allows you to define a start, stop, and step.

Application notes / Limits:

  • xx

Examples


[[ $result := untilStep 4 6 10 ]]
$result = [4]

[[ $result := untilStep 4 10 2 ]]
$result = [4 6 8]

[[ $result := untilStep 4 10 4 ]]
$result = [4 8]

uuidv4

func() string

The uuidv4 function can generate UUID v4 universally unique IDs.

Examples


result is unique, not repeatable
[[ $result := uuidv4 ]]
$result = "1483d529-221c-4ebd-b031-9ff0f4419937"