refactor(reverse-proxy): use route registry
This commit was merged in pull request #61.
This commit is contained in:
@@ -28,6 +28,23 @@ let
|
||||
in
|
||||
nameValuePair (registryName name) (import path { inherit lib; })
|
||||
) (filterAttrs (name: type: type == "regular" && hasSuffix ".nix" name) (builtins.readDir (self + "/registry")));
|
||||
join = registry: host: entry:
|
||||
filterAttrs (_name: value: value != null) (
|
||||
mapAttrs (registryName: _registry: (registry.${registryName}.${host} or { }).${entry} or null) definitions
|
||||
);
|
||||
|
||||
collectData =
|
||||
{ hosts }:
|
||||
mapAttrs (
|
||||
registryName: _registry:
|
||||
mapAttrs (hostName: host: host.config.registry.${registryName}.${hostName} or { }) hosts
|
||||
) definitions;
|
||||
|
||||
withOperations = registry:
|
||||
registry
|
||||
// {
|
||||
join = host: entry: join registry host entry;
|
||||
};
|
||||
in
|
||||
{
|
||||
inherit definitions;
|
||||
@@ -36,10 +53,5 @@ in
|
||||
options.registry = mapAttrs (_name: registry: registryOption registry) definitions;
|
||||
};
|
||||
|
||||
collect =
|
||||
{ hosts }:
|
||||
mapAttrs (
|
||||
registryName: _registry:
|
||||
mapAttrs (hostName: host: host.config.registry.${registryName}.${hostName} or { }) hosts
|
||||
) definitions;
|
||||
collect = args: withOperations (collectData args);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user