@@ -349,7 +349,18 @@ async function getRecommendedKubeNamespace(kubeconfigPath, kubeContextName) {
349349 return name ;
350350}
351351
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' ) ;
353364 const downloader = new Downloader ( {
354365 progress : new cliProgress . SingleBar (
355366 {
@@ -360,76 +371,66 @@ async function downloadVeonona(location = CODEFRESH_PATH) {
360371 ) ,
361372 location,
362373 } ) ;
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 ) ;
364384 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 ) ) {
368386 return path . resolve ( process . cwd ( ) , INSTALLATION_DEFAULTS . COMPONENTS_FOLDER ) ;
369387 }
370- console . log ( 'Failed to download component, aborting' ) ;
388+
389+ console . log ( 'Failed to find component, aborting' ) ;
371390 throw error ;
372391 }
392+
373393 return location ;
374394}
375395
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 ] ) ;
388402 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 ) ) {
393404 return path . resolve ( process . cwd ( ) , INSTALLATION_DEFAULTS . COMPONENTS_FOLDER ) ;
394405 }
395- console . log ( 'Failed to download component, aborting' ) ;
406+
407+ console . log ( 'Failed to find component, aborting' ) ;
396408 throw error ;
397409 }
398410 return location ;
399411}
400412
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 ) ;
413419 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 ) ) {
421421 return path . resolve ( process . cwd ( ) , INSTALLATION_DEFAULTS . COMPONENTS_FOLDER ) ;
422422 }
423- console . log ( 'Failed to download component, aborting' ) ;
423+
424+ console . log ( 'Failed to find component, aborting' ) ;
424425 throw error ;
425426 }
426427 return location ;
427428}
428429
429- async function downloadHybridComponents ( location ) {
430- await downloadVeonona ( location ) ;
430+ async function downloadHybridComponents ( location , bypassDownload = false ) {
431+ await downloadVeonona ( location , bypassDownload ) ;
431432 console . log ( `Kubernetes components installer downloaded successfully to ${ location } ` ) ;
432- await downloadSteveDore ( location ) ;
433+ await downloadSteveDore ( location , bypassDownload ) ;
433434 console . log ( `Kubernetes registrator installer downloaded successfully ${ location } ` ) ;
434435}
435436
@@ -444,8 +445,9 @@ async function runClusterAcceptanceTests({
444445 valuesFile, // --values
445446 setValue, // --set-value
446447 setFile, // --set-file
448+ bypassDownload, // --bypass-download
447449} ) {
448- const binLocation = await downloadVeonona ( ) ;
450+ const binLocation = await downloadVeonona ( undefined , bypassDownload ) ;
449451 const componentRunner = new Runner ( binLocation ) ;
450452 const cmd = [ 'test' , '--log-formtter' , DefaultLogFormatter ] ;
451453 if ( apiHost ) {
@@ -491,7 +493,7 @@ async function runClusterAcceptanceTests({
491493}
492494
493495async function runUpgrade ( { kubeNamespace, kubeContextName } ) {
494- const binLocation = await downloadVeonona ( ) ;
496+ const binLocation = await downloadVeonona ( undefined , bypassDownload ) ;
495497 const componentRunner = new Runner ( binLocation ) ;
496498 const cmd = [ 'upgrade' , '--log-formtter' , DefaultLogFormatter ] ;
497499 if ( kubeNamespace ) {
@@ -514,6 +516,7 @@ async function installAgent({
514516 token, // --agentToken
515517 kubeNodeSelector, // --kube-node-selector
516518 dryRun, // --dryRun
519+ bypassDownload, // --bypass-download
517520 inCluster, // -inCluster
518521 tolerations, // --tolerations
519522 venonaVersion, // --venona-version
@@ -526,7 +529,7 @@ async function installAgent({
526529 setValue, // --set-value
527530 setFile, // --set-file
528531} ) {
529- const binLocation = await downloadVeonona ( ) ;
532+ const binLocation = await downloadVeonona ( undefined , bypassDownload ) ;
530533 const componentRunner = new Runner ( binLocation ) ;
531534 const cmd = [
532535 'install' ,
@@ -557,6 +560,11 @@ async function installAgent({
557560 if ( dryRun ) {
558561 cmd . push ( '--dry-run' ) ;
559562 }
563+
564+ if ( bypassDownload ) {
565+ cmd . push ( `--bypass-download=${ bypassDownload } ` ) ;
566+ }
567+
560568 if ( inCluster ) {
561569 cmd . push ( '--in-cluster' ) ;
562570 }
@@ -600,6 +608,7 @@ async function installRuntime({
600608 kubeNamespace, // --kube-namespace
601609 dockerRegistry, // --docker-registry
602610 dryRun, // --dryRun
611+ bypassDownload, // --bypass-download
603612 inCluster, // -inCluster
604613 kubeConfigPath, // --kube-config-path
605614 verbose, // --verbose
@@ -612,7 +621,7 @@ async function installRuntime({
612621 storageClassName, // --storage-class
613622 logFormatting = DefaultLogFormatter , // --log-formtter
614623} ) {
615- const binLocation = await downloadVeonona ( ) ;
624+ const binLocation = await downloadVeonona ( undefined , bypassDownload ) ;
616625 const componentRunner = new Runner ( binLocation ) ;
617626 const cmd = [
618627 'install' ,
@@ -693,7 +702,7 @@ async function installAppProxy({
693702 envVars, // --envVars
694703 dryRun, // --dry-run
695704} ) {
696- const binLocation = await downloadVeonona ( ) ;
705+ const binLocation = await downloadVeonona ( undefined , bypassDownload ) ;
697706 const componentRunner = new Runner ( binLocation ) ;
698707 const cmd = [
699708 'install' ,
@@ -764,7 +773,7 @@ async function unInstallAppProxy({
764773 valuesFile, // --values
765774 setValue, // --set-value
766775} ) {
767- const binLocation = await downloadVeonona ( ) ;
776+ const binLocation = await downloadVeonona ( undefined , bypassDownload ) ;
768777 const componentRunner = new Runner ( binLocation ) ;
769778 const cmd = [
770779 'uninstall' ,
@@ -805,7 +814,7 @@ async function upgradeAppProxy({
805814 valuesFile, // --values
806815 setValue, // --set-value
807816} ) {
808- const binLocation = await downloadVeonona ( ) ;
817+ const binLocation = await downloadVeonona ( undefined , bypassDownload ) ;
809818 const componentRunner = new Runner ( binLocation ) ;
810819 const cmd = [
811820 'upgrade' ,
@@ -853,8 +862,9 @@ async function attachRuntime({
853862 setValue, // --set-value
854863 setFile, // --set-file
855864 dryRun,
865+ bypassDownload,
856866} ) {
857- const binLocation = await downloadVeonona ( ) ;
867+ const binLocation = await downloadVeonona ( undefined , bypassDownload ) ;
858868 const componentRunner = new Runner ( binLocation ) ;
859869 const cmd = [
860870 'attach' ,
0 commit comments