cluster/services/incandescence: don't try to filter destruction if no objects declared
This commit is contained in:
parent
8d7d178d9d
commit
76f08600af
1 changed files with 4 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
||||||
{ cluster, config, lib, ... }:
|
{ cluster, config, lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (lib) concatStringsSep escapeShellArg flatten filter filterAttrs length mapAttrs mapAttrs' mapAttrsToList mkIf mkMerge pipe stringToCharacters;
|
inherit (lib) concatStringsSep escapeShellArg flatten filter filterAttrs length mapAttrs mapAttrs' mapAttrsToList mkIf mkMerge optionalString pipe stringToCharacters;
|
||||||
|
|
||||||
cfg = config.services.incandescence;
|
cfg = config.services.incandescence;
|
||||||
clusterCfg = cluster.config.incandescence;
|
clusterCfg = cluster.config.incandescence;
|
||||||
|
@ -83,13 +83,15 @@ in
|
||||||
(builtins.add 2)
|
(builtins.add 2)
|
||||||
toString
|
toString
|
||||||
];
|
];
|
||||||
|
needsFilter = clusterCfg.providers.${provider}.objects.${formula} != [];
|
||||||
keyFilter = pipe clusterCfg.providers.${provider}.objects.${formula} [
|
keyFilter = pipe clusterCfg.providers.${provider}.objects.${formula} [
|
||||||
(map (x: escapeShellArg "^${x}$"))
|
(map (x: escapeShellArg "^${x}$"))
|
||||||
(concatStringsSep " \\\n -e ")
|
(concatStringsSep " \\\n -e ")
|
||||||
];
|
];
|
||||||
destroyAfterDays = toString formulaConfig.destroyAfterDays;
|
destroyAfterDays = toString formulaConfig.destroyAfterDays;
|
||||||
|
grep = optionalString needsFilter "grep -v -e ${keyFilter} |";
|
||||||
in ''
|
in ''
|
||||||
consul kv get --keys ${kvRoot}/ | cut -d/ -f${fieldNum} | grep -v -e ${keyFilter} | while read object; do
|
consul kv get --keys ${kvRoot}/ | cut -d/ -f${fieldNum} | ${grep} while read object; do
|
||||||
if consul kv get ${kvRoot}/$object/alive >/dev/null; then
|
if consul kv get ${kvRoot}/$object/alive >/dev/null; then
|
||||||
destroyOn="$(consul kv get ${kvRoot}/$object/destroyOn || true)"
|
destroyOn="$(consul kv get ${kvRoot}/$object/destroyOn || true)"
|
||||||
if [[ -z "$destroyOn" && "${destroyAfterDays}" -ne 0 ]]; then
|
if [[ -z "$destroyOn" && "${destroyAfterDays}" -ne 0 ]]; then
|
||||||
|
|
Loading…
Reference in a new issue