@@ -40,7 +40,7 @@ export class NodeCommand extends BaseCommand {
40
40
if ( ! opts || ! opts . keytoolDepManager ) throw new IllegalArgumentError ( 'An instance of KeytoolDependencyManager is required' , opts . keytoolDepManager )
41
41
42
42
this . downloader = opts . downloader
43
- this . plaformInstaller = opts . platformInstaller
43
+ this . platformInstaller = opts . platformInstaller
44
44
this . keyManager = opts . keyManager
45
45
this . accountManager = opts . accountManager
46
46
this . keytoolDepManager = opts . keytoolDepManager
@@ -312,6 +312,51 @@ export class NodeCommand extends BaseCommand {
312
312
}
313
313
}
314
314
315
+ async initializeSetup ( config , configManager , k8 ) {
316
+ // compute other config parameters
317
+ config . releasePrefix = Templates . prepareReleasePrefix ( config . releaseTag )
318
+ config . buildZipFile = `${ config . cacheDir } /${ config . releasePrefix } /build-${ config . releaseTag } .zip`
319
+ config . keysDir = path . join ( config . cacheDir , 'keys' )
320
+ config . stagingDir = Templates . renderStagingDir ( configManager , flags )
321
+ config . stagingKeysDir = path . join ( config . stagingDir , 'keys' )
322
+
323
+ if ( ! await k8 . hasNamespace ( config . namespace ) ) {
324
+ throw new FullstackTestingError ( `namespace ${ config . namespace } does not exist` )
325
+ }
326
+
327
+ // prepare staging keys directory
328
+ if ( ! fs . existsSync ( config . stagingKeysDir ) ) {
329
+ fs . mkdirSync ( config . stagingKeysDir , { recursive : true } )
330
+ }
331
+
332
+ // create cached keys dir if it does not exist yet
333
+ if ( ! fs . existsSync ( config . keysDir ) ) {
334
+ fs . mkdirSync ( config . keysDir )
335
+ }
336
+ }
337
+
338
+ fetchPlatformSoftware ( ctx , task , platformInstaller ) {
339
+ const config = ctx . config
340
+
341
+ const subTasks = [ ]
342
+ for ( const nodeId of ctx . config . nodeIds ) {
343
+ const podName = ctx . config . podNames [ nodeId ]
344
+ subTasks . push ( {
345
+ title : `Node: ${ chalk . yellow ( nodeId ) } ` ,
346
+ task : ( ) =>
347
+ platformInstaller . fetchPlatform ( podName , config . releaseTag )
348
+ } )
349
+ }
350
+
351
+ // set up the sub-tasks
352
+ return task . newListr ( subTasks , {
353
+ concurrent : true , // since we download in the container directly, we want this to be in parallel across all nodes
354
+ rendererOptions : {
355
+ collapseSubtasks : false
356
+ }
357
+ } )
358
+ }
359
+
315
360
async setup ( argv ) {
316
361
const self = this
317
362
@@ -345,26 +390,7 @@ export class NodeCommand extends BaseCommand {
345
390
curDate : new Date ( )
346
391
}
347
392
348
- // compute other config parameters
349
- config . releasePrefix = Templates . prepareReleasePrefix ( config . releaseTag )
350
- config . buildZipFile = `${ config . cacheDir } /${ config . releasePrefix } /build-${ config . releaseTag } .zip`
351
- config . keysDir = path . join ( config . cacheDir , 'keys' )
352
- config . stagingDir = Templates . renderStagingDir ( self . configManager , flags )
353
- config . stagingKeysDir = path . join ( config . stagingDir , 'keys' )
354
-
355
- if ( ! await this . k8 . hasNamespace ( config . namespace ) ) {
356
- throw new FullstackTestingError ( `namespace ${ config . namespace } does not exist` )
357
- }
358
-
359
- // prepare staging keys directory
360
- if ( ! fs . existsSync ( config . stagingKeysDir ) ) {
361
- fs . mkdirSync ( config . stagingKeysDir , { recursive : true } )
362
- }
363
-
364
- // create cached keys dir if it does not exist yet
365
- if ( ! fs . existsSync ( config . keysDir ) ) {
366
- fs . mkdirSync ( config . keysDir )
367
- }
393
+ await self . initializeSetup ( config , self . configManager , self . k8 )
368
394
369
395
// set config in the context for later tasks to use
370
396
ctx . config = config
@@ -474,7 +500,7 @@ export class NodeCommand extends BaseCommand {
474
500
const config = ctx . config
475
501
const configTxtPath = `${ config . stagingDir } /config.txt`
476
502
const template = `${ constants . RESOURCES_DIR } /templates/config.template`
477
- await self . plaformInstaller . prepareConfigTxt ( config . nodeIds , configTxtPath , config . releaseTag , config . chainId , template )
503
+ await self . platformInstaller . prepareConfigTxt ( config . nodeIds , configTxtPath , config . releaseTag , config . chainId , template )
478
504
}
479
505
}
480
506
]
@@ -489,25 +515,7 @@ export class NodeCommand extends BaseCommand {
489
515
title : 'Fetch platform software into network nodes' ,
490
516
task :
491
517
async ( ctx , task ) => {
492
- const config = ctx . config
493
-
494
- const subTasks = [ ]
495
- for ( const nodeId of ctx . config . nodeIds ) {
496
- const podName = ctx . config . podNames [ nodeId ]
497
- subTasks . push ( {
498
- title : `Node: ${ chalk . yellow ( nodeId ) } ` ,
499
- task : ( ) =>
500
- self . plaformInstaller . fetchPlatform ( podName , config . releaseTag )
501
- } )
502
- }
503
-
504
- // set up the sub-tasks
505
- return task . newListr ( subTasks , {
506
- concurrent : true , // since we download in the container directly, we want this to be in parallel across all nodes
507
- rendererOptions : {
508
- collapseSubtasks : false
509
- }
510
- } )
518
+ return self . fetchPlatformSoftware ( ctx , task , self . platformInstaller )
511
519
}
512
520
} ,
513
521
{
@@ -521,7 +529,7 @@ export class NodeCommand extends BaseCommand {
521
529
subTasks . push ( {
522
530
title : `Node: ${ chalk . yellow ( nodeId ) } ` ,
523
531
task : ( ) =>
524
- self . plaformInstaller . taskInstall ( podName , config . buildZipFile , config . stagingDir , config . nodeIds , config . keyFormat , config . force )
532
+ self . platformInstaller . taskInstall ( podName , config . buildZipFile , config . stagingDir , config . nodeIds , config . keyFormat , config . force )
525
533
} )
526
534
}
527
535
@@ -879,45 +887,22 @@ export class NodeCommand extends BaseCommand {
879
887
flags . nodeIDs ,
880
888
flags . releaseTag ,
881
889
flags . cacheDir ,
882
- flags . chainId ,
883
890
flags . keyFormat
884
- ] ) // TODO verify we need all of these
891
+ ] )
885
892
886
893
const config = {
887
894
namespace : self . configManager . getFlag ( flags . namespace ) ,
888
895
nodeIds : helpers . parseNodeIDs ( self . configManager . getFlag ( flags . nodeIDs ) ) ,
889
896
releaseTag : self . configManager . getFlag ( flags . releaseTag ) ,
890
897
cacheDir : self . configManager . getFlag ( flags . cacheDir ) ,
891
898
force : self . configManager . getFlag ( flags . force ) ,
892
- chainId : self . configManager . getFlag ( flags . chainId ) ,
893
899
applicationEnv : self . configManager . getFlag ( flags . applicationEnv ) ,
894
900
keyFormat : self . configManager . getFlag ( flags . keyFormat ) ,
895
901
de3vMode : self . configManager . getFlag ( flags . devMode ) ,
896
902
curDate : new Date ( )
897
903
}
898
904
899
- // compute other config parameters
900
- // TODO DRY
901
- self . logger . debug ( `[cacheDir=${ config . cacheDir } ]` )
902
- config . releasePrefix = Templates . prepareReleasePrefix ( config . releaseTag )
903
- config . buildZipFile = `${ config . cacheDir } /${ config . releasePrefix } /build-${ config . releaseTag } .zip`
904
- config . keysDir = path . join ( config . cacheDir , 'keys' )
905
- config . stagingDir = Templates . renderStagingDir ( self . configManager , flags )
906
- config . stagingKeysDir = path . join ( config . stagingDir , 'keys' )
907
-
908
- if ( ! await this . k8 . hasNamespace ( config . namespace ) ) {
909
- throw new FullstackTestingError ( `namespace ${ config . namespace } does not exist` )
910
- }
911
-
912
- // prepare staging keys directory
913
- if ( ! fs . existsSync ( config . stagingKeysDir ) ) {
914
- fs . mkdirSync ( config . stagingKeysDir , { recursive : true } )
915
- }
916
-
917
- // create cached keys dir if it does not exist yet
918
- if ( ! fs . existsSync ( config . keysDir ) ) {
919
- fs . mkdirSync ( config . keysDir )
920
- }
905
+ await self . initializeSetup ( config , self . configManager , self . k8 )
921
906
922
907
// set config in the context for later tasks to use
923
908
ctx . config = config
@@ -952,32 +937,14 @@ export class NodeCommand extends BaseCommand {
952
937
} )
953
938
}
954
939
} ,
955
- { // TODO DRY
940
+ {
956
941
title : 'Fetch platform software into network nodes' ,
957
942
task :
958
943
async ( ctx , task ) => {
959
- const config = ctx . config
960
-
961
- const subTasks = [ ]
962
- for ( const nodeId of ctx . config . nodeIds ) {
963
- const podName = ctx . config . podNames [ nodeId ]
964
- subTasks . push ( {
965
- title : `Node: ${ chalk . yellow ( nodeId ) } ` ,
966
- task : ( ) =>
967
- self . plaformInstaller . fetchPlatform ( podName , config . releaseTag )
968
- } )
969
- }
970
-
971
- // set up the sub-tasks
972
- return task . newListr ( subTasks , {
973
- concurrent : true , // since we download in the container directly, we want this to be in parallel across all nodes
974
- rendererOptions : {
975
- collapseSubtasks : false
976
- }
977
- } )
944
+ return self . fetchPlatformSoftware ( ctx , task , self . platformInstaller )
978
945
}
979
946
} ,
980
- { // TODO DRY
947
+ {
981
948
title : 'Setup network nodes' ,
982
949
task : async ( ctx , parentTask ) => {
983
950
const config = ctx . config
@@ -993,7 +960,7 @@ export class NodeCommand extends BaseCommand {
993
960
subTasks . push ( {
994
961
title : `Node: ${ chalk . yellow ( nodeId ) } ` ,
995
962
task : ( ) =>
996
- self . plaformInstaller . taskInstall ( podName , config . buildZipFile ,
963
+ self . platformInstaller . taskInstall ( podName , config . buildZipFile ,
997
964
config . stagingDir , nodeList , config . keyFormat , config . force )
998
965
} )
999
966
}
@@ -1218,7 +1185,6 @@ export class NodeCommand extends BaseCommand {
1218
1185
flags . nodeIDs ,
1219
1186
flags . releaseTag ,
1220
1187
flags . cacheDir ,
1221
- flags . chainId ,
1222
1188
flags . applicationEnv ,
1223
1189
flags . keyFormat
1224
1190
) ,
0 commit comments