From 777d1c0944e931bf5bb3538982c144b8916d1b97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= Date: Thu, 18 Jun 2020 01:48:19 +0200 Subject: [PATCH] consul.passthru.tests: Refactor let bindings --- nixos/tests/consul.nix | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/nixos/tests/consul.nix b/nixos/tests/consul.nix index 785963d1a7c..a5188d12830 100644 --- a/nixos/tests/consul.nix +++ b/nixos/tests/consul.nix @@ -55,31 +55,28 @@ let server = index: { pkgs, ... }: let - ip = builtins.elemAt allConsensusServerHosts index; + thisConsensusServerHost = builtins.elemAt allConsensusServerHosts index; + ip = thisConsensusServerHost; # since we already use IPs to identify servers in { networking.interfaces.eth1.ipv4.addresses = pkgs.lib.mkOverride 0 [ - { address = builtins.elemAt allConsensusServerHosts index; prefixLength = 16; } + { address = ip; prefixLength = 16; } ]; networking.firewall = firewallSettings; services.consul = - let - thisConsensusServerHost = builtins.elemAt allConsensusServerHosts index; - numConsensusServers = builtins.length allConsensusServerHosts; - in assert builtins.elem thisConsensusServerHost allConsensusServerHosts; { enable = true; inherit webUi; extraConfig = defaultExtraConfig // { server = true; - bootstrap_expect = numConsensusServers; + bootstrap_expect = builtins.length allConsensusServerHosts; retry_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. # See https://github.com/hashicorp/consul/issues/2868 - if numConsensusServers == 1 + if builtins.length allConsensusServerHosts == 1 then allConsensusServerHosts else builtins.filter (h: h != thisConsensusServerHost) allConsensusServerHosts; bind_addr = ip;