refactor(nixos): model route protocols explicitly
This commit is contained in:
@@ -9,14 +9,25 @@
|
||||
assertion =
|
||||
entries:
|
||||
util.registry.predicates.uniqueValue (entry: entry.value) (
|
||||
lib.concatMap (entry: map (port: entry // { value = port; }) entry.value.udp.ports) entries
|
||||
lib.concatMap (entry: map (port: entry // { value = port; }) entry.value.ports) entries
|
||||
);
|
||||
message = "Route UDP ports must be unique.";
|
||||
}
|
||||
{
|
||||
assertion =
|
||||
entries: lib.all (entry: entry.value.port == null || entry.value.http.port == null) entries;
|
||||
message = "Route entries must not set both port and http.port.";
|
||||
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.port == null && entry.value.ports != [ ]) (
|
||||
lib.filter (entry: entry.value.protocol == "udp") entries
|
||||
);
|
||||
message = "UDP routes must set ports and not port.";
|
||||
}
|
||||
];
|
||||
|
||||
@@ -25,31 +36,33 @@
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
example = "files.alexion.dev";
|
||||
description = "Domain served by this route entry.";
|
||||
description = "Public domain for this route.";
|
||||
};
|
||||
|
||||
protocol = lib.mkOption {
|
||||
type = lib.types.enum [
|
||||
"http"
|
||||
"https"
|
||||
"udp"
|
||||
];
|
||||
description = "Public protocol for this route.";
|
||||
};
|
||||
|
||||
port = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.port;
|
||||
default = null;
|
||||
example = 3923;
|
||||
description = "HTTPS backend TCP port served by the matching address registry entry.";
|
||||
description = "HTTP backend port for an HTTP or HTTPS route.";
|
||||
};
|
||||
|
||||
http.port = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.port;
|
||||
default = null;
|
||||
example = 8082;
|
||||
description = "HTTP backend TCP port served by the matching address registry entry.";
|
||||
};
|
||||
|
||||
udp.ports = lib.mkOption {
|
||||
ports = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.port;
|
||||
default = [ ];
|
||||
example = [
|
||||
2456
|
||||
2457
|
||||
];
|
||||
description = "UDP ports served by the matching address registry entry.";
|
||||
description = "UDP ports for a UDP route.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user