From 103474a4e2b1a0753967a625af164fa69f2664e2 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Sun, 2 Jul 2023 20:50:28 -0400 Subject: [PATCH] fix(striker-ui-api): add create_bridge to build network config --- .../src/lib/fconfig/buildNetworkConfig.ts | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/striker-ui-api/src/lib/fconfig/buildNetworkConfig.ts b/striker-ui-api/src/lib/fconfig/buildNetworkConfig.ts index 7f8930ad..3252f443 100644 --- a/striker-ui-api/src/lib/fconfig/buildNetworkConfig.ts +++ b/striker-ui-api/src/lib/fconfig/buildNetworkConfig.ts @@ -3,13 +3,19 @@ import { cvar } from '../varn'; export const buildNetworkConfig = ( networks: InitializeStrikerNetworkForm[], - configStep = 2, + { + netconfStep = 2, + netcountStep = 1, + }: { + netconfStep?: number; + netcountStep?: number; + } = {}, ): FormConfigData => { const { counters: ncounts, data: cdata } = networks.reduce<{ counters: Record; data: FormConfigData; }>( - (previous, { interfaces, ipAddress, subnetMask, type }) => { + (previous, { createBridge, interfaces, ipAddress, subnetMask, type }) => { const { counters } = previous; counters[type] = counters[type] ? counters[type] + 1 : 1; @@ -18,24 +24,32 @@ export const buildNetworkConfig = ( previous.data = { ...previous.data, - [cvar(configStep, `${networkShortName}_ip`)]: { - step: configStep, + [cvar(netconfStep, `${networkShortName}_ip`)]: { + step: netconfStep, value: ipAddress, }, - [cvar(configStep, `${networkShortName}_subnet_mask`)]: { - step: configStep, + [cvar(netconfStep, `${networkShortName}_subnet_mask`)]: { + step: netconfStep, value: subnetMask, }, ...buildNetworkLinkConfig(networkShortName, interfaces), }; + if (createBridge) { + previous.data[cvar(netconfStep, `${networkShortName}_create_bridge`)] = + { + step: netconfStep, + value: createBridge, + }; + } + return previous; }, { counters: {}, data: {} }, ); Object.entries(ncounts).forEach(([ntype, ncount]) => { - cdata[cvar(1, `${ntype}_count`)] = { value: ncount }; + cdata[cvar(netcountStep, `${ntype}_count`)] = { value: ncount }; }); return cdata;