refactor(nixos): simplify route protocol checks
This commit is contained in:
@@ -16,25 +16,17 @@
|
||||
{
|
||||
assertion =
|
||||
entries:
|
||||
lib.all (
|
||||
entry:
|
||||
let
|
||||
route = entry.value;
|
||||
in
|
||||
!lib.elem route.protocol [
|
||||
"http"
|
||||
"https"
|
||||
]
|
||||
|| (route.port != null && route.ports == [ ])
|
||||
) entries;
|
||||
lib.all (entry: entry.value.port != null && entry.value.ports == [ ]) (
|
||||
lib.filter (entry: entry.value.protocol != "udp") entries
|
||||
);
|
||||
message = "HTTP and HTTPS routes must set port and not ports.";
|
||||
}
|
||||
{
|
||||
assertion =
|
||||
entries:
|
||||
lib.all (
|
||||
entry: entry.value.protocol != "udp" || (entry.value.port == null && entry.value.ports != [ ])
|
||||
) entries;
|
||||
lib.all (entry: entry.value.port == null && entry.value.ports != [ ]) (
|
||||
lib.filter (entry: entry.value.protocol == "udp") entries
|
||||
);
|
||||
message = "UDP routes must set ports and not port.";
|
||||
}
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user