From 17c60573aff902dad24199e1ae6946a043d51498 Mon Sep 17 00:00:00 2001 From: 0oM4R Date: Thu, 21 Nov 2024 20:28:12 +0200 Subject: [PATCH 1/2] Refactor(deploymentList/Caprover): enhance deleting caprover deployment --- packages/playground/src/utils/delete_deployment.ts | 3 ++- packages/playground/src/weblets/tf_deployment_list.vue | 6 +----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/playground/src/utils/delete_deployment.ts b/packages/playground/src/utils/delete_deployment.ts index 44e37d1654..aa88678fdc 100644 --- a/packages/playground/src/utils/delete_deployment.ts +++ b/packages/playground/src/utils/delete_deployment.ts @@ -12,6 +12,7 @@ export interface DeleteDeploymentOptions { projectName: ProjectName; ip?: string[]; k8s?: boolean; + isCaprover?: boolean; } export async function deleteDeployment(grid: GridClient, options: DeleteDeploymentOptions) { @@ -50,7 +51,7 @@ export async function deleteDeployment(grid: GridClient, options: DeleteDeployme return grid.k8s.delete({ name: options.name }); } - if (options.deploymentName) { + if (options.deploymentName && !options.isCaprover) { return grid.machines.delete_machine({ deployment_name: options.deploymentName, name: options.name }); } diff --git a/packages/playground/src/weblets/tf_deployment_list.vue b/packages/playground/src/weblets/tf_deployment_list.vue index 4d443536a8..6898d34d7b 100644 --- a/packages/playground/src/weblets/tf_deployment_list.vue +++ b/packages/playground/src/weblets/tf_deployment_list.vue @@ -510,11 +510,6 @@ async function onDelete(k8s = false) { try { const projectNameLower = props.projectName?.toLowerCase(); const allSelectedItems = [...selectedItems.value]; - selectedItems.value.forEach(item => { - if (item.projectName?.toLowerCase().includes(ProjectName.Caprover.toLowerCase()) && item.workers) { - allSelectedItems.push(...item.workers); - } - }); await allSelectedItems.reduce(async (acc, item) => { await acc; @@ -531,6 +526,7 @@ async function onDelete(k8s = false) { projectName: item.projectName, ip: getDeploymentIps(item), k8s, + isCaprover: item.projectName?.toLowerCase().includes(ProjectName.Caprover.toLowerCase()), }); } } catch (e: any) { From 6b81cd4b5fa2e78fe3b0e35bf18a33ab8207ca02 Mon Sep 17 00:00:00 2001 From: 0oM4R Date: Sun, 24 Nov 2024 16:06:30 +0200 Subject: [PATCH 2/2] Docs(Caprover/delete): add comment to explain why we ignore caproverDeployment in delete_machine and go for machines.delete --- packages/playground/src/utils/delete_deployment.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/playground/src/utils/delete_deployment.ts b/packages/playground/src/utils/delete_deployment.ts index aa88678fdc..11ef548762 100644 --- a/packages/playground/src/utils/delete_deployment.ts +++ b/packages/playground/src/utils/delete_deployment.ts @@ -50,7 +50,7 @@ export async function deleteDeployment(grid: GridClient, options: DeleteDeployme } return grid.k8s.delete({ name: options.name }); } - + // if Caprover deployment should handled by machines.delete if (options.deploymentName && !options.isCaprover) { return grid.machines.delete_machine({ deployment_name: options.deploymentName, name: options.name }); }