fix: gracefully handle the config option not existing

This commit is contained in:
silver 2023-01-18 00:19:45 +00:00
parent ea493b434b
commit 1378338bb2
2 changed files with 21 additions and 9 deletions

View file

@ -72,9 +72,13 @@ in {
lib.attrsets.mapAttrsToList (key: value:
# make sure that anything running this firewall dosent count (recursion otherewise)
# firewall may want to open ports in itself but can deal with that later
if builtins.hasAttr "skynet_firewall" value.config
then (
if value.config.skynet_firewall.enable
then []
else value.config.skynet_firewall.forward
)
else []
) nodes
);
};

View file

@ -46,17 +46,25 @@ in {
# using the same logic as the firewall, comments there
external = builtins.concatLists (
lib.attrsets.mapAttrsToList (key: value:
if value.config.deployment.hostname == hostname
if builtins.hasAttr "skynet_dns" value.config
then (
if value.config.deployment.targetHost == hostname
then own.external
else value.config.skynet_dns.records.external
)
else []
) nodes
);
cname = builtins.concatLists (
lib.attrsets.mapAttrsToList (key: value:
if value.config.deployment.hostname == hostname
if builtins.hasAttr "skynet_dns" value.config
then (
if value.config.deployment.targetHost == hostname
then own.cname
else value.config.skynet_dns.records.cname
)
else []
) nodes
);
};