Skip to content

Commit 1948c26

Browse files
committed
wiring
Signed-off-by: instamenta <[email protected]>
1 parent 7b11550 commit 1948c26

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

src/commands/network.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {ConsensusNodeComponent} from '../core/config/remote/components/consensus
3838
import {ConsensusNodeStates} from '../core/config/remote/enumerations.js';
3939
import {EnvoyProxyComponent} from '../core/config/remote/components/envoy_proxy_component.js';
4040
import {HaProxyComponent} from '../core/config/remote/components/ha_proxy_component.js';
41+
import {GenesisNetworkDataConstructor} from '../core/models/genesisNetworkDataConstructor.js';
4142

4243
export interface NetworkDeployConfigClass {
4344
applicationEnv: string;
@@ -61,7 +62,7 @@ export interface NetworkDeployConfigClass {
6162
grpcWebTlsCertificatePath: string;
6263
grpcTlsKeyPath: string;
6364
grpcWebTlsKeyPath: string;
64-
genesisNetworkJson: string;
65+
genesisNetworkData: GenesisNetworkDataConstructor;
6566
getUnusedConfigs: () => string[];
6667
haproxyIps: string;
6768
envoyIps: string;
@@ -135,16 +136,16 @@ export class NetworkCommand extends BaseCommand {
135136
config: {
136137
chartDirectory?: string;
137138
app?: string;
138-
nodeAliases?: string[];
139+
nodeAliases: string[];
139140
debugNodeAlias?: NodeAlias;
140141
enablePrometheusSvcMonitor?: boolean;
141142
releaseTag?: string;
142143
persistentVolumeClaims?: string;
143144
valuesFile?: string;
144145
haproxyIpsParsed?: Record<NodeAlias, IP>;
145146
envoyIpsParsed?: Record<NodeAlias, IP>;
146-
genesisNetworkJson?: string;
147-
} = {},
147+
genesisNetworkData: GenesisNetworkDataConstructor;
148+
}
148149
) {
149150
let valuesArg = config.chartDirectory
150151
? `-f ${path.join(config.chartDirectory, 'solo-deployment', 'values.yaml')}`
@@ -162,7 +163,7 @@ export class NetworkCommand extends BaseCommand {
162163
}
163164

164165
const profileName = this.configManager.getFlag<string>(flags.profileName) as string;
165-
this.profileValuesFile = await this.profileManager.prepareValuesForSoloChart(profileName);
166+
this.profileValuesFile = await this.profileManager.prepareValuesForSoloChart(profileName, config.genesisNetworkData);
166167
if (this.profileValuesFile) {
167168
valuesArg += this.prepareValuesFiles(this.profileValuesFile);
168169
}
@@ -179,7 +180,7 @@ export class NetworkCommand extends BaseCommand {
179180

180181
// Iterate over each node and set static IPs for HAProxy
181182
if (config.haproxyIpsParsed) {
182-
config.nodeAliases?.forEach((nodeAlias, index) => {
183+
config.nodeAliases.forEach((nodeAlias, index) => {
183184
const ip = config.haproxyIpsParsed?.[nodeAlias];
184185

185186
if (ip) valuesArg += ` --set "hedera.nodes[${index}].haproxyStaticIP=${ip}"`;
@@ -188,7 +189,7 @@ export class NetworkCommand extends BaseCommand {
188189

189190
// Iterate over each node and set static IPs for Envoy Proxy
190191
if (config.envoyIpsParsed) {
191-
config.nodeAliases?.forEach((nodeAlias, index) => {
192+
config.nodeAliases.forEach((nodeAlias, index) => {
192193
const ip = config.envoyIpsParsed?.[nodeAlias];
193194

194195
if (ip) valuesArg += ` --set "hedera.nodes[${index}].envoyProxyStaticIP=${ip}"`;
@@ -199,7 +200,7 @@ export class NetworkCommand extends BaseCommand {
199200
valuesArg += this.prepareValuesFiles(config.valuesFile);
200201
}
201202

202-
valuesArg += `--set "hedera.configMaps.genesisNetworkJson=${config.genesisNetworkJson}"`
203+
valuesArg += `--set "hedera.configMaps.genesisNetworkJson=${config.genesisNetworkData.toJSON()}"`
203204

204205
this.logger.debug('Prepared helm chart values', {valuesArg});
205206
return valuesArg;
@@ -261,7 +262,7 @@ export class NetworkCommand extends BaseCommand {
261262
constants.SOLO_DEPLOYMENT_CHART,
262263
);
263264

264-
config.genesisNetworkJson = this.prepareGenesisNetworkJson(config)
265+
config.genesisNetworkData = new GenesisNetworkDataConstructor(config.nodeAliases);
265266

266267
config.valuesArg = await this.prepareValuesArg(config);
267268

src/core/models/genesisNetworkDataConstructor.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ import {KeyManager} from '../key_manager.js';
2121

2222
import crypto from 'node:crypto';
2323
import {PrivateKey} from '@hashgraph/sdk';
24-
import {constants} from '../index.js';
24+
import * as constants from '../constants.js';
2525

2626
export class GenesisNetworkDataConstructor {
2727
public readonly nodes: Record<NodeAlias, GenesisNetworkNodeDataWrapper>;
2828

29-
constructor (public readonly nodeAliases: NodeAliases) {
29+
public constructor (public readonly nodeAliases: NodeAliases) {
3030
this.nodeAliases.forEach(nodeAlias => {
3131
this.nodes[nodeAlias] = new GenesisNetworkNodeDataWrapper(Templates.nodeIdFromNodeAlias(nodeAlias))
3232

@@ -39,7 +39,7 @@ export class GenesisNetworkDataConstructor {
3939
* @param keyManager
4040
* @param keysDir - !!! config.keysDir !!!
4141
*/
42-
async load (keyManager: KeyManager, keysDir: string) {
42+
public async load (keyManager: KeyManager, keysDir: string) {
4343
await Promise.all(this.nodeAliases.map(async nodeAlias => {
4444
const nodeKeys = await keyManager.loadSigningKey(nodeAlias, keysDir);
4545

@@ -54,4 +54,8 @@ export class GenesisNetworkDataConstructor {
5454
this.nodes[nodeAlias].grpcCertificateHash = hash;
5555
}))
5656
}
57+
58+
public toJSON (): string {
59+
return JSON.stringify(this.nodes);
60+
}
5761
}

src/core/profile_manager.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export class ProfileManager {
171171
}
172172
}
173173

174-
resourcesForConsensusPod(profile: any, nodeAliases: NodeAliases, yamlRoot: object): object {
174+
resourcesForConsensusPod(profile: any, nodeAliases: NodeAliases, yamlRoot: object, genesisNetworkData: GenesisNetworkDataConstructor): object {
175175
if (!profile) throw new MissingArgumentError('profile is required');
176176

177177
const accountMap = getNodeAccountMap(nodeAliases);
@@ -198,6 +198,7 @@ export class ProfileManager {
198198
this.configManager.getFlag(flags.releaseTag),
199199
this.configManager.getFlag(flags.app),
200200
this.configManager.getFlag(flags.chainId),
201+
genesisNetworkData
201202
);
202203

203204
for (const flag of flags.nodeConfigFileFlags.values()) {
@@ -301,9 +302,10 @@ export class ProfileManager {
301302
/**
302303
* Prepare a values file for Solo Helm chart
303304
* @param profileName resource profile name
305+
* @param genesisNetworkData
304306
* @returns return the full path to the values file
305307
*/
306-
prepareValuesForSoloChart(profileName: string) {
308+
prepareValuesForSoloChart(profileName: string, genesisNetworkData: GenesisNetworkDataConstructor) {
307309
if (!profileName) throw new MissingArgumentError('profileName is required');
308310
const profile = this.getProfile(profileName);
309311

@@ -312,7 +314,7 @@ export class ProfileManager {
312314

313315
// generate the YAML
314316
const yamlRoot = {};
315-
this.resourcesForConsensusPod(profile, nodeAliases, yamlRoot);
317+
this.resourcesForConsensusPod(profile, nodeAliases, yamlRoot, genesisNetworkData);
316318
this.resourcesForHaProxyPod(profile, yamlRoot);
317319
this.resourcesForEnvoyProxyPod(profile, yamlRoot);
318320
this.resourcesForMinioTenantPod(profile, yamlRoot);

0 commit comments

Comments
 (0)