Allow getting service config from a common place connect_services
This commit is contained in:
parent
7cd3aeb29e
commit
2f03b5c8b5
|
@ -13,13 +13,23 @@
|
|||
[[- range $idx, $upstream := .consul.connect.upstreams ]]
|
||||
[[- $connect_services = append $upstream.destination_name $connect_services ]]
|
||||
upstreams {
|
||||
destination_name = [[ $upstream.destination_name | toJSON ]]
|
||||
destination_name = "[[ $upstream.destination_name ]]"
|
||||
[[- if has $upstream "local_bind_port" ]]
|
||||
local_bind_port = [[ $upstream.local_bind_port ]]
|
||||
[[- else if and (has $ "connect_services") (has $.connect_services $upstream.destination_name) (has (index $.connect_services $upstream.destination_name) "port") ]]
|
||||
local_bind_port = [[ (index $.connect_services $upstream.destination_name).port ]]
|
||||
[[- end ]]
|
||||
# Work arround, see https://github.com/hashicorp/nomad/issues/18538
|
||||
destination_type = "service"
|
||||
[[- $config := dict ]]
|
||||
[[- if has $upstream "config" ]]
|
||||
[[- $config = $upstream.config ]]
|
||||
[[- else if and (has $ "connect_services") (has $.connect_services $upstream.destination_name) (has (index $.connect_services $upstream.destination_name) "config") ]]
|
||||
[[- $config = (index $.connect_services $upstream.destination_name).config ]]
|
||||
[[- end ]]
|
||||
[[- if gt (len $config) 0 ]]
|
||||
config {
|
||||
[[- range $k, $v := $upstream.config ]]
|
||||
[[- range $k, $v := $config ]]
|
||||
[[- if or (isKind "number" $v) (isKind "bool" $v) ]]
|
||||
[[ $k ]] = [[ $v ]]
|
||||
[[- else if isKind "string" $v ]]
|
||||
|
|
Loading…
Reference in New Issue