@@ -349,7 +349,18 @@ async function getRecommendedKubeNamespace(kubeconfigPath, kubeContextName) {
349
349
return name ;
350
350
}
351
351
352
- async function downloadVeonona ( location = CODEFRESH_PATH ) {
352
+ async function bypassDownloadSuccess ( shouldBypass , localDir , localBin ) {
353
+ if ( shouldBypass ) {
354
+ const newLocation = path . join ( process . cwd ( ) , INSTALLATION_DEFAULTS . COMPONENTS_FOLDER , localDir , localBin ) ;
355
+ if ( await pathExists ( newLocation ) ) {
356
+ return true ;
357
+ }
358
+ }
359
+ return false ;
360
+ }
361
+
362
+ async function attemptDownload ( location , component ) {
363
+ console . log ( 'Downloading installer' ) ;
353
364
const downloader = new Downloader ( {
354
365
progress : new cliProgress . SingleBar (
355
366
{
@@ -360,76 +371,66 @@ async function downloadVeonona(location = CODEFRESH_PATH) {
360
371
) ,
361
372
location,
362
373
} ) ;
363
- const [ error ] = await to ( downloader . download ( components . venona ) ) ;
374
+
375
+ return await to ( downloader . download ( component ) ) ;
376
+ }
377
+
378
+ async function downloadVeonona ( location = CODEFRESH_PATH , bypassDownload = false ) {
379
+ if ( await bypassDownloadSuccess ( bypassDownload , components . venona . local . dir , components . venona . local . binary ) ) {
380
+ return path . resolve ( process . cwd ( ) , INSTALLATION_DEFAULTS . COMPONENTS_FOLDER ) ;
381
+ }
382
+
383
+ const [ error ] = await attemptDownload ( location , components . venona ) ;
364
384
if ( error ) {
365
- const newLocation = path . join ( process . cwd ( ) , INSTALLATION_DEFAULTS . COMPONENTS_FOLDER , components . venona . local . dir , components . venona . local . binary ) ;
366
- if ( await pathExists ( newLocation ) ) {
367
- console . log ( 'Failed to download installer, using binary from components folder' ) ;
385
+ if ( await bypassDownloadSuccess ( ! bypassDownload , components . venona . local . dir , components . venona . local . binary ) ) {
368
386
return path . resolve ( process . cwd ( ) , INSTALLATION_DEFAULTS . COMPONENTS_FOLDER ) ;
369
387
}
370
- console . log ( 'Failed to download component, aborting' ) ;
388
+
389
+ console . log ( 'Failed to find component, aborting' ) ;
371
390
throw error ;
372
391
}
392
+
373
393
return location ;
374
394
}
375
395
376
- async function downloadProvider ( { provider, location = CODEFRESH_PATH } ) {
377
- const downloader = new Downloader ( {
378
- progress : new cliProgress . SingleBar (
379
- {
380
- stopOnComplete : true ,
381
- format : CommonProgressFormat ,
382
- } ,
383
- cliProgress . Presets . shades_classic ,
384
- ) ,
385
- location,
386
- } ) ;
387
- const [ error ] = await to ( downloader . download ( components . gitops [ provider ] ) ) ;
396
+ async function downloadProvider ( { provider, location = CODEFRESH_PATH } , bypassDownload = false ) {
397
+ if ( await bypassDownloadSuccess ( bypassDownload , localSettings . dir , localSettings . binary ) ) {
398
+ return path . resolve ( process . cwd ( ) , INSTALLATION_DEFAULTS . COMPONENTS_FOLDER ) ;
399
+ }
400
+
401
+ const [ error ] = await attemptDownload ( location , components . gitops [ provider ] ) ;
388
402
if ( error ) {
389
- const localSettings = components . gitops [ provider ] . local ;
390
- const newLocation = path . join ( process . cwd ( ) , INSTALLATION_DEFAULTS . COMPONENTS_FOLDER , localSettings . dir , localSettings . binary ) ;
391
- if ( await pathExists ( newLocation ) ) {
392
- console . log ( 'Failed to download installer, using binary from components folder' ) ;
403
+ if ( await bypassDownloadSuccess ( ! bypassDownload , localSettings . dir , localSettings . binary ) ) {
393
404
return path . resolve ( process . cwd ( ) , INSTALLATION_DEFAULTS . COMPONENTS_FOLDER ) ;
394
405
}
395
- console . log ( 'Failed to download component, aborting' ) ;
406
+
407
+ console . log ( 'Failed to find component, aborting' ) ;
396
408
throw error ;
397
409
}
398
410
return location ;
399
411
}
400
412
401
- async function downloadSteveDore ( location = CODEFRESH_PATH ) {
402
- const downloader = new Downloader ( {
403
- progress : new cliProgress . SingleBar (
404
- {
405
- stopOnComplete : true ,
406
- format : CommonProgressFormat ,
407
- } ,
408
- cliProgress . Presets . shades_classic ,
409
- ) ,
410
- location,
411
- } ) ;
412
- const [ error ] = await to ( downloader . download ( components . stevedore ) ) ;
413
+ async function downloadSteveDore ( location = CODEFRESH_PATH , bypassDownload = false ) {
414
+ if ( await bypassDownloadSuccess ( bypassDownload , components . stevedore . local . dir , components . stevedore . local . binary ) ) {
415
+ return path . resolve ( process . cwd ( ) , INSTALLATION_DEFAULTS . COMPONENTS_FOLDER ) ;
416
+ }
417
+
418
+ const [ error ] = await attemptDownload ( location , components . stevedore ) ;
413
419
if ( error ) {
414
- const newLocation = path . join (
415
- process . cwd ( ) ,
416
- INSTALLATION_DEFAULTS . COMPONENTS_FOLDER ,
417
- components . stevedore . local . dir , components . stevedore . local . binary ,
418
- ) ;
419
- if ( await pathExists ( newLocation ) ) {
420
- console . log ( 'Failed to download installer, using binary from components folder' ) ;
420
+ if ( await bypassDownloadSuccess ( ! bypassDownload , components . stevedore . local . dir , components . stevedore . local . binary ) ) {
421
421
return path . resolve ( process . cwd ( ) , INSTALLATION_DEFAULTS . COMPONENTS_FOLDER ) ;
422
422
}
423
- console . log ( 'Failed to download component, aborting' ) ;
423
+
424
+ console . log ( 'Failed to find component, aborting' ) ;
424
425
throw error ;
425
426
}
426
427
return location ;
427
428
}
428
429
429
- async function downloadHybridComponents ( location ) {
430
- await downloadVeonona ( location ) ;
430
+ async function downloadHybridComponents ( location , bypassDownload = false ) {
431
+ await downloadVeonona ( location , bypassDownload ) ;
431
432
console . log ( `Kubernetes components installer downloaded successfully to ${ location } ` ) ;
432
- await downloadSteveDore ( location ) ;
433
+ await downloadSteveDore ( location , bypassDownload ) ;
433
434
console . log ( `Kubernetes registrator installer downloaded successfully ${ location } ` ) ;
434
435
}
435
436
@@ -444,8 +445,9 @@ async function runClusterAcceptanceTests({
444
445
valuesFile, // --values
445
446
setValue, // --set-value
446
447
setFile, // --set-file
448
+ bypassDownload, // --bypass-download
447
449
} ) {
448
- const binLocation = await downloadVeonona ( ) ;
450
+ const binLocation = await downloadVeonona ( undefined , bypassDownload ) ;
449
451
const componentRunner = new Runner ( binLocation ) ;
450
452
const cmd = [ 'test' , '--log-formtter' , DefaultLogFormatter ] ;
451
453
if ( apiHost ) {
@@ -491,7 +493,7 @@ async function runClusterAcceptanceTests({
491
493
}
492
494
493
495
async function runUpgrade ( { kubeNamespace, kubeContextName } ) {
494
- const binLocation = await downloadVeonona ( ) ;
496
+ const binLocation = await downloadVeonona ( undefined , bypassDownload ) ;
495
497
const componentRunner = new Runner ( binLocation ) ;
496
498
const cmd = [ 'upgrade' , '--log-formtter' , DefaultLogFormatter ] ;
497
499
if ( kubeNamespace ) {
@@ -514,6 +516,7 @@ async function installAgent({
514
516
token, // --agentToken
515
517
kubeNodeSelector, // --kube-node-selector
516
518
dryRun, // --dryRun
519
+ bypassDownload, // --bypass-download
517
520
inCluster, // -inCluster
518
521
tolerations, // --tolerations
519
522
venonaVersion, // --venona-version
@@ -526,7 +529,7 @@ async function installAgent({
526
529
setValue, // --set-value
527
530
setFile, // --set-file
528
531
} ) {
529
- const binLocation = await downloadVeonona ( ) ;
532
+ const binLocation = await downloadVeonona ( undefined , bypassDownload ) ;
530
533
const componentRunner = new Runner ( binLocation ) ;
531
534
const cmd = [
532
535
'install' ,
@@ -557,6 +560,11 @@ async function installAgent({
557
560
if ( dryRun ) {
558
561
cmd . push ( '--dry-run' ) ;
559
562
}
563
+
564
+ if ( bypassDownload ) {
565
+ cmd . push ( `--bypass-download=${ bypassDownload } ` ) ;
566
+ }
567
+
560
568
if ( inCluster ) {
561
569
cmd . push ( '--in-cluster' ) ;
562
570
}
@@ -600,6 +608,7 @@ async function installRuntime({
600
608
kubeNamespace, // --kube-namespace
601
609
dockerRegistry, // --docker-registry
602
610
dryRun, // --dryRun
611
+ bypassDownload, // --bypass-download
603
612
inCluster, // -inCluster
604
613
kubeConfigPath, // --kube-config-path
605
614
verbose, // --verbose
@@ -612,7 +621,7 @@ async function installRuntime({
612
621
storageClassName, // --storage-class
613
622
logFormatting = DefaultLogFormatter , // --log-formtter
614
623
} ) {
615
- const binLocation = await downloadVeonona ( ) ;
624
+ const binLocation = await downloadVeonona ( undefined , bypassDownload ) ;
616
625
const componentRunner = new Runner ( binLocation ) ;
617
626
const cmd = [
618
627
'install' ,
@@ -693,7 +702,7 @@ async function installAppProxy({
693
702
envVars, // --envVars
694
703
dryRun, // --dry-run
695
704
} ) {
696
- const binLocation = await downloadVeonona ( ) ;
705
+ const binLocation = await downloadVeonona ( undefined , bypassDownload ) ;
697
706
const componentRunner = new Runner ( binLocation ) ;
698
707
const cmd = [
699
708
'install' ,
@@ -764,7 +773,7 @@ async function unInstallAppProxy({
764
773
valuesFile, // --values
765
774
setValue, // --set-value
766
775
} ) {
767
- const binLocation = await downloadVeonona ( ) ;
776
+ const binLocation = await downloadVeonona ( undefined , bypassDownload ) ;
768
777
const componentRunner = new Runner ( binLocation ) ;
769
778
const cmd = [
770
779
'uninstall' ,
@@ -805,7 +814,7 @@ async function upgradeAppProxy({
805
814
valuesFile, // --values
806
815
setValue, // --set-value
807
816
} ) {
808
- const binLocation = await downloadVeonona ( ) ;
817
+ const binLocation = await downloadVeonona ( undefined , bypassDownload ) ;
809
818
const componentRunner = new Runner ( binLocation ) ;
810
819
const cmd = [
811
820
'upgrade' ,
@@ -853,8 +862,9 @@ async function attachRuntime({
853
862
setValue, // --set-value
854
863
setFile, // --set-file
855
864
dryRun,
865
+ bypassDownload,
856
866
} ) {
857
- const binLocation = await downloadVeonona ( ) ;
867
+ const binLocation = await downloadVeonona ( undefined , bypassDownload ) ;
858
868
const componentRunner = new Runner ( binLocation ) ;
859
869
const cmd = [
860
870
'attach' ,
0 commit comments