Skip to content

Commit 43ab636

Browse files
committed
restructured network.mjs to remove duplication of flags list and be easier to match up with prepare config
Signed-off-by: Jeromy Cannon <[email protected]>
1 parent 4ec2ce1 commit 43ab636

File tree

1 file changed

+38
-54
lines changed

1 file changed

+38
-54
lines changed

src/commands/network.mjs

Lines changed: 38 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,26 @@ import { constants } from '../core/index.mjs'
2424
import * as prompts from './prompts.mjs'
2525
import * as helpers from '../core/helpers.mjs'
2626

27+
const FLAGS_LIST = [
28+
flags.app,
29+
flags.applicationEnv,
30+
flags.cacheDir,
31+
flags.chainId,
32+
flags.chartDirectory,
33+
flags.enableHederaExplorerTls,
34+
flags.enablePrometheusSvcMonitor,
35+
flags.fstChartVersion,
36+
flags.hederaExplorerTlsHostName,
37+
flags.hederaExplorerTlsLoadBalancerIp,
38+
flags.namespace,
39+
flags.nodeIDs,
40+
flags.profileFile,
41+
flags.profileName,
42+
flags.releaseTag, // we need it to determine which version of root image(Java17 or Java21) we should use
43+
flags.tlsClusterIssuerType,
44+
flags.valuesFile
45+
]
46+
2747
export class NetworkCommand extends BaseCommand {
2848
constructor (opts) {
2949
super(opts)
@@ -73,7 +93,7 @@ export class NetworkCommand extends BaseCommand {
7393
}
7494

7595
const profileName = this.configManager.getFlag(flags.profileName)
76-
this.profileValuesFile = await this.profileManager.prepareValuesForFstChart(profileName, config.applicationEnv)
96+
this.profileValuesFile = await this.profileManager.prepareValuesForFstChart(profileName)
7797
if (this.profileValuesFile) {
7898
valuesArg += this.prepareValuesFiles(this.profileValuesFile)
7999
}
@@ -97,41 +117,32 @@ export class NetworkCommand extends BaseCommand {
97117
}
98118

99119
async prepareConfig (task, argv) {
100-
const flagList = [
101-
flags.releaseTag, // we need it to determine which version of root image(Java17 or Java21) we should use
102-
flags.namespace,
103-
flags.nodeIDs,
104-
flags.chartDirectory,
105-
flags.valuesFile,
106-
flags.tlsClusterIssuerType,
107-
flags.enableHederaExplorerTls,
108-
flags.hederaExplorerTlsHostName,
109-
flags.enablePrometheusSvcMonitor,
110-
flags.profileFile,
111-
flags.profileName
112-
]
113-
114120
this.configManager.update(argv)
115121
this.logger.debug('Loaded cached config', { config: this.configManager.config })
116-
await prompts.execute(task, this.configManager, flagList)
122+
await prompts.execute(task, this.configManager, FLAGS_LIST)
117123

118124
// create a config object for subsequent steps
119125
const config = {
120-
releaseTag: this.configManager.getFlag(flags.releaseTag),
121-
namespace: this.configManager.getFlag(flags.namespace),
122-
nodeIds: helpers.parseNodeIds(this.configManager.getFlag(flags.nodeIDs)),
126+
appName: this.configManager.getFlag(flags.app),
127+
applicationEnv: this.configManager.getFlag(flags.applicationEnv),
128+
cacheDir: this.configManager.getFlag(flags.cacheDir),
129+
chainId: this.configManager.getFlag(flags.chainId),
123130
chartDir: this.configManager.getFlag(flags.chartDirectory),
124-
fstChartVersion: this.configManager.getFlag(flags.fstChartVersion),
125-
valuesFile: this.configManager.getFlag(flags.valuesFile),
126-
tlsClusterIssuerType: this.configManager.getFlag(flags.tlsClusterIssuerType),
127131
enableHederaExplorerTls: this.configManager.getFlag(flags.enableHederaExplorerTls),
128-
hederaExplorerTlsHostName: this.configManager.getFlag(flags.hederaExplorerTlsHostName),
129132
enablePrometheusSvcMonitor: this.configManager.getFlag(flags.enablePrometheusSvcMonitor),
130-
applicationEnv: this.configManager.getFlag(flags.applicationEnv)
133+
fstChartVersion: this.configManager.getFlag(flags.fstChartVersion),
134+
hederaExplorerTlsHostName: this.configManager.getFlag(flags.hederaExplorerTlsHostName),
135+
hederaExplorerTlsLoadBalancerIp: this.configManager.getFlag(flags.hederaExplorerTlsLoadBalancerIp),
136+
namespace: this.configManager.getFlag(flags.namespace),
137+
nodeIds: helpers.parseNodeIds(this.configManager.getFlag(flags.nodeIDs)),
138+
profileFile: this.configManager.getFlag(flags.profileFile),
139+
profileName: this.configManager.getFlag(flags.profileName),
140+
releaseTag: this.configManager.getFlag(flags.releaseTag),
141+
tlsClusterIssuerType: this.configManager.getFlag(flags.tlsClusterIssuerType),
142+
valuesFile: this.configManager.getFlag(flags.valuesFile)
131143
}
132144

133145
// compute values
134-
config.hederaExplorerTlsLoadBalancerIp = argv.hederaExplorerTlsLoadBalancerIp
135146
config.chartPath = await this.prepareChartPath(config.chartDir,
136147
constants.FULLSTACK_TESTING_CHART, constants.FULLSTACK_DEPLOYMENT_CHART)
137148

@@ -406,22 +417,7 @@ export class NetworkCommand extends BaseCommand {
406417
.command({
407418
command: 'deploy',
408419
desc: 'Deploy fullstack testing network',
409-
builder: y => flags.setCommandFlags(y,
410-
flags.releaseTag,
411-
flags.namespace,
412-
flags.nodeIDs,
413-
flags.chartDirectory,
414-
flags.valuesFile,
415-
flags.tlsClusterIssuerType,
416-
flags.enableHederaExplorerTls,
417-
flags.hederaExplorerTlsLoadBalancerIp,
418-
flags.hederaExplorerTlsHostName,
419-
flags.enablePrometheusSvcMonitor,
420-
flags.fstChartVersion,
421-
flags.profileFile,
422-
flags.profileName,
423-
flags.applicationEnv
424-
),
420+
builder: y => flags.setCommandFlags(y, ...FLAGS_LIST),
425421
handler: argv => {
426422
networkCmd.logger.debug('==== Running \'network deploy\' ===')
427423
networkCmd.logger.debug(argv)
@@ -461,19 +457,7 @@ export class NetworkCommand extends BaseCommand {
461457
.command({
462458
command: 'refresh',
463459
desc: 'Refresh fullstack testing network deployment',
464-
builder: y => flags.setCommandFlags(y,
465-
flags.namespace,
466-
flags.chartDirectory,
467-
flags.valuesFile,
468-
flags.deployMirrorNode,
469-
flags.deployHederaExplorer,
470-
flags.tlsClusterIssuerType,
471-
flags.enableHederaExplorerTls,
472-
flags.hederaExplorerTlsLoadBalancerIp,
473-
flags.hederaExplorerTlsHostName,
474-
flags.enablePrometheusSvcMonitor,
475-
flags.applicationEnv
476-
),
460+
builder: y => flags.setCommandFlags(y, ...FLAGS_LIST),
477461
handler: argv => {
478462
networkCmd.logger.debug('==== Running \'chart upgrade\' ===')
479463
networkCmd.logger.debug(argv)

0 commit comments

Comments
 (0)