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: lib.attrsets.mapAttrsToList (key: value:
# make sure that anything running this firewall dosent count (recursion otherewise) # 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 # 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 if value.config.skynet_firewall.enable
then [] then []
else value.config.skynet_firewall.forward else value.config.skynet_firewall.forward
)
else []
) nodes ) nodes
); );
}; };

View file

@ -46,17 +46,25 @@ in {
# using the same logic as the firewall, comments there # using the same logic as the firewall, comments there
external = builtins.concatLists ( external = builtins.concatLists (
lib.attrsets.mapAttrsToList (key: value: 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 then own.external
else value.config.skynet_dns.records.external else value.config.skynet_dns.records.external
)
else []
) nodes ) nodes
); );
cname = builtins.concatLists ( cname = builtins.concatLists (
lib.attrsets.mapAttrsToList (key: value: 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 then own.cname
else value.config.skynet_dns.records.cname else value.config.skynet_dns.records.cname
)
else []
) nodes ) nodes
); );
}; };