mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-19 00:40:40 +02:00
Make org subnet optional
This commit is contained in:
parent
1dff9baa61
commit
021bc073a2
6 changed files with 31 additions and 4 deletions
|
@ -240,6 +240,14 @@ export async function getNextAvailableClientSubnet(
|
|||
): Promise<string> {
|
||||
const [org] = await db.select().from(orgs).where(eq(orgs.orgId, orgId));
|
||||
|
||||
if (!org) {
|
||||
throw new Error(`Organization with ID ${orgId} not found`);
|
||||
}
|
||||
|
||||
if (!org.subnet) {
|
||||
throw new Error(`Organization with ID ${orgId} has no subnet defined`);
|
||||
}
|
||||
|
||||
const existingAddressesSites = await db
|
||||
.select({
|
||||
address: sites.address
|
||||
|
@ -279,7 +287,7 @@ export async function getNextAvailableOrgSubnet(): Promise<string> {
|
|||
.from(orgs)
|
||||
.where(isNotNull(orgs.subnet));
|
||||
|
||||
const addresses = existingAddresses.map((org) => org.subnet);
|
||||
const addresses = existingAddresses.map((org) => org.subnet!);
|
||||
|
||||
let subnet = findNextAvailableCidr(
|
||||
addresses,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue