给定 Consul 密钥:
flyway/tweedle/server: postgres
flyway/beetle/server: postgres
flyway/battle/server: mysql
service/tweedle/repo: fox/tweedle.git
service/beetle/repo: fox/beetle.git
service/battle/repo: fox/battle.git
我正在尝试遍历顶部集,使用键在底部集中查找值,使用以下代码(不起作用):
{
{{ range $key, $pairs :=tree "flyway/" | explode }}
$key: {{ key "service/{{$key}}/repo" }}
{{ end }}
}
要得到:
tweedle: fox/tweedle.git
beetle: fox/beetle.git
battle: fox/battle.git