fix(striker-ui-api): add anvil data fence hash type

main
Tsu-ba-me 2 years ago
parent 4bbacab09f
commit 09b69820b4
  1. 2
      striker-ui-api/src/lib/accessModule.ts
  2. 6
      striker-ui-api/src/lib/request_handlers/fence/getFenceTemplate.ts
  3. 32
      striker-ui-api/src/types/GetAnvilDataFunction.d.ts

@ -278,7 +278,7 @@ const getAnvilData = async () => {
const getFenceSpec = async () => { const getFenceSpec = async () => {
await subroutine('get_fence_data', { pre: ['Striker'] }); await subroutine('get_fence_data', { pre: ['Striker'] });
return getData<unknown>('fence_data'); return getData<AnvilDataFenceHash>('fence_data');
}; };
const getHostData = async () => { const getHostData = async () => {

@ -4,10 +4,10 @@ import { getFenceSpec } from '../../accessModule';
import { stderr } from '../../shell'; import { stderr } from '../../shell';
export const getFenceTemplate: RequestHandler = async (request, response) => { export const getFenceTemplate: RequestHandler = async (request, response) => {
let rawFenceData; let rFenceData: AnvilDataFenceHash;
try { try {
rawFenceData = await getFenceSpec(); rFenceData = await getFenceSpec();
} catch (subError) { } catch (subError) {
stderr(`Failed to get fence device template; CAUSE: ${subError}`); stderr(`Failed to get fence device template; CAUSE: ${subError}`);
@ -16,5 +16,5 @@ export const getFenceTemplate: RequestHandler = async (request, response) => {
return; return;
} }
response.status(200).send(rawFenceData); response.status(200).send(rFenceData);
}; };

@ -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 = { type AnvilDataHostListHash = {
host_uuid: { host_uuid: {
[hostUuid: string]: { [hostUuid: string]: {

Loading…
Cancel
Save