Skip to content

Commit

Permalink
Feat: delete vm deployment with its gateway
Browse files Browse the repository at this point in the history
check for all network interfaces
  • Loading branch information
0oM4R committed Oct 21, 2024
1 parent ca42e22 commit 6591896
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/playground/src/utils/delete_deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface DeleteDeploymentOptions {
deploymentName?: string;
name: string;
projectName: ProjectName;
ip?: string;
ip?: string[];
k8s?: boolean;
}

Expand Down Expand Up @@ -117,9 +117,9 @@ function isVm(projectName: string) {
return false;
}

async function deleteVmGateways(grid: GridClient, ip?: string) {
async function deleteVmGateways(grid: GridClient, ips?: string[]) {
const { gateways } = await loadDeploymentGateways(grid, {
filter: ip ? gw => gw.backends.some(bk => bk.includes(ip)) : undefined,
filter: ips ? gw => gw.backends.some(bk => ips.some(ip => bk.includes(ip))) : undefined,
});
for (const gateway of gateways) {
try {
Expand Down
24 changes: 23 additions & 1 deletion packages/playground/src/weblets/tf_deployment_list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ async function onDelete(k8s = false) {
deploymentName: item.deploymentName,
name: k8s ? item.deploymentName : item.name,
projectName: item.projectName,
ip: item.interfaces?.[0]?.ip,
ip: getDeploymentIps(item),
k8s,
});
}
Expand Down Expand Up @@ -565,6 +565,28 @@ deploymentListManager?.register(uid, () => {
});
onUnmounted(() => deploymentListManager?.unregister(uid));
/**
* Collect the deployment interfaces ips
* @param item deployment data
* @returns {string[]} list of strings
*/
function getDeploymentIps(item: any): string[] {
const ips = [];
// wg ip
if (item.interfaces) {
for (const iface of item.interfaces) {
if (iface.ip) ips.push(iface.ip);
}
}
// public ip, ipv6
if (item.publicIP) {
if (item.publicIP.ip) ips.push(item.publicIP.ip.split("/")[0]);
if (item.publicIP.ip6) ips.push(item.publicIP.ip6.split("/")[0]);
}
if (item.planetary) ips.push(item.planetary);
if (item.myceliumIP) ips.push(item.myceliumIP);
return ips;
}
</script>

<script lang="ts">
Expand Down

0 comments on commit 6591896

Please sign in to comment.