From f976085d6038f24c4aa19dfe50008ffaa56b7712 Mon Sep 17 00:00:00 2001 From: Bharath Vedartham Date: Thu, 26 Oct 2023 12:42:05 +0530 Subject: [PATCH 1/5] add adminer to postgres package --- main.star | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/main.star b/main.star index 2451996..6bab8f7 100644 --- a/main.star +++ b/main.star @@ -1,3 +1,5 @@ +adminer_module = import_module("github.com/bharath-123/db-adminer-package/main.star") + PORT_NAME = "postgresql" APPLICATION_PROTOCOL = "postgresql" @@ -18,7 +20,8 @@ def run( config_file_artifact_name="", seed_file_artifact_name="", extra_configs=[], - persistent=True, + persistent=False, + launch_adminer=True, ): """Launches a Postgresql database instance, optionally seeding it with a SQL file script @@ -33,7 +36,8 @@ def run( seed_file_artifact_name (string): The name of a files artifact containing seed data If not empty, the Postgres server will be populated with the data upon start extra_configs (list[string]): Each argument gets passed as a '-c' argument to the Postgres server - 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 + persistent (bool): Whether the data should be persisted. Defaults to False; Note that this isn't supported on multi node k8s cluster as of 2023-10-16 + launch_adminer (bool): Whether to launch adminer. Defaults to True. Returns: An object containing useful information about the Postgres database running inside the enclave: ``` @@ -107,6 +111,15 @@ def run( ), ) + if launch_adminer: + adminer = adminer_module.run(plan, + default_db=database, + default_driver="pgsql", + default_password=password, + default_server=postgres_service.hostname, + default_username=user + ) + url = "{protocol}://{user}:{password}@{hostname}/{database}".format( protocol=APPLICATION_PROTOCOL, user=user, @@ -135,4 +148,4 @@ def run_query(plan, service, user, password, database, query): ) return plan.exec( service.name, recipe=ExecRecipe(command=["psql", url, "-c", query]) - ) + ) \ No newline at end of file From a1387bf910b29804d4af6c6a4514f80577a7fc0c Mon Sep 17 00:00:00 2001 From: Bharath Vedartham Date: Thu, 26 Oct 2023 13:14:10 +0530 Subject: [PATCH 2/5] address review comments --- main.star | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.star b/main.star index 6bab8f7..ae20ffe 100644 --- a/main.star +++ b/main.star @@ -2,6 +2,7 @@ adminer_module = import_module("github.com/bharath-123/db-adminer-package/main.s PORT_NAME = "postgresql" APPLICATION_PROTOCOL = "postgresql" +PG_DRIVER = "pgsql" CONFIG_FILE_MOUNT_DIRPATH = "/config" SEED_FILE_MOUNT_PATH = "/docker-entrypoint-initdb.d" @@ -21,7 +22,7 @@ def run( seed_file_artifact_name="", extra_configs=[], persistent=False, - launch_adminer=True, + launch_adminer=False, ): """Launches a Postgresql database instance, optionally seeding it with a SQL file script @@ -37,7 +38,7 @@ def run( If not empty, the Postgres server will be populated with the data upon start extra_configs (list[string]): Each argument gets passed as a '-c' argument to the Postgres server persistent (bool): Whether the data should be persisted. Defaults to False; Note that this isn't supported on multi node k8s cluster as of 2023-10-16 - launch_adminer (bool): Whether to launch adminer. Defaults to True. + launch_adminer (bool): Whether to launch adminer. Defaults to False. Returns: An object containing useful information about the Postgres database running inside the enclave: ``` @@ -114,7 +115,7 @@ def run( if launch_adminer: adminer = adminer_module.run(plan, default_db=database, - default_driver="pgsql", + default_driver=PG_DRIVER, default_password=password, default_server=postgres_service.hostname, default_username=user From 3b5904066a6a226e0007c970d47ddf681e00ff16 Mon Sep 17 00:00:00 2001 From: Bharath Vedartham Date: Thu, 26 Oct 2023 13:15:14 +0530 Subject: [PATCH 3/5] add newline --- main.star | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.star b/main.star index ae20ffe..bee310c 100644 --- a/main.star +++ b/main.star @@ -149,4 +149,4 @@ def run_query(plan, service, user, password, database, query): ) return plan.exec( service.name, recipe=ExecRecipe(command=["psql", url, "-c", query]) - ) \ No newline at end of file + ) From a957b01f409a3f0329bd703b5ca877dc8e50d531 Mon Sep 17 00:00:00 2001 From: Bharath Vedartham Date: Thu, 26 Oct 2023 21:37:54 +0530 Subject: [PATCH 4/5] update description --- main.star | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.star b/main.star index bee310c..ade4845 100644 --- a/main.star +++ b/main.star @@ -38,7 +38,7 @@ def run( If not empty, the Postgres server will be populated with the data upon start extra_configs (list[string]): Each argument gets passed as a '-c' argument to the Postgres server persistent (bool): Whether the data should be persisted. Defaults to False; Note that this isn't supported on multi node k8s cluster as of 2023-10-16 - launch_adminer (bool): Whether to launch adminer. Defaults to False. + launch_adminer (bool): Whether to launch adminer which launches a website to inspect postgres database entries. Defaults to False. Returns: An object containing useful information about the Postgres database running inside the enclave: ``` From b202454881c9cb5028fbc8c70de6e7199f1dc3f3 Mon Sep 17 00:00:00 2001 From: Bharath Vedartham Date: Thu, 26 Oct 2023 22:22:00 +0530 Subject: [PATCH 5/5] revert persistent back to True --- main.star | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.star b/main.star index ade4845..c9f9372 100644 --- a/main.star +++ b/main.star @@ -21,7 +21,7 @@ def run( config_file_artifact_name="", seed_file_artifact_name="", extra_configs=[], - persistent=False, + persistent=True, launch_adminer=False, ): """Launches a Postgresql database instance, optionally seeding it with a SQL file script @@ -37,7 +37,7 @@ def run( seed_file_artifact_name (string): The name of a files artifact containing seed data If not empty, the Postgres server will be populated with the data upon start extra_configs (list[string]): Each argument gets passed as a '-c' argument to the Postgres server - persistent (bool): Whether the data should be persisted. Defaults to False; Note that this isn't supported on multi node k8s cluster as of 2023-10-16 + 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 launch_adminer (bool): Whether to launch adminer which launches a website to inspect postgres database entries. Defaults to False. Returns: An object containing useful information about the Postgres database running inside the enclave: