I am trying to do something like this:
template {
data = <<EOH
{{range nomadService 1 "service_name"}}
{{ .Address }}:{{ .Port }}
{{ end }}
EOH
destination = "local/selected-service.env"
env = false
}
However this generates an error because of that 1, I guess I should be filtering by some kind of key (or remove the 1 altogether):
Template failed: (dynamic): execute: template: :1:18: executing "" at <nomadService 1 "service_name">: error calling nomadService: expected arguments <service> or <count> <key> <service>
But I don’t have anything to filter on, I would like randomly get one of the available services, how could I do that? With the help of AI I was trying to apply some kind of randomness to the service list, but it seems that most of the Go template syntax is not available in Nomad (??).
Thank you in advance.