Native Functions
Tanka extends Jsonnet using native functions, offering additional functionality not yet available in the standard library.
To use them in your code, you need to access them using std.native
from the standard library:
std.native
takes the native function’s name as a string
argument and returns a function
, which is called using the second set of parentheses.
sha256
Signature
sha256
computes the SHA256 sum of the given string.
Examples
Evaluating with Tanka results in the JSON:
parseJson
Signature
parseJson
parses a json string and returns the respective Jsonnet type (Object
, Array
, etc).
Examples
Evaluating with Tanka results in the JSON:
parseYaml
Signature
parseYaml
wraps yaml.Unmarshal
to convert a string of yaml document(s) into
a set of dicts. If yaml
only contains a single document, a single value array
will be returned.
Examples
Evaluating with Tanka results in the JSON:
manifestJsonFromJson
Signature
manifestJsonFromJson
reserializes JSON and allows to change the indentation.
Examples
Evaluating with Tanka results in the JSON:
manifestYamlFromJson
Signature
manifestYamlFromJson
serializes a JSON string as a YAML document.
Examples
Evaluating with Tanka results in the JSON:
escapeStringRegex
Signature
escapeStringRegex
escapes all regular expression metacharacters and returns a
regular expression that matches the literal text.
Examples
Evaluating with Tanka results in the JSON:
regexMatch
Signature
regexMatch
returns whether the given string is matched by the given
RE2 regular expression.
Examples
Evaluating with Tanka results in the JSON:
regexSubst
Signature
regexSubst
replaces all matches of the re2 regular expression with the
replacement string.
Examples
Evaluating with Tanka results in the JSON: