mirror of
https://github.com/fosrl/pangolin.git
synced 2026-05-25 02:03:03 +00:00
Handle crud to newt with new hcs
This commit is contained in:
@@ -205,7 +205,14 @@ export async function buildTargetConfigurationForNewtClient(
|
||||
port: targets.port,
|
||||
internalPort: targets.internalPort,
|
||||
enabled: targets.enabled,
|
||||
protocol: resources.protocol,
|
||||
protocol: resources.protocol
|
||||
})
|
||||
.from(targets)
|
||||
.innerJoin(resources, eq(targets.resourceId, resources.resourceId))
|
||||
.where(and(eq(targets.siteId, siteId), eq(targets.enabled, true)));
|
||||
|
||||
const allHealthChecks = await db
|
||||
.select({
|
||||
targetHealthCheckId: targetHealthCheck.targetHealthCheckId,
|
||||
hcEnabled: targetHealthCheck.hcEnabled,
|
||||
hcPath: targetHealthCheck.hcPath,
|
||||
@@ -224,13 +231,13 @@ export async function buildTargetConfigurationForNewtClient(
|
||||
hcHealthyThreshold: targetHealthCheck.hcHealthyThreshold,
|
||||
hcUnhealthyThreshold: targetHealthCheck.hcUnhealthyThreshold
|
||||
})
|
||||
.from(targets)
|
||||
.innerJoin(resources, eq(targets.resourceId, resources.resourceId))
|
||||
.leftJoin(
|
||||
targetHealthCheck,
|
||||
eq(targets.targetId, targetHealthCheck.targetId)
|
||||
)
|
||||
.where(and(eq(targets.siteId, siteId), eq(targets.enabled, true)));
|
||||
.from(targetHealthCheck)
|
||||
.where(
|
||||
and(
|
||||
eq(targetHealthCheck.siteId, siteId),
|
||||
eq(targetHealthCheck.hcEnabled, true)
|
||||
)
|
||||
);
|
||||
|
||||
const { tcpTargets, udpTargets } = allTargets.reduce(
|
||||
(acc, target) => {
|
||||
@@ -254,7 +261,7 @@ export async function buildTargetConfigurationForNewtClient(
|
||||
{ tcpTargets: [] as string[], udpTargets: [] as string[] }
|
||||
);
|
||||
|
||||
const healthCheckTargets = allTargets.map((target) => {
|
||||
const healthCheckTargets = allHealthChecks.map((target) => {
|
||||
// make sure the stuff is defined
|
||||
const isTCP = target.hcMode?.toLowerCase() === "tcp";
|
||||
if (!target.hcHostname || !target.hcPort || !target.hcInterval) {
|
||||
|
||||
Reference in New Issue
Block a user