mirror of
https://github.com/juspay/services-flake.git
synced 2024-11-08 22:11:47 +03:00
refactor(postgres): replace string argument with attrset for connectionURI
(#146)
for justification, see: https://github.com/juspay/services-flake/pull/143#discussion_r1521290361
This commit is contained in:
parent
fb48b6b612
commit
18f9decf13
@ -29,12 +29,7 @@
|
||||
settings.processes.pgweb = {
|
||||
command = pkgs.pgweb;
|
||||
depends_on."northwind".condition = "process_healthy";
|
||||
environment.PGWEB_DATABASE_URL =
|
||||
let
|
||||
inherit (config.services.postgres.northwind)
|
||||
listen_addresses port;
|
||||
in
|
||||
"postgres://$USER@${listen_addresses}:${builtins.toString port}/sample";
|
||||
environment.PGWEB_DATABASE_URL = config.services.postgres.northwind.connectionURI { dbName = "sample"; };
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -45,7 +45,7 @@
|
||||
pgcfg = config.services.postgres.pg1;
|
||||
in
|
||||
{
|
||||
environment.PGWEB_DATABASE_URL = pgcfg.connectionURI dbName;
|
||||
environment.PGWEB_DATABASE_URL = pgcfg.connectionURI { inherit dbName; };
|
||||
command = pkgs.pgweb;
|
||||
depends_on."pg1".condition = "process_healthy";
|
||||
};
|
||||
|
@ -60,8 +60,11 @@ in
|
||||
connectionURI = lib.mkOption {
|
||||
type = lib.types.functionTo lib.types.str;
|
||||
readOnly = true;
|
||||
default = dbName: "postgres://${config.listen_addresses}:${builtins.toString config.port}/${dbName}";
|
||||
description = "A function that accepts database name and returns the [postgres connection URI](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING-URIS)";
|
||||
default = { dbName, ... }: "postgres://${config.listen_addresses}:${builtins.toString config.port}/${dbName}";
|
||||
description = ''
|
||||
A function that accepts an attrset overriding the connection parameters
|
||||
and returns the [postgres connection URI](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING-URIS)
|
||||
'';
|
||||
};
|
||||
|
||||
hbaConf =
|
||||
|
Loading…
Reference in New Issue
Block a user