From 09b69820b448a39bf86d4b31b3851d517203f122 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Wed, 28 Jun 2023 17:22:47 -0400 Subject: [PATCH] fix(striker-ui-api): add anvil data fence hash type --- striker-ui-api/src/lib/accessModule.ts | 2 +- .../fence/getFenceTemplate.ts | 6 ++-- .../src/types/GetAnvilDataFunction.d.ts | 32 +++++++++++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/striker-ui-api/src/lib/accessModule.ts b/striker-ui-api/src/lib/accessModule.ts index 0fe44518..1432ffc3 100644 --- a/striker-ui-api/src/lib/accessModule.ts +++ b/striker-ui-api/src/lib/accessModule.ts @@ -278,7 +278,7 @@ const getAnvilData = async () => { const getFenceSpec = async () => { await subroutine('get_fence_data', { pre: ['Striker'] }); - return getData('fence_data'); + return getData('fence_data'); }; const getHostData = async () => { diff --git a/striker-ui-api/src/lib/request_handlers/fence/getFenceTemplate.ts b/striker-ui-api/src/lib/request_handlers/fence/getFenceTemplate.ts index 7a723fcd..0dfde601 100644 --- a/striker-ui-api/src/lib/request_handlers/fence/getFenceTemplate.ts +++ b/striker-ui-api/src/lib/request_handlers/fence/getFenceTemplate.ts @@ -4,10 +4,10 @@ import { getFenceSpec } from '../../accessModule'; import { stderr } from '../../shell'; export const getFenceTemplate: RequestHandler = async (request, response) => { - let rawFenceData; + let rFenceData: AnvilDataFenceHash; try { - rawFenceData = await getFenceSpec(); + rFenceData = await getFenceSpec(); } catch (subError) { stderr(`Failed to get fence device template; CAUSE: ${subError}`); @@ -16,5 +16,5 @@ export const getFenceTemplate: RequestHandler = async (request, response) => { return; } - response.status(200).send(rawFenceData); + response.status(200).send(rFenceData); }; diff --git a/striker-ui-api/src/types/GetAnvilDataFunction.d.ts b/striker-ui-api/src/types/GetAnvilDataFunction.d.ts index 93b351b5..53433c40 100644 --- a/striker-ui-api/src/types/GetAnvilDataFunction.d.ts +++ b/striker-ui-api/src/types/GetAnvilDataFunction.d.ts @@ -33,6 +33,38 @@ type AnvilDataDatabaseHash = { }; }; +type AnvilDataFenceParameterType = + | 'boolean' + | 'integer' + | 'second' + | 'select' + | 'string'; + +type AnvilDataFenceHash = { + [agent: string]: { + actions: string[]; + description: string; + parameters: { + [parameterId: string]: { + content_type: AnvilDataFenceParameterType; + default?: string; + deprecated: number; + description: string; + obsoletes: number; + options?: string[]; + replacement: string; + required: '0' | '1'; + switches: string; + unique: '0' | '1'; + }; + }; + switch: { + [switchId: string]: { name: string }; + }; + symlink?: { [agent: string]: string }; + }; +}; + type AnvilDataHostListHash = { host_uuid: { [hostUuid: string]: {