Skip to content

Commit d21abb7

Browse files
committed
TODO design
Signed-off-by: Jeromy Cannon <[email protected]>
1 parent 0026118 commit d21abb7

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

src/commands/node.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ export class NodeCommand extends BaseCommand {
552552
{
553553
title: 'Prepare config.txt for the network',
554554
task: async (ctx, _) => {
555+
// TODO: move this to profile manager, the flags need to go to init and network commands
555556
const config = ctx.config
556557
const configTxtPath = `${config.stagingDir}/config.txt`
557558
const template = `${constants.RESOURCES_DIR}/templates/config.template`
@@ -1311,6 +1312,7 @@ export class NodeCommand extends BaseCommand {
13111312
{
13121313
title: 'Prepare config.txt for the network',
13131314
task: async (ctx, _) => {
1315+
// TODO: move this to profile manager, the flags need to go to init and network commands
13141316
const config = ctx.config
13151317
const configTxtPath = `${config.stagingDir}/config.txt`
13161318
const template = `${constants.RESOURCES_DIR}/templates/config.template`

src/core/platform_installer.mjs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ export class PlatformInstaller {
177177
}
178178
}
179179

180+
// TODO delete this we will update profileManager.resourcesForConsensusPod to read these files and put into the values.yaml
180181
async copyPlatformConfigFiles (podName, stagingDir) {
181182
const self = this
182183

@@ -270,14 +271,17 @@ export class PlatformInstaller {
270271

271272
/**
272273
* Prepares config.txt file for the node
273-
* @param nodeIDs node IDs
274-
* @param destPath path where config.txt should be written
275-
* @param releaseTag release tag e.g. v0.42.0
276-
* @param template path to the confit.template file
277-
* @param chainId chain ID (298 for local network)
274+
* @param {string[]} nodeIDs node IDs
275+
* @param {string} destPath path where config.txt should be written
276+
* @param {string} releaseTag release tag e.g. v0.42.0
277+
* @param {string} template path to the config.template file
278+
* @param {string} chainId chain ID (298 for local network)
279+
* @param {string} appName the app name (default: HederaNode.jar)
278280
* @returns {Promise<string[]>}
279281
*/
280282
async prepareConfigTxt (nodeIDs, destPath, releaseTag, chainId = constants.HEDERA_CHAIN_ID, template = `${constants.RESOURCES_DIR}/templates/config.template`, appName = constants.HEDERA_APP_NAME) {
283+
// TODO: move this to profile manager
284+
// TODO: nodeIds should come from argv, it is required, it is already in profileManager.resourcesForConsensusPod
281285
if (!nodeIDs || nodeIDs.length === 0) throw new MissingArgumentError('list of node IDs is required')
282286
if (!destPath) throw new MissingArgumentError('destPath is required')
283287
if (!template) throw new MissingArgumentError('config templatePath is required')
@@ -294,9 +298,10 @@ export class PlatformInstaller {
294298
const releaseVersion = semver.parse(releaseTag, { includePrerelease: true })
295299

296300
try {
301+
// TODO we need to build the config.txt prior to deploying the network
297302
const networkNodeServicesMap = await this.accountManager.getNodeServiceMap(this._getNamespace())
298303
/** @type {string[]} */
299-
const configLines = []
304+
const configLines = fs.readFileSync(template, 'utf-8').split('\n')
300305
configLines.push(`swirld, ${chainId}`)
301306
configLines.push(`app, ${appName}`)
302307

@@ -309,6 +314,7 @@ export class PlatformInstaller {
309314
const internalIP = Templates.renderFullyQualifiedNetworkPodName(this._getNamespace(), nodeId)
310315
const externalIP = Templates.renderFullyQualifiedNetworkSvcName(this._getNamespace(), nodeId)
311316

317+
// TODO yamlRoot returned from ProfileManager.resourcesForConsensusPod (called from prepareValuesForFstChart) has: { hedera.nodes.${nodeIndex}.name & hedera.nodes.${nodeIndex}.accountId } const account = networkNodeServices.accountId
312318
const account = networkNodeServices.accountId
313319
if (releaseVersion.minor >= 40) {
314320
configLines.push(`address, ${nodeSeq}, ${nodeNickName}, ${nodeName}, ${nodeStakeAmount}, ${internalIP}, ${internalPort}, ${externalIP}, ${externalPort}, ${account}`)

src/core/profile_manager.mjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ export class ProfileManager {
145145
}
146146
}
147147

148+
// TODO need to pass through the config.releaseTag, config.chainId, and config.app
148149
resourcesForConsensusPod (profile, nodeIds, yamlRoot) {
149150
if (!profile) throw new MissingArgumentError('profile is required')
150151

@@ -155,11 +156,25 @@ export class ProfileManager {
155156

156157
// set consensus pod level resources
157158
for (let nodeIndex = 0; nodeIndex < nodeIds.length; nodeIndex++) {
159+
// TODO here is where the nodeId is set, hedera.nodes.${nodeIndex}.name
158160
this._setValue(`hedera.nodes.${nodeIndex}.name`, nodeIds[nodeIndex], yamlRoot)
161+
// TODO here is where the accountId is set, hedera.nodes.${nodeIndex}.accountId
159162
this._setValue(`hedera.nodes.${nodeIndex}.accountId`, `${realm}.${shard}.${accountId++}`, yamlRoot)
160163
this._setChartItems(`hedera.nodes.${nodeIndex}`, profile.consensus, yamlRoot)
161164
}
162165

166+
// TODO prepareConfigTxt then set the value
167+
// TODO load the files and set the values
168+
// hedera:
169+
// configMaps:
170+
// apiPermissionsProperties: ""
171+
// applicationEnv: ""
172+
// applicationProperties: ""
173+
// bootstrapProperties: ""
174+
// configTxt: ""
175+
// log4j2Xml: ""
176+
// settingsTxt: ""
177+
163178
if (profile.consensus) {
164179
// set default for consensus pod
165180
this._setChartItems('defaults.root', profile.consensus.root, yamlRoot)
@@ -217,6 +232,8 @@ export class ProfileManager {
217232
* @return {Promise<string>} return the full path to the values file
218233
*/
219234
prepareValuesForFstChart (profileName, applicationEnvFilePath = '') {
235+
// TODO need to pass through the config.releaseTag, config.chainId, and config.app
236+
220237
if (!profileName) throw new MissingArgumentError('profileName is required')
221238
const profile = this.getProfile(profileName)
222239

@@ -225,6 +242,7 @@ export class ProfileManager {
225242

226243
// generate the yaml
227244
const yamlRoot = {}
245+
// TODO yamlRoot returned from ProfileManager.resourcesForConsensusPod (called from prepareValuesForFstChart) has: { hedera.nodes.${nodeIndex}.name & hedera.nodes.${nodeIndex}.accountId }
228246
this.resourcesForConsensusPod(profile, nodeIds, yamlRoot)
229247
this.resourcesForHaProxyPod(profile, yamlRoot)
230248
this.resourcesForEnvoyProxyPod(profile, yamlRoot)

0 commit comments

Comments
 (0)