@@ -687,6 +687,7 @@ async def _deploy_branch_environment_task(
687687 pgbouncer_admin_password : str ,
688688 pgbouncer_config : PgbouncerConfigSnapshot ,
689689 pitr_enabled : bool ,
690+ initial_password : str ,
690691) -> None :
691692 await _persist_branch_status (branch_id , BranchServiceStatus .CREATING )
692693 try :
@@ -702,6 +703,7 @@ async def _deploy_branch_environment_task(
702703 pgbouncer_admin_password = pgbouncer_admin_password ,
703704 pgbouncer_config = pgbouncer_snapshot_to_mapping (pgbouncer_config ),
704705 pitr_enabled = pitr_enabled ,
706+ initial_password = initial_password ,
705707 )
706708 except VelaError :
707709 await _persist_branch_status (branch_id , BranchServiceStatus .ERROR )
@@ -731,6 +733,7 @@ async def _clone_branch_environment_task(
731733 copy_data : bool ,
732734 pgbouncer_config : PgbouncerConfigSnapshot ,
733735 pitr_enabled : bool ,
736+ initial_password : str | None ,
734737) -> None :
735738 await _persist_branch_status (branch_id , BranchServiceStatus .CREATING )
736739 storage_class_name : str | None = None
@@ -773,6 +776,7 @@ async def _clone_branch_environment_task(
773776 use_existing_pvc = copy_data ,
774777 pgbouncer_config = pgbouncer_snapshot_to_mapping (pgbouncer_config ),
775778 pitr_enabled = pitr_enabled ,
779+ initial_password = initial_password ,
776780 )
777781 except VelaError :
778782 await _persist_branch_status (branch_id , BranchServiceStatus .ERROR )
@@ -805,6 +809,7 @@ async def _restore_branch_environment_task(
805809 restore_database_size : int ,
806810 pgbouncer_config : PgbouncerConfigSnapshot ,
807811 pitr_enabled : bool ,
812+ initial_password : str | None ,
808813) -> None :
809814 await _persist_branch_status (branch_id , BranchServiceStatus .CREATING )
810815 storage_class_name : str | None = None
@@ -851,6 +856,7 @@ async def _restore_branch_environment_task(
851856 use_existing_pvc = True ,
852857 pgbouncer_config = pgbouncer_snapshot_to_mapping (pgbouncer_config ),
853858 pitr_enabled = pitr_enabled ,
859+ initial_password = initial_password ,
854860 )
855861 except VelaError :
856862 await _persist_branch_status (branch_id , BranchServiceStatus .ERROR )
@@ -1259,6 +1265,7 @@ def _schedule_branch_environment_tasks(
12591265 pgbouncer_config : PgbouncerConfigSnapshot ,
12601266 restore_snapshot : RestoreSnapshotContext | None ,
12611267 restore_database_size : int | None ,
1268+ initial_password : str | None = None ,
12621269) -> None :
12631270 if deployment_parameters is not None :
12641271 asyncio .create_task (
@@ -1274,6 +1281,7 @@ def _schedule_branch_environment_tasks(
12741281 pgbouncer_admin_password = pgbouncer_admin_password ,
12751282 pgbouncer_config = pgbouncer_config ,
12761283 pitr_enabled = branch .pitr_enabled ,
1284+ initial_password = deployment_parameters .database_password ,
12771285 )
12781286 )
12791287 return
@@ -1298,6 +1306,7 @@ def _schedule_branch_environment_tasks(
12981306 restore_database_size = restore_database_size ,
12991307 pgbouncer_config = pgbouncer_config ,
13001308 pitr_enabled = branch .pitr_enabled ,
1309+ initial_password = initial_password ,
13011310 )
13021311 )
13031312 return
@@ -1317,6 +1326,7 @@ def _schedule_branch_environment_tasks(
13171326 copy_data = copy_data ,
13181327 pgbouncer_config = pgbouncer_config ,
13191328 pitr_enabled = branch .pitr_enabled ,
1329+ initial_password = initial_password ,
13201330 )
13211331 )
13221332
@@ -1363,11 +1373,11 @@ async def create( # noqa: C901
13631373 source_id : Identifier | None = getattr (source , "id" , None )
13641374 clone_parameters : DeploymentParameters | None = None
13651375 restore_database_size : int | None = None
1376+ source_overrides : BranchSourceDeploymentParameters | None = None
13661377 restore_params = parameters .restore
13671378 is_restore = restore_params is not None
13681379 is_data_clone = bool (parameters .source and parameters .source .data_copy )
13691380 if source is not None :
1370- source_overrides : BranchSourceDeploymentParameters | None = None
13711381 if parameters .source is not None :
13721382 source_overrides = parameters .source .deployment_parameters
13731383 elif restore_params is not None :
@@ -1480,6 +1490,10 @@ async def create( # noqa: C901
14801490 )
14811491 restore_snapshot : RestoreSnapshotContext | None = restore_snapshot_context
14821492
1493+ clone_initial_password : str | None = None
1494+ if source_overrides is not None and source_overrides .database_password is not None :
1495+ clone_initial_password = source_overrides .database_password
1496+
14831497 _schedule_branch_environment_tasks (
14841498 deployment_parameters = parameters .deployment ,
14851499 organization_id = organization .id ,
@@ -1494,6 +1508,7 @@ async def create( # noqa: C901
14941508 pgbouncer_config = pgbouncer_config_snapshot ,
14951509 restore_snapshot = restore_snapshot ,
14961510 restore_database_size = restore_database_size ,
1511+ initial_password = clone_initial_password ,
14971512 )
14981513
14991514 payload = (await _public (entity )).model_dump (mode = "json" ) if response == "full" else None
0 commit comments