Skip to content

Commit fd1ffde

Browse files
authored
add support to launch adminer (#10)
* add adminer to postgres package * address review comments * add newline * update description * revert persistent back to True
1 parent 1495294 commit fd1ffde

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

main.star

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
adminer_module = import_module("github.com/bharath-123/db-adminer-package/main.star")
2+
13
PORT_NAME = "postgresql"
24
APPLICATION_PROTOCOL = "postgresql"
5+
PG_DRIVER = "pgsql"
36

47
CONFIG_FILE_MOUNT_DIRPATH = "/config"
58
SEED_FILE_MOUNT_PATH = "/docker-entrypoint-initdb.d"
@@ -19,6 +22,7 @@ def run(
1922
seed_file_artifact_name="",
2023
extra_configs=[],
2124
persistent=True,
25+
launch_adminer=False,
2226
):
2327
"""Launches a Postgresql database instance, optionally seeding it with a SQL file script
2428
@@ -34,6 +38,7 @@ def run(
3438
If not empty, the Postgres server will be populated with the data upon start
3539
extra_configs (list[string]): Each argument gets passed as a '-c' argument to the Postgres server
3640
persistent (bool): Whether the data should be persisted. Defaults to True; Note that this isn't supported on multi node k8s cluster as of 2023-10-16
41+
launch_adminer (bool): Whether to launch adminer which launches a website to inspect postgres database entries. Defaults to False.
3742
Returns:
3843
An object containing useful information about the Postgres database running inside the enclave:
3944
```
@@ -107,6 +112,15 @@ def run(
107112
),
108113
)
109114

115+
if launch_adminer:
116+
adminer = adminer_module.run(plan,
117+
default_db=database,
118+
default_driver=PG_DRIVER,
119+
default_password=password,
120+
default_server=postgres_service.hostname,
121+
default_username=user
122+
)
123+
110124
url = "{protocol}://{user}:{password}@{hostname}/{database}".format(
111125
protocol=APPLICATION_PROTOCOL,
112126
user=user,

0 commit comments

Comments
 (0)