Karan Sharma

Nomad Template Snippets

0 minutes (110 words)

🔗Service List

I needed to fetch a list of upstream services from Nomad’s service registry and render in a .toml file like this. This is essentially a comma separated list of services

servers = ["",""]

Figuring this out with Go template took some time.

servers = [{{ range $index, $element := nomadService "my-app-svc" }}{{if $index}},{{end}}"{{.Address}}:{{.Port}}"{{- end }}]

Tags: #Nomad