./redteamer

Functions

Special Functions

Functions particular useful for conditional logic.


Error Handling

These functions evaluate expressions and handle errors.

can

The can function evaluates a given expression and returns a boolean value indicating whether the expression was evaluated without any errors.

can(some_expression)
# Example: can(file("${path.module_dir}/config.yaml")) // returns true if the file exists and is readable

try

The try function evaluates all of its argument expressions sequentially and returns the result of the first one that does not produce any errors.

try(some_expression, fallback_value)
# Example: try(file("${path.module_dir}/config.yaml"), "default_value") // returns the file content or "default_value" if an error occurs

Conditional Functions

Conditional and logical functions in RedTeamer provide a set of tools for evaluating conditions and making logical comparisons within your lists.

coalesce

The coalesce function evaluates a series of values and returns the first non-null or non-empty string value.

coalesce(value1, value2, ...)
# Example: coalesce("", "default", "fallback") // returns "default"

anytrue

The anytrue function checks whether any element in a given collection is true or "true".

anytrue(list)
# Example: anytrue([false, "true", false]) // returns true

alltrue

The alltrue function evaluates whether all elements in a given collection are true or "true".

alltrue(list)
# Example: alltrue([true, "true", true]) // returns true

Omnitype Functions

Omnitype functions work across different data types.

length

The len function quantifies the length of a given list, map, or string.

len(collection_or_string)
# Example: len(["a", "b", "c"]) // returns 3
# Example: len("hello") // returns 5
Previous
Parsing Functions