From 690b52d8c66d5bb320255bb4c9d15b2bd3319f61 Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Sat, 24 Aug 2024 10:12:30 -0400 Subject: [PATCH] chore(TALE-29): remove acl from integration/context --- app/components/Header.tsx | 1 - app/integration/docker.ts | 30 -------------------------- app/integration/integration.ts | 1 - app/integration/kubernetes.ts | 9 -------- app/integration/proc.ts | 11 +--------- app/routes/_data.acls._index/route.tsx | 4 ---- app/routes/_data.tsx | 1 - app/utils/config/headplane.ts | 6 ------ 8 files changed, 1 insertion(+), 62 deletions(-) diff --git a/app/components/Header.tsx b/app/components/Header.tsx index 51ce8e9..d6de368 100644 --- a/app/components/Header.tsx +++ b/app/components/Header.tsx @@ -10,7 +10,6 @@ import TabLink from './TabLink' interface Properties { readonly data?: { - acl: HeadplaneContext['acl'] config: HeadplaneContext['config'] user?: SessionData['user'] } diff --git a/app/integration/docker.ts b/app/integration/docker.ts index e31966c..b2e501b 100644 --- a/app/integration/docker.ts +++ b/app/integration/docker.ts @@ -88,36 +88,6 @@ export default createIntegration({ return context.client !== undefined }, - onAclChange: async (context) => { - if (!context.client || !context.container) { - return - } - - log.info('INTG', 'Sending SIGHUP to Headscale via Docker') - - let attempts = 0 - while (attempts <= context.maxAttempts) { - const response = await context.client.request({ - method: 'POST', - path: `/v1.30/containers/${context.container}/kill?signal=SIGHUP`, - }) - - if (response.statusCode !== 204) { - if (attempts < context.maxAttempts) { - attempts++ - await setTimeout(1000) - continue - } - - const stringCode = response.statusCode.toString() - const body = await response.body.text() - throw new Error(`API request failed: ${stringCode} ${body}`) - } - - break - } - }, - onConfigChange: async (context) => { if (!context.client || !context.container) { return diff --git a/app/integration/integration.ts b/app/integration/integration.ts index c1e1056..671fea2 100644 --- a/app/integration/integration.ts +++ b/app/integration/integration.ts @@ -3,7 +3,6 @@ export interface IntegrationFactory { name: string context: T isAvailable: (context: T) => Promise | boolean - onAclChange?: (context: T) => Promise | void onConfigChange?: (context: T) => Promise | void } diff --git a/app/integration/kubernetes.ts b/app/integration/kubernetes.ts index 345ecde..ccca0db 100644 --- a/app/integration/kubernetes.ts +++ b/app/integration/kubernetes.ts @@ -177,15 +177,6 @@ export default createIntegration({ } }, - onAclChange: (context) => { - if (!context.pid) { - return - } - - log.info('INTG', 'Sending SIGHUP to Headscale') - kill(context.pid, 'SIGHUP') - }, - onConfigChange: (context) => { if (!context.pid) { return diff --git a/app/integration/proc.ts b/app/integration/proc.ts index d50d6ea..64c3628 100644 --- a/app/integration/proc.ts +++ b/app/integration/proc.ts @@ -70,14 +70,5 @@ export default createIntegration({ log.error('INTG', 'Failed to read /proc') return false } - }, - - onAclChange: (context) => { - if (!context.pid) { - return - } - - log.info('INTG', 'Sending SIGHUP to Headscale') - kill(context.pid, 'SIGHUP') - }, + } }) diff --git a/app/routes/_data.acls._index/route.tsx b/app/routes/_data.acls._index/route.tsx index e994ed7..d466560 100644 --- a/app/routes/_data.acls._index/route.tsx +++ b/app/routes/_data.acls._index/route.tsx @@ -82,10 +82,6 @@ export async function action({ request }: ActionFunctionArgs) { }) } - if (context.integration?.onAclChange) { - await context.integration.onAclChange(context.integration.context) - } - return json({ success: true }) } diff --git a/app/routes/_data.tsx b/app/routes/_data.tsx index 8f51763..1dbdc4c 100644 --- a/app/routes/_data.tsx +++ b/app/routes/_data.tsx @@ -35,7 +35,6 @@ export async function loader({ request }: LoaderFunctionArgs) { const context = await loadContext() return { - acl: context.acl, config: context.config, user: session.get('user'), } diff --git a/app/utils/config/headplane.ts b/app/utils/config/headplane.ts index 8825fcc..6987bcd 100644 --- a/app/utils/config/headplane.ts +++ b/app/utils/config/headplane.ts @@ -22,11 +22,6 @@ export interface HeadplaneContext { write: boolean } - acl: { - read: boolean - write: boolean - } - oidc?: { issuer: string client: string @@ -69,7 +64,6 @@ export async function loadContext(): Promise { cookieSecret, integration: await loadIntegration(), config: contextData, - acl: await checkAcl(config), oidc: await checkOidc(config), }