mirror of
https://github.com/fosrl/pangolin.git
synced 2026-05-24 17:52:33 +00:00
Fix deleting resource
This commit is contained in:
@@ -52,6 +52,16 @@ export async function deleteResource(
|
|||||||
.from(targets)
|
.from(targets)
|
||||||
.where(eq(targets.resourceId, resourceId));
|
.where(eq(targets.resourceId, resourceId));
|
||||||
|
|
||||||
|
const healthChecksToBeRemoved = await db
|
||||||
|
.select()
|
||||||
|
.from(targetHealthCheck)
|
||||||
|
.where(
|
||||||
|
inArray(
|
||||||
|
targetHealthCheck.targetId,
|
||||||
|
targetsToBeRemoved.map((t) => t.targetId)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
const [deletedResource] = await db
|
const [deletedResource] = await db
|
||||||
.delete(resources)
|
.delete(resources)
|
||||||
.where(eq(resources.resourceId, resourceId))
|
.where(eq(resources.resourceId, resourceId))
|
||||||
@@ -91,16 +101,11 @@ export async function deleteResource(
|
|||||||
.where(eq(newts.siteId, site.siteId))
|
.where(eq(newts.siteId, site.siteId))
|
||||||
.limit(1);
|
.limit(1);
|
||||||
|
|
||||||
const [healthCheck] = await db
|
|
||||||
.select()
|
|
||||||
.from(targetHealthCheck)
|
|
||||||
.where(eq(targetHealthCheck.targetId, target.targetId));
|
|
||||||
|
|
||||||
await removeTargets(
|
await removeTargets(
|
||||||
newt.newtId,
|
newt.newtId,
|
||||||
// [target],
|
// [target],
|
||||||
[], // deleting the target from newt causes issues because we cant unbind the port. this needs to be fixed in newt before we can do this
|
[], // deleting the target from newt causes issues because we cant unbind the port. this needs to be fixed in newt before we can do this
|
||||||
[healthCheck],
|
healthChecksToBeRemoved,
|
||||||
deletedResource.protocol,
|
deletedResource.protocol,
|
||||||
newt.version
|
newt.version
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user