1

Is there a way to retrieve only 3 IPs from Consul service catalog?

{{if service 'web' 'passing'}}
 "{{range $index, $service := service 'web'}}{{if ne $index 0}},{{end}}{{.Address}}{{end}}"

The above code gets all comma separated IPs (I have 100's of IPs) that passes the web service check . I just need first 3 IPs.

-W

wasay
  • 87
  • 1
  • 3
  • 8

1 Answers1

0

{{range $index, $service := service "web"}}{{if gt $index 3}}{{.Address}}:{{ .Port }},{{end}}{{end}}

should do it.

Spanky
  • 5,608
  • 10
  • 39
  • 45