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