consul.passthru.tests: Refactor: Extract variable

This commit is contained in:
Niklas Hambüchen 2020-06-18 01:45:11 +02:00
parent 720128ce7e
commit f795df26cf

View File

@ -66,6 +66,7 @@ let
services.consul = services.consul =
let let
thisConsensusServerHost = builtins.elemAt allConsensusServerHosts index; thisConsensusServerHost = builtins.elemAt allConsensusServerHosts index;
numConsensusServers = builtins.length allConsensusServerHosts;
in in
assert builtins.elem thisConsensusServerHost allConsensusServerHosts; assert builtins.elem thisConsensusServerHost allConsensusServerHosts;
{ {
@ -73,12 +74,12 @@ let
inherit webUi; inherit webUi;
extraConfig = defaultExtraConfig // { extraConfig = defaultExtraConfig // {
server = true; server = true;
bootstrap_expect = builtins.length allConsensusServerHosts; bootstrap_expect = numConsensusServers;
retry_join = retry_join =
# If there's only 1 node in the network, we allow self-join; # If there's only 1 node in the network, we allow self-join;
# otherwise, the node must not try to join itself, and join only the other servers. # otherwise, the node must not try to join itself, and join only the other servers.
# See https://github.com/hashicorp/consul/issues/2868 # See https://github.com/hashicorp/consul/issues/2868
if builtins.length allConsensusServerHosts == 1 if numConsensusServers == 1
then allConsensusServerHosts then allConsensusServerHosts
else builtins.filter (h: h != thisConsensusServerHost) allConsensusServerHosts; else builtins.filter (h: h != thisConsensusServerHost) allConsensusServerHosts;
bind_addr = ip; bind_addr = ip;