cluster/services/ways: don't render empty upstream blocks
This commit is contained in:
parent
415fd7f076
commit
a285c57d5b
1 changed files with 6 additions and 1 deletions
|
@ -69,11 +69,16 @@ in
|
|||
{
|
||||
source = let
|
||||
upstreams = lib.mapAttrsToList (_: cfg: ''
|
||||
{{ if ne (len (service "${cfg.consulService}~_agent")) 0 }}
|
||||
# ${cfg.consulService}
|
||||
upstream ${cfg.nginxUpstreamName} {
|
||||
{{ range $i, $e := service "${cfg.consulService}~_agent" -}}
|
||||
server {{ .Address }}:{{ .Port }}{{ if ne $i 0 }} backup{{ end }};
|
||||
{{ end }}
|
||||
}
|
||||
{{ else }}
|
||||
# upstream ${cfg.nginxUpstreamName} (${cfg.consulService}): no servers available
|
||||
{{ end }}
|
||||
'') consulServiceWays;
|
||||
in pkgs.writeText "ways-upstreams.ctmpl" (lib.concatStringsSep "\n" (lib.unique upstreams));
|
||||
destination = "/run/consul-template/nginx-ways-upstreams.conf";
|
||||
|
|
Loading…
Reference in a new issue