In addition to the default go template functions, this is a list of all available go template functions implemented by ourself:
Type | Name | Function header | Example | Result | Description | Errorhandling | Alias |
---|---|---|---|---|---|---|---|
date | ago | func(date interface{}) string | [[ $result := ago (dateModify now "-15m") ]] |
$result = “15m0s” | returns the duration time between a specific timestamp and now. | ||
date | date | func(date interface{}, fmt string) string | [[ $result := date 1638860002 "02.01.2006 03:04" ]] |
$result = “07.12.2021 07:53” | converts a date to the string specific output format. Date can be time, int, int32 or int64. | ||
date | dateInZone | func(date interface{}, fmt string, zone string) string | [[ $result := dateInZone ( toDate "2021-12-12T12:12:12+0100" "2006-01-02T15:04:05-0700" ) "02.01.2006 15:04" "Europe/Zurich" ]] |
$result = “12.12.2021 12:12” | zone can be “”, “UTC” or location name corresponding to a file in the IANA Time Zone database, such as “America/New_York” or “Europe/Zurich”. | ||
date | dateModify | func(date Time, duration string) Time | [[ $result := dateModify ( toDate "2021-12-12T12:12:12+0100" "2006-01-02T15:04:05-0700" ) "+01h30m20s" ]] |
$result = “2021-12-12 13:42:32 +0100 CET” | changes the output time with the entered duration time. You can add or substract time. | ||
date | htmlDate | func(date interface{}) string | [[ $result := htmlDate ( toDate "2021-12-12T12:12:12+0100" "2006-01-02T15:04:05-0700" ) ]] |
$result = “2021-12-12” | converts a date into a string for html. Output format is fix to YYYY-MM-DD, localtime. (HTML5 RFC 3339) | ||
date | htmlDateInZone | func(date Time, zone string) Time | [[ $result := htmlDateInZone ( toDate "2021-12-12T17:12:12+0100" "2006-01-02T15:04:05-0700" ) "Asia/Shanghai" ]] |
$result = “2021-12-13” | converts a date into a string for html for a specific timezone. Output format is fix to YYYY-MM-DD in the specific timezone. (HTML5 RFC 3339) | ||
date | now | func() time.Time | [[ $result := now ]] |
$result = “2021-12-06 10:59:00.1744468 +0100 CET m=+160.128715901” | returns the actual date and time. | ||
date | toDate | func(str string, fmt string) Time | [[ $result := toString (toDate "2021-12-07T12:12:12+0100" "2006-01-02T15:04:05-0700") ]] |
$result = “2021-12-07 12:12:12 +0100 CET” | converts a string to a date. The first argument is the date layout and the second the date string. | ||
date | unixEpoch | func(date Time) string | [[ $result := unixEpoch now ]] |
$result = “1638903549” | converts a date to a string in unix epoch format. | ||
string | after | func(value string, a string) string | [[ $result := after "This is a test string" "is" ]] |
$result = “ a test string” | Cuts the input string after the match/search string. | ||
string | abbrev | func(s string, width int) string | [[ $result := abbrev "this is a very long test string" 10 ]] |
$result = “this is…” | Cuts string and adds … if they are to long | ||
string | abbrevBoth | func(s string, left, right int) string | [[ $resulat := abbrevBoth "this is a very long test string" 5 10 ]] |
$result = “…is a…” | Cuts from left and right characters and replaces them with …, if string is large enough. | ||
string | adler32sum | func(input string) string | [[ $result := adler32sum "This is a test string" ]] |
$result = “1363740589” | Returns the adler32-hash of the source string. | ||
string | camelcase | func(str string) string | [[ $result := camelcase "this is a TeSt String" ]] |
$result = “ThisIsATestString” | Replaces a space or an underscores with a capital letter. Other capital letter will be replaced with lower case. | ||
string | cat | func(i interface…) string | [[ $result := cat "This is a test string" "100" "This is a test string2" ]] |
$result = “This is a test string 100 This is a test string2” | Concatenates strings together into 1 string | ||
string | contains | func(s string, substr string) bool | [[ $result := contains "This is a test string" "is a" ]] |
$result = true | Checks the string, if a specific search string occurs. If occurs = true, else = false | ||
string | hasPrefix | func(s string, prefix string) bool | [[ $result := hasPrefix "This is a test string" "Thi" ]] |
$result = true | Checks the string, if the string starts with the specified string. | ||
string | hasSuffix | func(s string, suffix string) bool | [[ $result := hassuffix "This is a test string" "ing" ]] |
$result = true | Checks the string, if the string ends with the specified string | ||
string | indent | func(v string, spaces int) string | [[ $result := indent "This is a test string" 5 ]] |
$result = “ This is a test string” | Indent the string based on the number with spaces. | ||
string | initials | func(s string) string | [[ $result := initials "This is a test string" ]] |
$result = “Tiats” | Contains all first letters from each word in the string. | ||
string | join | func(v interface{}, sep string) string | [[ $result := join "This","is","a","test","string" "_" ]] |
$result = “This_is_a_test_string” | Joins a list of strings into a single string, with the given separator. | ||
string | kebabcase | func(str string) string | [[ $result := kebabcase "This is a TeSt String" ]] |
$result = “this-is-a-te-st-string” | Replaces all spaces with a dash (-) and all upper case with a dash and the lower case character. | ||
string | lower | func(s string) string | [[ $result := toLower "This is a TEST String" ]] |
$result = “this is a teststring” | Converts all upper case characters to lower case | ||
string | nindent | func(v string, spaces int) string | [[ $result := nindent "This is a test string" 2 ]] |
$result = “\n This is a test string” | Is the same as the indent function, but prepends a new line to the beginning of the string. | ||
string | noescape | func(str string) HTML | stdout: [[ noescape "<b>This is a test string</b>" ]] |
On standard Log console = stdout: This is a test string | Doesn’t escape the string. Used for stdout/Console. | ||
string | nospace | func(str string) string | [[ $result := toUpper "This is a test string" ]] |
$result = “Thisisateststring” | Eliminiats all spaces in the string. | ||
string | plural | func(one string, many string, count int) string | [[ $result := plural "This is a test string" "This are plenty of strings" 1 ]] |
$result = “This is a test string” | Pluralize a string | ||
string | quote | func(i interface) string | [[ $result := quote "This is a test string" "This is a test string2" ]] |
$result = “\“This is a test string\” \“This is a test string2\“” | Inserts double quotes “ between strings. | ||
string | randAlpha | func(count int) string | [[ $result := randAlpha "5" ]] |
$result = “KjcNd” | Generates a random Alpha string with upper and lower case characters. | ||
string | randAlphaNum | func(count int) string | [[ $result := randAlphaNum 10 ]] |
$result = “E9ZsAHervv” | Contains random alpha and numeric characters | ||
string | randAscii | func(count int) string | [[ $result := randAscii 5 ]] |
$result = “AmaN&” | Generates a random Ascii string | ||
string | randNumeric | func(count int) string | [[ $result := randNumeric 5 ]] |
$result = “67336” | Generates a random numeric string. | ||
string | repeat | func(s string, count int) string | [[ $result := repeat "This is a test string" 5 ]] |
$result = “This is a test stringThis is a test stringThis is a test stringThis is a test stringThis is a test string” | Repeats the string based on the number. | ||
string | replace | func(src string, old string, new string) string | [[ $result := replace "This is a test string" "string" "replace" ]] |
$result = “This is a test replace” | Performs a simple string replacement. | ||
string | replaceLine | func(input, search, newline string) string | [[ $result := replaceLine "This is a test string" "test" "String test new" ]] |
$result = “String test new” | Replaces the source/input string, if a match with the search string occurs with the newline string. | ||
string | replaceLineAndIndent | func(input, search, newline string) string | [[ $result := replaceLineAndIndent "This is a test string" "test" "String test new" ]] |
$result = “ String test new” | replaces the source/input string, if a match with the search string occurs with the newline string and indent the line based on the source/input string. | ||
string | [sha1sum]./string(#sha1sum) | func(input string) string | [[ $result := sha1sum "This is a test string" ]] |
$result = “e2f67c772368acdeee6a2242c535c6cc28d8e0ed” | Returns the sha1-hash of the source string. | ||
string | sha256sum | func(input string) string | [[ $result := sha256sum "This is a test string" ]] |
$result = “717ac506950da0ccb6404cdd5e7591f72018a20cbca27c8a423e9c9e5626ac61” | Returns the sha256-hash of the source | ||
string | shuffle | func(str string) string | [[ $result := shuffle "This is a test string" ]] |
$result = “ asnrttsesiThgsi it” | Randomized order of same string | ||
string | snakecase | func(str string) string | [[ $result := snakecase "This is a TeSt string" ]] |
$result = “this_is_a_te_st_string” | Converts all upper to lower case and inserts additional an underscore “_” | ||
string | sortAlpha | func(list interface{}) []string | [[ $result := sortAlpha [ "öäü","<",".","A","a","!","$","1" ] ]] |
$result = [ “!”,”\$“,”.“,“1”,”<“,“A”,“a”,“öäü” ] | sorts a list of strings into alphabetical (lexicographical) order. | ||
string | splitList | func(orig string, sep string) []string | [[ $result := splitList "This is a #test string" "#" ]] |
$result = “[“This is a “,“test string”]” | Splits the source string based on separator and produces a array. [[ $result := splitList “This#is a #test string” “#” ]] | ||
string | split | func(orig string, sep string) []string | [[ $result := split "This is a #test string" "#" ]] |
$result = “[“This is a “,“test string”]” | Splits the source string based on separator and produces a array. | ||
string | splitnToMap | func(orig string, sep string, c int) map[string]string | [[ $result := splitnToMap "This is a test string" "test" 2]] |
$result = “{”_0”:“This is a “,”_1”:” string”} | Splits the source/orig string based on separator (sep) and the max split count ©, which produces a map with index keys.keys. | ||
string | splitToMap | func(orig string, sep string) map[string]string | [[ $result := splitToMap "This is a test string" "test" ]] |
$result = “{”_0”:“This is a “,”_1”:” string”}” | Splits the source string based on separator and produces a map with index keys. | ||
string | squote | func(i interface) string | [[ $result := quote "This is a test string" "This is a test string2" ]] |
$result = “‘This is a test string’ ‘This is a test string2’” | Inserts simple quotes ‘ between strings. | ||
string | substr | func(s string, start, end int) string | [[ $result := substr "This is a test string" 1 11 ]] |
$result = “his is a t” “St” | Cuts the string starting with start value end stop with the end value | ||
string | swapcase | func(str string) string | [[ $result := swapcase "This is a tESt String" ]] |
$result = “tHIS IS A TesT sTRING” | Changes lower case to upper and upper to lower case characters. | ||
string | title | func(s string) string | [[ $result := title "this is a test string" ]] |
$result = “This Is A Test String” | Converts the first letter of the word to upper case | ||
string | toLower | func(s string) string | [[ $result := toLower "This is a TEST String" ]] |
$result = “this is a teststring” | Converts all upper case characters to lower case | ||
string | toString | func(v interface{}) string | [[ $result := toString "[This is a test1 string" "This is a TEST2 string]" ]] |
$result = “[This is a test1 string This is a TEST2 string]” | Converts everything to a string. | ||
string | toStrings | func(v interface{}) []string | [[ $result := toStrings "This is a test string" ]] |
$result = [ “This is a test string” ] | Converts everything to a string array. | ||
string | toUpper | func(s string) string | [[ $result := toUpper "This is a teststring" ]] |
$result = “ “THIS IS A TESTSTRING” | Converts lower case charaters to upper case | ||
string | trim | func(s string) string | [[ $result := trim " This is a teststring " ]] |
$result = “This is a teststring” | Eliminates spaces at the beginning and end of a string | ||
string | trimAll | func(s string, cutset string) string | [[ $result := trimAll "aabHabb" "ab" ]] |
$result = “H” | Cuts characters from left and right, if any combination of cutset-characters matches. | ||
string | trimPrefix / stripPrefix | func(s string, prefix string) string | [[ $result := trimPrefix "This is a test string" "This " ]] |
$result = “is a test string” | Eliminates the characters from the beginning of the string. | ||
string | trimSuffix / stripSuffix | func(s string, suffix string) string | [[ $result := trimSuffix "This is a test string" " string" ]] |
$result = “This is a test” | Eliminates the suffix from the end of the string. | ||
string | trunc | func(s string, c int) string | [[ $result := trunc "This is a test string" 11 ]] |
$result = “This is a t” | Cuts from left to right depending on the integer value. | ||
string | untitle | func(s string) string | [[ $result := title "This Is A Test String" ]] |
$result = “this is a test string” | Converts the first letter of the word to lower case | ||
string | upper | func(s string) string | [[ $result := toUpper "This is a teststring" ]] |
$result = “THIS IS A TESTSTRING” | Converts lower case charaters to upper case | ||
string | wrap | func(str string, wrapLength int) string | [[ $result := wrap "This is a test string" 10 ]] |
$result = “This is a\ntest\nstring” | Replaces the space with a line breaks before the wrapLength has reached. | ||
string | wrapWith | func(str string, len int, sep string) string | [[ $result := wrapWith "This is a test string" 10 "+#+" ]] |
$result = “This is a+#+test+#+string” | Replaces space with the indiviual separator before the wrapLength has reached. It also splits long words. | ||
conversion | atoi | func(a string) int | [[ $result := atoi "1200" ]] |
$result = 1200 | equivalent converts a string to an integer | ||
conversion | float64 | func(v interface{}) float64 | [[ $result := float64 "1.200" ]] |
$result = 1.2 | converts to a float64 | ||
conversion | int64 | func(v interface{}) int64 | [[ $result := int64 "1200" ]] |
$result = 1200 | converts integer types to 64-bit integers | ||
conversion | int | func(v interface{}) int | [[ $result := int "1200" ]] |
$result = 1200 | converts to an int. | ||
conversion | toByte | func(s string) []byte | [[ $result := toByte "This is a Test String" ]] |
$result = “This is a Test String” | converts a string to a byte array | ||
arithmetic | add | func(i …interface{}) int64 | [[ $result := add 600 700 150 650 ) ]] |
$result = int64{2100} | adds two or more numbers and returns and int64 | ||
arithmetic | biggest | func(i …interface{}) int64 | [[ $result := biggest 600 700 50 650 ]] |
$result = int64{700} | returns the highest number from one or more numbers | ||
arithmetic | ceil | func(a interface{}) float64 | [[ $result := ceil "12.123 ]] |
$result = float64{13} | round up to the next int64 number without fractical part | ||
arithmetic | dec | func(i interface{}) int64 | [[ $result := dec "15" ]] |
result = int64{14} | decrement by 1 | ||
arithmetic | div | func(a, b interface{}) int64 | [[ $result := div 15 3 ]] |
result = int64{5} | divides a dividend with the divisor | ||
arithmetic | floor | func(a interface{}) float64 | [[ $result := floor 13.623 ]] |
result = float64{13} | round down to next int64 number without fractical part | ||
arithmetic | inc | func(i interface{}) int64 | [[ $result := dec "15" ]] |
result = int64{16} | increment by 1 | ||
arithmetic | max | func(i …interface{}) int64 | [[ $result := max 600 700 50 650 ]] |
$result = int64{700} | returns the highest number one or more numbers | ||
arithmetic | min | func(i …interface{}) int64 | [[ $result := min 600 700 50 650 ]] |
$result = int64{50} | returns the lowest number one or more numbers | ||
arithmetic | minus | func(a, b interface{}) int64 | [[ $result := minus 16 3 ]] |
$result = int64{13} | substracts the second number (b) from the first number (a) | ||
arithmetic | mod | func(a, b interface{}) int64 | [[ $result := mod 16 3 ]] |
$result = int64{1} | contains the remainder of a division | ||
arithmetic | mul | func(i …interface{}) int64 | [[ $result := mul 16 3 2 ]] |
$result = int64{96} | multiplies two or more numbers and returns and int64 | ||
arithmetic | plus | func(i …interface{}) int64 | [[ $result := plus 600 700 150 650 ]] |
$result = int64{2100} | adds two or more numbers and returns and int64 | ||
arithmetic | round | func(a float64) float64 | [[ $result := round ( float64 ( "12.5" ) ) ]] [[ $result := round ( float64 ( "12.49" ) ) ]] |
\$result = int64{13}<br>\$result = int64{12} | rounds up or down the number | ||
arithmetic | sub | func(a, b interface{}) int64 | [[ $result := sub 16 3 ]] |
$result = int64{13} | substracts the second number (b) from the first number (a) | ||
reflection | kindIs | func(src interface{}, target string) bool | [[ $result := toString (kindIs (int "12345") "int") ]] |
$result = true | will test the value and send back the object type and returns true also, if interface is a pointer to the type | ||
reflection | kindOf | func(src interface{}) string | [[ $result := kindOf (toByte "12345 This is a test string") ]] |
$result = slice | returns the kind of an object | ||
reflection | typeIs | func(src interface{}, target string) bool | [[ $result := toString (typeIs "int" "string") ]] |
$result = true | is like kindIs, but for types: typeIs “*io.Buffer” $myVal. | ||
reflection | typeIsLike | func(src interface{}, target string) bool | [[ $result := typeIsLike (typeIs (int "12345") "int") ]] |
$result = true | works as typeIs, except that it also dereferences pointers. | ||
reflection | typeOf | func(src interface{}) string | [[ typeOf (toByte "12345 This is a test string") ]] |
$result = []uint8 | returns the underlying type of a value: typeOf $foo and returns true also, if interface is a pointer to the type | ||
file-path | base | func(path string) string | [[ $result := toString (base "/usr/shared/Documents/test.md" ) ]] |
$result = “test.md” | The base function return the last element of the path. |
||
file-path | clean | func(path string) string | [[ $result := toString (clean "/usr/shared/Documents/test.md" ) ]] |
$result = “test.md” | The clean function returns the shortest path name equivalent to path by purely lexical processing. It applies the following rules iteratively until no further processing can be done: |
||
file-path | dir | func(path string) string | [[ $result := toString (dir "/usr/shared/Documents/test.md" ) ]] |
$result = “/usr/shared/Documents” | The dir function returns all but the last element of path, typically the path’s directory. |
||
file-path | ext | func(path string) string | [[ $result := toString (ext "/usr/shared/Documents/test.md" ) ]] |
$result = “.md” | The ext function returns the file name extension used by path. |
||
file-path | isAbs | func(path string) bool | [[ $result := toString (isAbs "/usr/shared/Documents/test.md" ) ]] |
$result = “true” | The ext function returns the file name extension used by path. If the path is relative, it contains false. |
||
encoding | b64dec / base64decode | func(v string) []byte | [[ $result := toString (b64dec "VGhpcyBpcyBhIHRlc3Qgc3RyaW5nCg==") ]] |
$result = “This is a test string\n” | The b64dec / base64decode function returns the decode value of the inputstring, which is formated in base64 |
||
encoding | b64enc / base64encode | func(v []byte) string | [[ $result := b64enc (toByte "-----BEGIN CERTIFICATE----- < Certificate >-----END CERTIFICATE-----\n") ]] |
$result = “LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tIDwgQ2VydGlmaWNhdGUgPi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K” | The b64enc / base64encode function converts a string into a base64 string. |
||
data-structure | append | func(list interface{}, v interface{}) []interface{} | [[ $result := push $result "AfterD" ]] |
$result = [A B C D AfterD] | adds an item onto the end of a list | ||
data-structure | dict | func(v …interface{}) map[string]interface{} | [[ $result := dict "field1" "This is a test string" ]] |
$result = map[field1:This is a test string] | returns a map with key value pairs. | ||
data-structure | first | func(list interface{}) interface{} | [[ $result := first (list "field1" "field2") ]] |
$result = field1 | returns the first item on a list. | ||
data-structure | has | func(haystack interface{}, needle interface{}) bool | [[ $result := has (list "A" "B" "C") "B" ]] |
$result = true | Test to see if a list has a particular element. | ||
data-structure | initial | func(item interface{}) []interface{} | [[ $result := initial ( list "A" "B" "C" ) ]] |
$result = [A B] | returns all items from a list without the last item. | ||
data-structure | keys | func(dicts …map[string]interface{}) []string | [[ $result := keys ( dict "F2" "B" "F3" "C" ) ]] |
$result = [F2 F3] | returns all keys from a map | ||
data-structure | last | func(list interface{}) interface{} | [[ $result := last ( list "A" "B" "C" ) ]] |
$result = C | returns the last item from a list. | ||
data-structure | list | func(v …interface{}) []interface{} | [[ $result := list 1 2 3 4 ]] |
$result = [1 2 3 4] | provides a simple list type that can contain arbitrary sequential lists of data. | ||
data-structure | listContains | func(haystack interface{}, needle interface{}) bool | [[ $result := has (list "A" "B" "C") "B" ]] |
$result = true | Test to see if a list has a particular element. | ||
data-structure | mapSet | func(d map[string]interface{}, key string, value interface{}) map[string]interface{} | [[ $result := mapSet $map "F4" "D" ]] |
$result = map[F1:A F4:D] | defines a map based on a key and a value. | ||
data-structure | mapUnset | func(d map[string]interface{}, key string) map[string]interface{} | [[ $result := mapUnset $result "fieldinteger2" ]] |
$result = map[] | removes a map/key value pair in a mapset. | ||
data-structure | merge | func(dst map[string]interface{}, srcs …map[string]interface{}) interface{} | [[ $result := merge $map1 $map2 ]] |
$result = map[firstName:Max lastName:Muster] | merges 2 maps to 1 map. | ||
data-structure | mergeOverwrite | func(dst map[string]interface{}, srcs …map[string]interface{}) (interface{}, error) | [[ $result := mergeOverwrite $map30 $map31 ]] |
$result = map[lastName:Huber] | overwrites a map based on the key. | X | |
data-structure | omit | func(dict map[string]interface{}, keys …string) map[string]interface{} | [[ $result := omit $map "F1" "F3" ]] |
$result = map[F2:B] | is similar to pick, except it returns a new dict with all the keys that do not match the given keys. | ||
data-structure | pick | func(dict map[string]interface{}, keys …string) map[string]interface{} | [[ $result := pick $map "F2" ]] |
$result = map[F2:B] | selects just the given keys out of a dictionary, creating a new dict. | ||
data-structure | pluck | func(key string, d …map[string]interface{}) []interface{} | [[ $result := pluck "F2" $map ]] |
$result = [B] | makes it possible to give one key and multiple maps, and get a list of all of the matches. | ||
data-structure | prepend | func(list interface{}, v interface{}) []interface{} | [[ $result := prepend $list "BeforeA" ]] |
$result = [BeforeA A B C D] | adds an item onto the beginning of a list. | ||
data-structure | push | func(list interface{}, v interface{}) []interface{} | [[ $result := push $result "AfterD" ]] |
$result = [A B C D AfterD] | adds an item onto the end of a list | ||
data-structure | rest | func(list interface{}) []interface{} | [[ $result := rest ( list 1 2 3 4 ) ]] |
$result = [2 3 4] | get the tail of the list (everything but the first item). | ||
data-structure | reverse | func(v interface{}) []interface{} | [[ $result := reverse ( list 1 2 3 4 ) ]] |
$result = “[4 3 2 1]” | Produce a new list with the reversed elements of the given list. | ||
data-structure | slice | func(list interface{}, indices …interface{}) interface{} | [[ $result := slice ( list 1 2 3 4 5 ) 1 4 ]] |
$result = [2 3 4] | cuts/slices a list | ||
data-structure | uniq | func(list interface{}) []interface{} | [[ $result := uniq ( list 1 1 2 2 )]] |
$result = [2 3] | contains only unique list entries. | ||
data-structure | values | func(dict map[string]interface{}) []interface{} | [[ $result := values ( mapSet ( dict "F1" "A" ) "F4" "D" ) ]] |
$result = [A D] | contains an array with all the values of the map. | ||
data-structure | without | func(list interface{}, omit …interface{}) []interface{} | [[ $result := without ( list 1 2 3 4 ) 3 ]] |
$result = [1 2 4] | filters items out of a list. | ||
crypto | buildCustomCert | func(b64cert string, b64key string) (certificate, error) | [[ $result := buildCustomCert $cert $key ]] |
$result.Key / $result.Cert contains a new Certificate signed by the CA | creates a custom certificate based on a the CA. | [X] | |
crypto | derivePassword | func(counter uint32, passwordType string, password string, user string, site string) string | [[ $result := toString (derivePassword (int "12345") "maximum" "passwordtest" "max muster" "test.example.com") ]] |
$result = “h0l74EUVH0Sr1TtHM55” | generates a password based on the diverse input parameters. | ||
crypto | genCA | func(cn string, daysValid int) (certificate, error) | [[ $result := toString (genCA "testca.example.com" (int "3650")) ]] |
$result.Key = “< CA private key>” / $result.Cert = “< CA Certificate>” | generates a digital certificate for a certificate authority (CA) | [X] | |
crypto | genPrivateKey | func(typ string) string | [[ $result := toString (genPrivateKey "") ]] |
$result.Key = “< private key >” / $result.Cert = “< Certificate >” | generates a private key based on the required key type e.g. rsa / dsa / ecdsa | ||
crypto | genSelfSignedCert | func(cn string, ips []string, alternateDNS []string, daysValid int) (certificate, error) | [[ $result := genSelfSignedCert "test.example.com" (split "10.0.0.1,10.100.0.1" "," ) (split "san1.muster.max,example.com,ingrid.example.com" ",") 365 ]] |
$result.Key = “< private key >” / $result.Cert = “< Certificate >” | generates a self signed certificate based on several input parameter | [X] | |
crypto | genSignedCert | func(cn string, ips []string, alternateDNS []string, daysValid int, ca certificate) (certificate, error) | [[ $result := genSignedCert "test.example.com" (split "10.0.0.1,10.100.0.1" "," ) (split "san1.muster.max,example.com,ingrid.example.com" ",") 365 $ca ]] |
$result.Key = “< private key >” / $result.Cert = “< Certificate >” | generates a signed certificate based on several input parameter and a certificate authority (CA) certificate | [X] | |
regex | regexFind | func(s string, regex string) string | [[ $result := toString (regexFind "This is a test string" "^This") ]] |
$result = “This” | returns the first (left most) match of the regular expression in the input | ||
regex | regexFindAll | func(s string, regex string, n int) []string | [[ $result := toString (regexFindAll "This is a test string" "test" 1) ]] |
$result = “[test]” | returns a slice of all matches of the regular expression in the input string. The last parameter n determines the number of substrings to return, where -1 means return all matches. |
||
regex | regexMatch | func(s string, regex string) bool | [[ $result := toString (regexMatch "This is a test string" "test") ]] |
$result = true | returns true if the input string contains any match of the regular expression. | ||
regex | regexReplaceAll | func(s string, regex string, repl string) string | [[ $result := toString (regexReplaceAll "This is a test string" "test" "TesT Replace") ]] |
$result = “This is a TesT Replace string” | returns a copy of the input string, replacing matches of the Regexp with the replacement string replacement. | ||
regex | regexReplaceAllLiteral | func(s string, regex string, repl string) string | [[ $result := toString (regexReplaceAllLiteral "This is a test string" "test" "TesT Replace") ]] |
$result = “This is a TesT Replace string” | difference to regexReplaceAll: The replacement string is substituted directly, without using Expand | ||
regex | regexSplit | func(s string, regex string, n int) []string | [[ $result := toString (regexSplit "This is a test string" "s" 2) ]] |
$result = “[Thi is a test string]” | slices the input string into substrings separated by the expression and returns a slice of the substrings between those expression matches. | ||
marshal | marshal | func(v interface{}) string | [[ $result := toString (marshal "This is a test string") ]] |
$result = “\“This is a test string\“”` | converts an GO object to a JSON object | ||
marshal | marshalIndent | func(v interface{}) string | [[ $result := toString ( marshalIndent $data ) ]] check code example to create the $data object |
$result = “{\n \“teststring\”: [\n \“This\“,\n \“is\“,\n \“a\“,\n \“Test String\”\n ]\n}”` | indent the object with 2 additional positions per JSON level. | ||
marshal | marshalJson | func(v interface{}) string | [[ $result := toString (marshal "This is a test string") ]] |
$result = “\“This is a test string\“”` | converts an GO object to a JSON object | ||
marshal | marshalJsonIndent | func(v interface{}) string | [[ $result := toString ( marshalIndent $data ) ]] check code example to create the $data object |
$result = “{\n \“teststring\”: [\n \“This\“,\n \“is\“,\n \“a\“,\n \“Test String\”\n ]\n}”` | indent the object with 2 additional positions per JSON level. | ||
marshal | marshalYaml | func(data interface{}) string | [[ $result := toString ( marshalYaml $data ) ]] check code example to create the $data object |
$result = “teststring:\n- This\n- is\n- a\n- Test String\n” | converts an object to a YAML object | ||
marshal | toJson | func(v interface{}) string | [[ $result := toString (marshal "This is a test string") ]] |
$result = “\“This is a test string\“”` | converts an GO object to a JSON object | ||
marshal | toPrettyJson | func(v interface{}) string | [[ $result := toString ( marshalIndent $data ) ]] check code example to create the $data object |
$result = “{\n \“teststring\”: [\n \“This\“,\n \“is\“,\n \“a\“,\n \“Test String\”\n ]\n}”` | indent the object with 2 additional positions per JSON level. | ||
marshal | unmarshal (still in development) | func(source string) (data interface{}) | [[ $v := unmarshal "['abc', 'cde']" ]] |
$v contains a new object depends on the input. in this case its a array | |||
marshal | unmarshalYaml (still in development) | func(source string) (data interface{}) | [[ $v := unmarshalYaml $myyamlstring ]] |
$v contains a new object depends on the input | |||
others | 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. | ||
others | 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. | ||
others | 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. | ||
others | 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. | ||
others | env | func(s string) string | [[ $result := env "ENVTEST1" ]] |
$result = “envValue1” | reads the environment variables based on the variable name. | ||
others | 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. | ||
others | 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. | ||
others | fatal | func(msg string) bool | [[ $result := fatal "Fatal Ingrid: programm stopped because of error" ]] |
no result, Program is exited immediately | stops/kills the program. | ||
others | flushCache | func() bool | [[ $result := flushCache ]] |
$result = true | clears the data cache. | ||
others | get | func(key string) interface{} | [[ $result := get "SetLocal1" ]] |
$result = “This is a local teststring” | the value of the named local variable. | ||
others | getCache | func(key string) interface{} | [[ $result := getCache "Entry1" ]] |
$result = “Cache Value 1” | get the value of named cached variable. | ||
others | getg | func(key string) interface{} | [[ $result := getg "globalsimple" ]] |
$result = “This is a test string” | get the value of a global variable. | ||
others | getGlobals | func() Data | [[ $result := getGlobals ]] |
$result = “map[initiator:[ingrid-api] runtime_version:[…” | get the values of all global variables. | ||
others | hasCache | func(key string) bool | [[ $result := hasCache "datafield1" ]] |
$result = true or false (if named cachefield not exists) | checks a data variable, if it exists. | ||
others | hasgVar | func(key string) bool | [[ $result := hasgVar "Var1" ]] |
$result = true | checks a global variable, if it exists. | ||
others | hasVar | func(key string) bool | [[ $result := hasVar "_Var1" ]] |
$result = true | checks a local variable, if it exists. | ||
others | listCache | func() (keys []string) | [[ $result := listCache ]] |
$result = [datafield1] | shows all data variables. | ||
others | listgVar | func() (keys []string) | [[ $result := listgVars ]] |
$result = [globalvar1] | shows all global variables. | ||
others | listVars | func() (keys []string) | [[ $result := listVars ]] |
$result = [_Var1] | shows all local variables. | ||
others | 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. | |||
others | set | func(key string, value interface{}) string | [[ $result := set "_Var1" "Value 1" ]] |
$result = “_Var1” | creates a new local field with corresponding value. | ||
others | setCache | func(key string, value interface{}) string | [[ $result := setCache "datafield1" "Value 1" ]] |
$result = “datafield1” | creates a new cache field with corresponding value. | ||
others | setg | func(key string, value interface{}) string | [[ $result := setg "globalvar1" "Value 1" ]] |
$result = “globalvar1” | creates a new gobal variable field with corresponding value. | ||
others | setGlobals | func(data pkgmsg.Data) bool | no use case to use this function in a workflow | creates a new globals field with corresponding value. | |||
others | sleep | func(value int) bool | [[ sleep 1000 ]] |
sleep for 1 second or 1’000 millisecond | sleeps the amount of time in milliseconds. | ||
others | 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. | ||
others | until | func(count int) []int | [[ $result := until 5 ]] |
$result = [0 1 2 3 4] | builds a range of integers. | ||
others | 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. | ||
others | uuidv4 | func() string | [[ $result := uuidv4 ]] |
$result = “1483d529-221c-4ebd-b031-9ff0f4419937” | can generate UUID v4 universally unique IDs. | ||
ingrid-request | setTimeout | func(seconds int) bool | [[- $_ := setTimeout 5 ]] |
sets the Timeout for Ingrid Calls and executes | |||
ingrid-request | defaultTimeout | func() bool | [[- $_ := defaultTimeout ]] |
sets the Timeout to default for Ingrid Calls and executes | |||
ingrid-request | newRequest | func() IngridMsg | [[ $v := newRequest ]] |
$v contains a new empty Ingrid Request | |||
ingrid-request | getRequest | func() IngridMsg | [[ $v := getRequest ]] |
$v contains the current Request, that was sent to the Workflow | |||
ingrid-request | setRequest | func(r IngridMsg) bool | [[ $v := setRequest $req ]] |
Sets the $req object as current Request. $v contains the new Request | |||
ingrid-request | getRequestClass | func(msg IngridMsg) string | [[ $v := getRequestClass $req ]] |
$v contains the Class of the Ingrid Request $req | |||
ingrid-request | getRequestData | func(msg IngridMsg) Data | [[ $v := getRequestData $req ]] |
$v contains the Data from the Ingrid Request $req | |||
ingrid-request | getRequestOperation | func(msg IngridMsg) string | [[ $v := getRequestOperation $req ]] |
$v contains the Operation of the Ingrid Request $req | |||
ingrid-request | setRequestClass | func(msg IngridMsg, value string) IngridMsg | [[ $v := setRequestClass $req "User" ]] |
sets the Class of the Request $req to “User”. $v contains the new Request | |||
ingrid-request | setRequestData | func(msg IngridMsg, value Data) IngridMsg | [[ $v := setRequestData $req $data ]] |
sets the Data on the Request $req to $data. $v contains the new Request | |||
ingrid-request | getRequestControl | func(msg IngridMsg) Data | [[ $v := getRequestControl $req ]] |
$v contains the Controls of the Request $req | |||
ingrid-request | setRequestList | func(msg IngridMsg, values []Data) IngridMsg | [[ $v := setRequestList $req $list ]] |
sets the List object to the Data Array $list. $v contains the new Request | |||
ingrid-request | setRequestOperation | func(msg IngridMsg, value string) IngridMsg | [[ $v := setRequestOperation $req "YourOp"]] |
sets the Operation of $req to “YourOp”. $v contains the new Request | |||
ingrid-request | getRequestID | func(msg IngridMsg) string | [[ $v := getRequestID $req]] |
get the RequestID of the Request $req | |||
ingrid-request | setRequestControl | func(msg IngridMsg, value string) IngridMsg | [[ $v := setRequestControl $req $controls ]] |
sets the Control of the Request $req to $controls. $v contains the new Request | |||
data | newData | func() Data | [[ $v := newData ]] |
$v contains a new Data object | |||
data | addValue | func(data Data, name string, value string) Data | [[ $v := addValue $data "key" "value" ]] |
$v contains the $data object with the “value” added to the attribute “key” | |||
data | addValues | func(data Data, name string, values []string) Data | [[ $v := addValues $data "key" $values ]] |
$v contains the $data object with the array $values added to the attribute “key” | |||
data | clearValue | func(data Data, name string) Data | [[ $v := clearValue $data "key" ]] |
$v contains the $data object with the attribute “key” removed | |||
data | getValue | func(data Data, name string) string | [[ $v := getValue $data "key" ]] |
$v contains the value of the attribute “key” from $data | |||
data | getValues | func(data Data, name string) []string | [[ $v := getValues $data "key" ]] |
$v contains the values array of the attribute “key” from $data | |||
data | setValue | func(data Data, name string, value string) Data | [[ $v := setValue $data "key" "value" ]] |
$v contains the $data object with the attribute “key” set to “value” (replace) | |||
data | setValues | func(data Data, name string, values []string) Data | [[ $v := setValues $data "key" $values ]] |
$v contains the $data object with the attribute “key” set to $values (replace) | |||
data | getKeys | func getKeys(data Data) []string | [[ $v := getKeys $data ]] |
$v contains all the keys exists in the $data object | |||
list | newList | func() []Data | [[ $v := newList ]] |
$v contains a new empty List of Data Objects | |||
list | addDataToList | func(list []Data, data Data) []Data | [[ $v := addDataToList $list $data ]] |
$v contains the List $list with $data Added as new entry to it | |||
list | hasList | func(result Result) bool | [[ $v := hasList $result ]] |
$v is true if $result contains a List Object with entries | |||
result | newResult | func() Result | [[ $v := newResult ]] |
$v contains a new Result Object | |||
result | getResult | func() Result | [[ $v := getCurrentResult ]] |
$v contains the Result object from the current Request | |||
result | setResult | func(result Result) bool | [[ setCurrentResult $res ]] |
sets the Result object $res as the current Requests Result | |||
result | getResult | func(msg IngridMsg) Result | [[ $v := getResult $msg ]] |
$v contains the Result object from the given Message Object $msg | |||
result | setResult | func(msg IngridMsg, result Result) IngridMsg | [[ $v := setResult $msg $res ]] |
sets the Result object $res on the given Message Object $msg and returns a new Message Object | |||
result | getResultCode | func(result Result) int | [[ $v := getResultCode $res ]] |
$v contains the Result Code from the $res result Object | |||
result | getResultData | func(result Result) Data | [[ $v := getResultData $res ]] |
$v contains the Result Data from the $res result Object | |||
result | getResultList | func(result Result) []Data | [[ $v := getResultList $res ]] |
$v contains the Result List from the $res result Object | |||
result | getResultMsg | func(result Result) string | [[ $v := getResultMsg $res ]] |
$v contains the Result Message from the $res result Object | |||
result | setResultCode | func(result Result, code int) Result | [[ $v := setResultCode $res 400 ]] |
$v contains the $res Result Object with the Code set to 400 | |||
result | setResultData | func(result Result, data Data) Result | [[ $v := setResultData $res $data ]] |
$v contains the $res Result Object with the Data set to $data | |||
result | setResultList | func(result Result, data []Data) Result | [[ $v := setResultList $res $list ]] |
$v contains the $res Result Object with the List set to $list | |||
result | setResultMsg | func(result Result, msg string) Result | [[ $v := setResultMsg $res "It Went Wrong" ]] |
$v contains the $res Result Object with the Message set to “It Went Wrong” | |||
control | newControl | func() Data | [[ $v := newControl ]] |
$v contains new Control structure. | It is the same as Data. You can use all the Data functions on it | ||
calls | ingridCall | func(slap string, v interface{}) (Data IngridMsg) | [[ $v := ingridCall "main" $req ]] |
Sends a Request to the hive to Slap “main”. $v contains a request, that should contain a Result | |||
calls | ingridCallRaw | func(slap string, data string) []byte | [[ $v := ingridCallRaw "another_slap" $myrawdata ]] |
Sends a Request to the hive to Slap “another_slap” with the Raw Data of $myrawdata. $v will be a array of bytes with the response in it | |||
calls | ingridExec | func(slap string, v interface{}) (err error) | [[ $v := ingridExec "some_broadcast" $req ]] |
Sends a Request to the hive to Slap “some_broadcast”. $v should be nil unless there is a error while sending to the hive | |||
calls | log | func(severity string, message string) bool | [[ log "error" "log this error" ]] |
Sends a Log Message to the hive as error with the given message | |||
calls | logIt | func(severity string, actor string, message string) bool | [[ logIt "warn" "myworker" "log this error" ]] |
Sends a Log Message to the hive as warning with the given message and the given actor | |||
calls | audit | func(workflow string, process string, requestid string, version string, data string) bool | [[ audit "CoolWorkflow" "Step1" "1234" "1.0" "Audit this user request" ]] |
Send an Audit Message to the Hive. | |||
calls | auditIt | func(severity string, actor string, requestid string, message string, tags string) bool | [[ auditIt "warn" "myworker" "1234" "Audit this user request" "nutz" ]] |
Send an Audit Message to the Hive. | |||
calls | openIncident | func(incidentType string, message string, tags string, requestid string) bool | [[ openIncident "critical" "No db conn" "db-updater" "example-request-id" ]] |
Sends a incident message to the hive with open |
|||
calls | openIncidentRaw | func(incidentType string, actor string, message string, status string, tags string, requestid string, incidentid string) bool | [[ openIncidentRaw "critical" "mysql" "No db conn" "open" "db-updater" "example-request-id" "example-incident-id" ]] |
Sends a incident message to the hive with open |
|||
calls | closeIncident | func(incidentid string) bool | [[ closeIncident "example-id" ]] |
Sends a incident message to the hive with close |
|||
calls | closeAllIncidents | func(tag string) bool | [[ closeAllIncidents "db-updater" ]] |
Sends a incident message to the hive with closeall |
|||
metrics | newMeter | func() Meter | [[ $v := newMeter ]] |
$v contains new Meter Object | |||
metrics | startMeter | func(meter Meter) Meter | [[ $v := startMeter $meter ]] |
$v contains the $meter Object. The Meter has been started | |||
metrics | stopMeter | func(meter Meter) Meter | [[ $v := stopMeter $meter ]] |
$v contains the $meter Object with the Meter stopped | |||
metrics | getMeterSeconds | func(meter Meter) float64 | [[ $v := getMeterSeconds $meter ]] |
$v contains the seconds passed between start and stop | |||
metrics | getMeterNanos | func(meter Meter) float64 | [[ $v := getMeterNanos $meter ]] |
$v contains the Nanoseconds between start and stop | |||
metrics | getMeterDuration | func(meter Meter) Duration | [[ $v := getMeterDuration $meter ]] |
$v contains the duration beween start and stop | |||
metrics | addMetric | func(metrictype string, metricunit string, metricname string, metricid string, value interface{}, more string) bool | [[ addMetric "flow" "s" "meter1" "act1" (getMeterSeconds $meter) (print (getMeterDuration $meter)) ]] |
Adds a Metric entry to the stats with the measurement of a meter | |||
metrics | getMeta | func() Data | [[ $v := getMeta ]] |
$v contains the Meta Data (Data Object) | |||
metrics | setMeta | func(metadata Data) bool | [[ setMeta $data ]] |
Set the Meta Data on the Metric | |||
filesystem | saveFile | func(name string, content Data) error | [[ $v := saveFile "myfile" $content ]] |
$v contains an Error if the Data in the file could not be saved | |||
filesystem | loadFile | func(name string) content Data | [[ $v := loadFile "myfile" ]] |
$v contains a Data Object created from the Filecontent | |||
filesystem | saveRawFile | func(name string, content interface{}) error | [[ $v := saveRawFile "myfile" $content ]] |
$v contains an Error if the file could not be saved | |||
filesystem | loadRawFile | func(name string) interface{} | [[ $v := loadRawFile "myfile" ]] |
$v contains an byte array loaded from the Filecontent | |||
filesystem | saveListFile | func(name string, content []Data) error | [[ $v := saveListFile "myfile" $list]] |
$v contains an Error if the List Object could not be saved to the file | |||
filesystem | loadListFile | func(name string) (content []Data) | [[ $v := loadListFile "myfile" ]] |
$v contains a List of Data Objects loaded from the File | |||
filesystem | saveRequest | func(name string, content IngridMsg) error | [[ $v := saveRequest "myfile" $request ]] |
$v contains an Error if the Request Object could not be saved into the file | |||
filesystem | loadRequest | func(name string) (content IngridMsg) | [[ $v := loadRequest "myfile" ]] |
$v contains a Request Object loaded from the File | |||
logging | debug | func(objs …interface{}) bool | [[ debug "myfile" 123 ]] |
debugs the given objects | |||
mapping | setMapEntry | func(inmap map[string]string, key string, value string) map[string]string | [[ $v := setMapEntry $map "newkey" "newvalue" ]] |
$v contains the $map with the key “newkey” to to value “newvalue” | |||
mapping | newMap | func() map[string]string | [[ $v := newMap ]] |
$v contains a new map object | |||
mapping | mapData | func(inmap map[string]string, data Data) Data | [[ $v := mapData $map $data ]] |
maps the data from $data into $v according to the $map (maps keys) copies rest | |||
mapping | mapStrictData | func(inmap map[string]string, data Data) Data | [[ $v := mapStrictData $map $data ]] |
maps the data from $data into $v acording to the $map (maps only avilable keys) | |||
mapping | suffixReplace | func(inmap map[string]string, data Data) Data | [[ $v := suffixReplace $map $data ]] |
replaces suffixes in $data values according to key value from the $map | |||
mapping | prefixReplace | func(inmap map[string]string, data Data) Data | [[ $v := prefixReplace $map $data ]] |
replaces prefixed in $data values according to key value from the $map | |||
error | addError | func ( err error ) bool | [[ addError (newError "my Error: This is a test string" )]] |
“my Error: This is a test string” | adds an additional error message to the error object | ||
error | clearErrors | func () bool | [[ clearErrors ]] |
null | reset all errors | ||
error | getError | func () string | [[ getError ]] |
result on console: “illegal base64 data at input byte 4” | contains the error message (1st error) | ||
error | getErrors | func () (tplerr []string) | [[ getErrors ]] |
result on console: “illegal base64 data at input byte 4” “my Error: This is a test string” |
returns all errors | ||
error | hasErrors | func () bool | [[ hasErrors ]] |
if error = true / no error = false | checks the command for errors | ||
error | newError | func ( text string ) error | [[ $result := newError "This is a test string" ]] |
$result = “This is a test string” | returns an error that formats as the given text | ||
developer | __break | func() boo | [[ $result := ]] |
$result = | |||
developer | __cache | func() string | [[ $result := ]] |
$result = | |||
developer | __data | func() string | [[ $result := ]] |
$result = | |||
developer | __debug | func(objs …interface{}) string | [[ $result := ]] |
$result = | |||
developer | __dump | func() string | [[ $result := ]] |
$result = | |||
developer | __exit | func(sec int) bool | [[ $result := ]] |
$result = | |||
developer | __sleep | func(sec int) bool | [[ $result := ]] |
$result = | |||
developer | __template | func() string | [[ $result := ]] |
$result = | |||
developer | __vars | func() string | [[ $result := ]] |
$result = |