Skip to content

Commit 537fc1a

Browse files
committed
set the networks deploy config with the contexts and the consensus nodes for later use
Signed-off-by: Jeromy Cannon <[email protected]>
1 parent e86e94c commit 537fc1a

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

src/commands/network.ts

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {type NamespaceName} from '../core/kube/resources/namespace/namespace_nam
3232
import {SecretType} from '../core/kube/resources/secret/secret_type.js';
3333
import {PvcRef} from '../core/kube/resources/pvc/pvc_ref.js';
3434
import {PvcName} from '../core/kube/resources/pvc/pvc_name.js';
35+
import {type ConsensusNode} from '../core/model/consensus_node.js';
3536

3637
export interface NetworkDeployConfigClass {
3738
applicationEnv: string;
@@ -72,6 +73,8 @@ export interface NetworkDeployConfigClass {
7273
storageBucketPrefix: string;
7374
backupBucket: string;
7475
googleCredential: string;
76+
consensusNodes: ConsensusNode[];
77+
contexts: string[];
7578
}
7679

7780
export class NetworkCommand extends BaseCommand {
@@ -381,16 +384,22 @@ export class NetworkCommand extends BaseCommand {
381384
const namespace = await resolveNamespaceFromDeployment(this.localConfig, this.configManager, task);
382385

383386
// create a config object for subsequent steps
384-
const config = this.getConfig(NetworkCommand.DEPLOY_CONFIGS_NAME, NetworkCommand.DEPLOY_FLAGS_LIST, [
385-
'chartPath',
386-
'keysDir',
387-
'nodeAliases',
388-
'stagingDir',
389-
'stagingKeysDir',
390-
'valuesArg',
391-
'resolvedThrottlesFile',
392-
'namespace',
393-
]) as NetworkDeployConfigClass;
387+
const config: NetworkDeployConfigClass = this.getConfig(
388+
NetworkCommand.DEPLOY_CONFIGS_NAME,
389+
NetworkCommand.DEPLOY_FLAGS_LIST,
390+
[
391+
'chartPath',
392+
'keysDir',
393+
'nodeAliases',
394+
'stagingDir',
395+
'stagingKeysDir',
396+
'valuesArg',
397+
'resolvedThrottlesFile',
398+
'namespace',
399+
'consensusNodes',
400+
'contexts',
401+
],
402+
) as NetworkDeployConfigClass;
394403

395404
config.nodeAliases = helpers.parseNodeAliases(config.nodeAliasesUnparsed);
396405

@@ -422,6 +431,9 @@ export class NetworkCommand extends BaseCommand {
422431
config.valuesArg = await this.prepareValuesArg(config);
423432
config.namespace = namespace;
424433

434+
config.consensusNodes = this.getConsensusNodes();
435+
config.contexts = this.getContexts();
436+
425437
if (!(await this.k8Factory.default().namespaces().has(namespace))) {
426438
await this.k8Factory.default().namespaces().create(namespace);
427439
}

test/unit/commands/network.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,14 @@ describe('NetworkCommand unit tests', () => {
121121
GenesisNetworkDataConstructor.initialize = sinon.stub().returns(null);
122122
});
123123

124+
afterEach(() => {
125+
sinon.restore();
126+
});
127+
124128
it('Install function is called with expected parameters', async () => {
125129
const networkCommand = new NetworkCommand(opts);
130+
sinon.stub(networkCommand, 'getConsensusNodes').resolves([]);
131+
sinon.stub(networkCommand, 'getContexts').resolves([]);
126132
await networkCommand.deploy(argv);
127133

128134
expect(opts.chartManager.install.args[0][0].name).to.equal(constants.SOLO_TEST_CLUSTER);
@@ -138,6 +144,8 @@ describe('NetworkCommand unit tests', () => {
138144
argv[flags.force.name] = true;
139145

140146
const networkCommand = new NetworkCommand(opts);
147+
sinon.stub(networkCommand, 'getConsensusNodes').resolves([]);
148+
sinon.stub(networkCommand, 'getContexts').resolves([]);
141149
await networkCommand.deploy(argv);
142150
expect(opts.chartManager.install.args[0][0].name).to.equal(constants.SOLO_TEST_CLUSTER);
143151
expect(opts.chartManager.install.args[0][1]).to.equal(constants.SOLO_DEPLOYMENT_CHART);

0 commit comments

Comments
 (0)