@@ -19,9 +19,6 @@ const installationProgress = require('./installation-process');
1919const { to } = require ( './../../../../logic/cli-config/errors/awaitTo' ) ;
2020const {
2121 createErrorHandler,
22- createTestPipeline,
23- executeTestPipeline,
24- updateTestPipelineRuntime,
2522 drawCodefreshFiglet,
2623 getDefaultRuntime,
2724 getRecommendedKubeNamespace,
@@ -40,6 +37,9 @@ const {
4037const InstallationPlan = require ( './InstallationPlan' ) ;
4138const { produceVenonaKeys } = require ( './key-helper' ) ;
4239const { array } = require ( 'yargs' ) ;
40+ const {
41+ addPipelineToInstallationPlan,
42+ } = require ( './pipeline-helper' ) ;
4343
4444const defaultDockerRegistry = 'quay.io' ;
4545const handleError = createErrorHandler ( `\nIf you had any issues with the installation please report them at: ${ colors . blue ( 'https://github.com/codefresh-io/cli/issues/new' ) } ` ) ;
@@ -318,10 +318,6 @@ const initCmd = new Command({
318318 httpsProxy = httpsProxy || detectedProxyVars . httpsProxy ;
319319 noProxy = noProxy || detectedProxyVars . noProxy ;
320320
321- if ( shouldUseHelm ) {
322- shouldExecutePipeline = false ;
323- }
324-
325321 if ( noQuestions ) {
326322 // use defaults
327323 kubeContextName = kubeContextName || getKubeContext ( kubeConfigPath ) ;
@@ -415,7 +411,7 @@ const initCmd = new Command({
415411 type : 'confirm' ,
416412 name : 'shouldExecutePipeline' ,
417413 default : INSTALLATION_DEFAULTS . RUN_DEMO_PIPELINE ,
418- message : 'Run demo pipeline after install?' ,
414+ message : shouldUseHelm ? 'Create demo pipeline?' : 'Run demo pipeline after install?' ,
419415 } ) ;
420416 }
421417
@@ -503,7 +499,7 @@ const initCmd = new Command({
503499 bypassDownload,
504500 } ,
505501 installationEvent : installationProgress . events . ACCEPTANCE_TESTS_RAN ,
506- condition : ! skipClusterTest ,
502+ condition : ! skipClusterTest && ! shouldUseHelm ,
507503 } ) ;
508504
509505 // generate new agent name
@@ -834,6 +830,20 @@ const initCmd = new Command({
834830 condition : ! shouldUseHelm ,
835831 } ) ;
836832
833+
834+ function shouldInstallMonitoringFn ( ) {
835+ if ( ! installMonitor ) {
836+ return false ;
837+ }
838+
839+ if ( isInCluster ( ) || skipClusterIntegration ) {
840+ console . log ( 'Monitor component cannot be installed without cluster integration, you can install it seperately using: "codefresh install monitor"' ) ;
841+ return false ;
842+ }
843+
844+ return true ;
845+ }
846+
837847 // install monitoring
838848 installationPlan . addStep ( {
839849 name : 'install cluster monitoring' ,
@@ -858,22 +868,7 @@ const initCmd = new Command({
858868 successMessage : 'Successfully installed cluster monitoring' ,
859869 installationEvent : installationProgress . events . MONITOR_INSTALLED ,
860870 executeOnDryRun : true ,
861- condition : async ( ) => {
862- if ( shouldUseHelm ) {
863- return false ;
864- }
865-
866- if ( ! installMonitor ) {
867- return false ;
868- }
869-
870- if ( isInCluster ( ) || skipClusterIntegration ) {
871- console . log ( 'Monitor component cannot be installed without cluster integration, you can install it seperately using: "codefresh install monitor"' ) ;
872- return false ;
873- }
874-
875- return true ;
876- } ,
871+ condition : ! shouldUseHelm && shouldInstallMonitoringFn ,
877872 } ) ;
878873
879874 // helm value files if its enabled
@@ -888,6 +883,16 @@ const initCmd = new Command({
888883 kubeNamespace ,
889884 ) ;
890885
886+ const _appProxy = {
887+ enabled : appProxy || false ,
888+ host : appProxyHost || '' ,
889+ } ;
890+
891+ const monitor = {
892+ enabled : shouldInstallMonitoringFn ( ) ,
893+ clusterId : kubeContextName ,
894+ } ;
895+
891896 const global = {
892897 namespace : kubeNamespace ,
893898 codefreshHost : sdk . config . context . url ,
@@ -899,7 +904,7 @@ const initCmd = new Command({
899904 keys,
900905 } ;
901906
902- const content = JSON . stringify ( { global } , null , 4 ) ;
907+ const content = JSON . stringify ( { appProxy : _appProxy , monitor , global } , null , 4 ) ;
903908
904909 fs . writeFileSync (
905910 helmValuesFile ,
@@ -914,51 +919,7 @@ const initCmd = new Command({
914919
915920 // Post Installation
916921 if ( shouldExecutePipeline ) {
917- const pipelines = await sdk . pipelines . list ( { id : `${ INSTALLATION_DEFAULTS . PROJECT_NAME } /${ INSTALLATION_DEFAULTS . DEMO_PIPELINE_NAME } ` } ) ;
918- const testPipelineExists = ! ! _ . get ( pipelines , 'docs.length' ) ;
919-
920- if ( ! testPipelineExists ) {
921- installationPlan . addStep ( {
922- name : 'create test pipeline' ,
923- func : async ( ) => {
924- await createTestPipeline (
925- installationPlan . getContext ( 'runtimeName' ) ,
926- INSTALLATION_DEFAULTS . DEMO_PIPELINE_NAME ,
927- [ 'echo hello Codefresh Runner!' ] ,
928- dockerRegistry ,
929- ) ;
930- } ,
931- installationEvent : installationProgress . events . PIPELINE_CREATED ,
932- } ) ;
933- } else {
934- installationPlan . addStep ( {
935- name : 'update test pipeline runtime' ,
936- func : async ( ) => {
937- await updateTestPipelineRuntime (
938- undefined ,
939- installationPlan . getContext ( 'runtimeName' ) ,
940- INSTALLATION_DEFAULTS . DEMO_PIPELINE_NAME ,
941- dockerRegistry ,
942- ) ;
943- } ,
944- errMessage : colors . yellow ( '*warning* could not update test pipeline runtime, you can' +
945- ' change it manually if you want to run it again on this runtime' ) ,
946- successMessage : 'Updated test pipeline runtime' ,
947- exitOnError : false ,
948- } ) ;
949- }
950-
951- installationPlan . addStep ( {
952- name : 'execute test pipeline' ,
953- func : async ( ) => {
954- await executeTestPipeline (
955- installationPlan . getContext ( 'runtimeName' ) ,
956- INSTALLATION_DEFAULTS . DEMO_PIPELINE_NAME ,
957- ) ;
958- } ,
959- errMessage : 'Failed to execute test pipeline' ,
960- installationEvent : installationProgress . events . PIPELINE_EXECUTED ,
961- } ) ;
922+ await addPipelineToInstallationPlan ( installationPlan , dockerRegistry , ! shouldUseHelm ) ;
962923 }
963924
964925 await installationPlan . execute ( ) ;
@@ -972,11 +933,22 @@ const initCmd = new Command({
972933 if ( installMonitor ) {
973934 console . log ( `Go to ${ colors . blue ( 'https://g.codefresh.io/kubernetes/services/' ) } to view your cluster in Codefresh dashbaord` ) ;
974935 }
936+
975937 console . log ( `Link to the new runtime: ${ colors . blue ( `https://g.codefresh.io/account-admin/account-conf/runtime-environments?runtime=${ encodeURI ( installationPlan . getContext ( 'runtimeName' ) ) } ` ) } ` ) ;
976938 console . log ( `\nDocumentation link: ${ colors . blue ( 'https://codefresh.io/docs/docs/enterprise/codefresh-runner/#codefresh-runner-preview-release' ) } ` ) ;
977939 console . log ( `If you had any issues with the installation please report them at: ${ colors . blue ( 'https://github.com/codefresh-io/cli/issues/new' ) } ` ) ;
978940 await to ( progressReporter . report ( installationProgress . events . FINISHED , installationProgress . status . SUCCESS ) ) ;
979941 await drawCodefreshFiglet ( ) ;
942+
943+ if ( shouldUseHelm ) {
944+ console . log ( '\n\nTo install helm run:' ) ;
945+ console . log ( 'helm repo add cf-runtime https://h.cfcr.io/codefresh-inc/runtime' ) ;
946+ console . log ( `kubectl create ns ${ kubeNamespace } ` ) ;
947+ console . log ( `helm install cf-runtime cf-runtime/cf-runtime -f ${ helmValuesFile } --namespace ${ kubeNamespace } \n` ) ;
948+ console . log ( 'In order to test your runner helm based installation please execute\n' +
949+ 'codefresh runner execute-test-pipeline' ) ;
950+ }
951+
980952 process . exit ( ) ; // TODO : This is not needed - needed to be fixed
981953 } ,
982954} ) ;
0 commit comments