Documentation Index
Fetch the complete documentation index at: https://errand.nuvrel.dev/llms.txt
Use this file to discover all available pages before exploring further.
split(separator, str) divides str at every occurrence of separator and returns a list of the parts.
Signature
split(separator string, str string) list(string)
Example
Accept a comma-separated list of services as a variable and run a command for each one:
variable "services" {
description = "Comma-separated list of services to restart"
type = string
default = "api,worker,scheduler"
}
computed "service_list" {
expression = split(",", var.services)
}
task "restart" {
description = "Restart each service"
commands = [
"for svc in ${join(" ", computed.service_list)}; do systemctl restart $svc; done",
]
}
With the default value, computed.service_list becomes ["api", "worker", "scheduler"].
Notes
- If
separator does not appear in str, the result is a list with one element: the original string.
- Consecutive separators produce empty strings in the result. Use
compact to remove them.
- To join a list back into a string, use
join.