blackstork-io / fabric

An open-source command-line tool for cybersecurity reporting automation and a configuration language for reusable templates. Reporting-as-Code
https://blackstork.io/fabric/
Apache License 2.0
12 stars 0 forks source link

Add `join` HCL function #204

Closed traut closed 1 week ago

traut commented 1 week ago

Background

In many use-cases, particularly for simplifying loading JQ queries, it is helpful to join strings.

Design

Implement join() function, similar to Terraform's. The function should accept a separator and a list of strings and returns a string.

For example:

document "test" {

  vars {
    items = ["a", "b", "c"]
  }

  content text {
    local_var = query_jq(join("\r", [
      from_file("./utils.jq"),
      ".vars.items | custom_function",
    ]))

    value = "Length: {{ .vars.local }}"
  }
}