Skip to content

Commit

Permalink
Refactor(deploymentList/Caprover): enhance deleting caprover deployme…
Browse files Browse the repository at this point in the history
…nt (#3675)

* Refactor(deploymentList/Caprover): enhance deleting caprover deployment

* Docs(Caprover/delete): add comment to explain why we ignore caproverDeployment in delete_machine and go for machines.delete
  • Loading branch information
0oM4R authored Dec 2, 2024
1 parent efae2d5 commit 1677788
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 3 additions & 2 deletions packages/playground/src/utils/delete_deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface DeleteDeploymentOptions {
projectName: ProjectName;
ip?: string[];
k8s?: boolean;
isCaprover?: boolean;
}

export async function deleteDeployment(grid: GridClient, options: DeleteDeploymentOptions) {
Expand Down Expand Up @@ -49,8 +50,8 @@ export async function deleteDeployment(grid: GridClient, options: DeleteDeployme
}
return grid.k8s.delete({ name: options.name });
}

if (options.deploymentName) {
// 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 });
}

Expand Down
6 changes: 1 addition & 5 deletions packages/playground/src/weblets/tf_deployment_list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down

0 comments on commit 1677788

Please sign in to comment.