refactor(striker-ui-api): replace 'local' with constant

main
Tsu-ba-me 2 years ago
parent f9bd775ed6
commit 1b6f1c2a2e
  1. 2
      striker-ui-api/src/lib/accessModule.ts
  2. 4
      striker-ui-api/src/lib/request_handlers/host/getHost.ts
  3. 4
      striker-ui-api/src/lib/request_handlers/host/getHostConnection.ts
  4. 4
      striker-ui-api/src/lib/request_handlers/ssh-key/getSSHKey.ts

@ -147,7 +147,7 @@ const getLocalHostUUID = () => {
subModuleName: 'Get', subModuleName: 'Get',
}).stdout; }).stdout;
} catch (subError) { } catch (subError) {
throw new Error(`Failed to get local host UUID; CAUSE: ${subError}`); throw new Error(`Failed to get localhost UUID; CAUSE: ${subError}`);
} }
shout(`localHostUUID=[${result}]`); shout(`localHostUUID=[${result}]`);

@ -1,3 +1,5 @@
import { LOCAL } from '../../consts/LOCAL';
import { getLocalHostUUID } from '../../accessModule'; import { getLocalHostUUID } from '../../accessModule';
import buildGetRequestHandler from '../buildGetRequestHandler'; import buildGetRequestHandler from '../buildGetRequestHandler';
import { buildQueryHostDetail } from './buildQueryHostDetail'; import { buildQueryHostDetail } from './buildQueryHostDetail';
@ -21,7 +23,7 @@ export const getHost = buildGetRequestHandler((request, buildQueryOptions) => {
if (output instanceof Array) { if (output instanceof Array) {
result = output.reduce<Record<string, HostOverview>>( result = output.reduce<Record<string, HostOverview>>(
(previous, [hostName, hostUUID]) => { (previous, [hostName, hostUUID]) => {
const key = hostUUID === localHostUUID ? 'local' : hostUUID; const key = hostUUID === localHostUUID ? LOCAL : hostUUID;
previous[key] = { hostName, hostUUID }; previous[key] = { hostName, hostUUID };

@ -1,3 +1,5 @@
import { LOCAL } from '../../consts/LOCAL';
import { getAnvilData, getLocalHostUUID } from '../../accessModule'; import { getAnvilData, getLocalHostUUID } from '../../accessModule';
import { buildUnknownIDCondition } from '../../buildCondition'; import { buildUnknownIDCondition } from '../../buildCondition';
import buildGetRequestHandler from '../buildGetRequestHandler'; import buildGetRequestHandler from '../buildGetRequestHandler';
@ -61,7 +63,7 @@ export const getHostConnection = buildGetRequestHandler(
beforeBuildIDCond.length > 0 ? beforeBuildIDCond : [localHostUUID]; beforeBuildIDCond.length > 0 ? beforeBuildIDCond : [localHostUUID];
const getConnectionKey = (hostUUID: string) => const getConnectionKey = (hostUUID: string) =>
hostUUID === localHostUUID ? 'local' : hostUUID; hostUUID === localHostUUID ? LOCAL : hostUUID;
process.stdout.write(`condHostUUIDs=[${condHostUUIDs}]\n`); process.stdout.write(`condHostUUIDs=[${condHostUUIDs}]\n`);

@ -1,3 +1,5 @@
import { LOCAL } from '../../consts/LOCAL';
import { getLocalHostUUID } from '../../accessModule'; import { getLocalHostUUID } from '../../accessModule';
import buildGetRequestHandler from '../buildGetRequestHandler'; import buildGetRequestHandler from '../buildGetRequestHandler';
import { buildQueryResultReducer } from '../../buildQueryResultModifier'; import { buildQueryResultReducer } from '../../buildQueryResultModifier';
@ -28,7 +30,7 @@ const MAP_TO_HANDLER: Record<string, BuildQuerySubFunction> = {
}; };
}; };
}>((previous, [hostName, hostUUID, stateName, stateNote, stateUUID]) => { }>((previous, [hostName, hostUUID, stateName, stateNote, stateUUID]) => {
const hostUUIDKey = hostUUID === localHostUUID ? 'local' : hostUUID; const hostUUIDKey = hostUUID === localHostUUID ? LOCAL : hostUUID;
if (previous[hostUUIDKey] === undefined) { if (previous[hostUUIDKey] === undefined) {
previous[hostUUIDKey] = {}; previous[hostUUIDKey] = {};

Loading…
Cancel
Save