|
|
@ -20,16 +20,33 @@ export const getFence: RequestHandler = buildGetRequestHandler( |
|
|
|
|
|
|
|
|
|
|
|
const afterQueryReturn: QueryResultModifierFunction | undefined = |
|
|
|
const afterQueryReturn: QueryResultModifierFunction | undefined = |
|
|
|
buildQueryResultReducer<{ [fenceUUID: string]: FenceOverview }>( |
|
|
|
buildQueryResultReducer<{ [fenceUUID: string]: FenceOverview }>( |
|
|
|
(previous, [fenceUUID, fenceName, fenceAgent, fenceArgumentString]) => { |
|
|
|
( |
|
|
|
const fenceParameters = fenceArgumentString |
|
|
|
previous, |
|
|
|
.split(/\s+/) |
|
|
|
[fenceUUID, fenceName, fenceAgent, fenceParametersString], |
|
|
|
.reduce<FenceParameters>((previous, parameterPair) => { |
|
|
|
) => { |
|
|
|
const [parameterId, parameterValue] = parameterPair.split(/=/); |
|
|
|
const fenceParametersArray = fenceParametersString.match( |
|
|
|
|
|
|
|
/(?:[^\s'"]+|'[^']*'|"[^"]*")+/g, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!fenceParametersArray) return previous; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const fenceParameters = fenceParametersArray.reduce<FenceParameters>( |
|
|
|
|
|
|
|
(previousParameters, parameterString) => { |
|
|
|
|
|
|
|
const parameterPair = parameterString.split(/=(.*)/, 2); |
|
|
|
|
|
|
|
|
|
|
|
previous[parameterId] = parameterValue.replace(/['"]/g, ''); |
|
|
|
if (parameterPair.length !== 2) return previousParameters; |
|
|
|
|
|
|
|
|
|
|
|
return previous; |
|
|
|
const [parameterId, parameterValue] = parameterPair; |
|
|
|
}, {}); |
|
|
|
|
|
|
|
|
|
|
|
previousParameters[parameterId] = parameterValue.replace( |
|
|
|
|
|
|
|
/['"]/g, |
|
|
|
|
|
|
|
'', |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return previousParameters; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{}, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
stdout( |
|
|
|
stdout( |
|
|
|
`${fenceAgent}: ${fenceName} (${fenceUUID})\n${JSON.stringify( |
|
|
|
`${fenceAgent}: ${fenceName} (${fenceUUID})\n${JSON.stringify( |
|
|
|