Update the way wait_for template works

This commit is contained in:
Daniel Berteaud 2023-08-25 12:32:42 +02:00
parent f7189b5a15
commit c1ce3ccbdb
2 changed files with 6 additions and 5 deletions

View File

@ -1,3 +1,4 @@
resources {
cpu = [[ .cpu ]]
memory = [[ .memory ]]
@ -5,3 +6,4 @@
memory_max = [[ .memory_max ]]
[[- end ]]
}

View File

@ -4,11 +4,10 @@
image = [[ .ctx.images.wait_for | toJSON ]]
}
env {
[[- range $k, $v := . ]]
[[- if regexp.Match "^SERVICE_\\d+" $k ]]
[[ $k ]] = [[ printf "%s%s.service.%s" $v $.ctx.env.suffix $.ctx.consul.domain | toJSON ]]
[[- else if regexp.Match "^COUNT_\\d+" $k ]]
[[ $k ]] = [[ $v ]]
[[- range $idx, $service := .wait_for ]]
SERVICE_[[ $idx ]] = [[ printf "%s%s.service.%s" $service.service $.ctx.env.suffix $.ctx.consul.domain | toJSON ]]
[[- if has $service "count" ]]
COUNT_[[ $idx ]] = [[ $service.count ]]
[[- end ]]
[[- end ]]
}