Some data manipulations require a lot of JQ code. Writing it inline in the template is not convenient, so it would be great to be able to load JQ code from local files.
Design
Add from_file() HCL function that accepts a file path and returns the contents of the file as string (the function expects text)
The example of the use-case would be:
document "test" {
vars {
items = ["a", "b", "c"]
}
content text {
local_var = query_jq(from_file("./query.jq"))
value = "Length: {{ .vars.local }}"
}
}
with query.jq:
.vars.items | length
To simplify the logic, from_file would resolve the relative path from the directory where Fabric is executed
Background
Some data manipulations require a lot of JQ code. Writing it inline in the template is not convenient, so it would be great to be able to load JQ code from local files.
Design
Add
from_file()
HCL function that accepts a file path and returns the contents of the file as string (the function expects text)The example of the use-case would be:
with
query.jq
:To simplify the logic,
from_file
would resolve the relative path from the directory where Fabric is executed