@@ -19,9 +19,6 @@ const installationProgress = require('./installation-process');
19
19
const { to } = require ( './../../../../logic/cli-config/errors/awaitTo' ) ;
20
20
const {
21
21
createErrorHandler,
22
- createTestPipeline,
23
- executeTestPipeline,
24
- updateTestPipelineRuntime,
25
22
drawCodefreshFiglet,
26
23
getDefaultRuntime,
27
24
getRecommendedKubeNamespace,
@@ -40,6 +37,9 @@ const {
40
37
const InstallationPlan = require ( './InstallationPlan' ) ;
41
38
const { produceVenonaKeys } = require ( './key-helper' ) ;
42
39
const { array } = require ( 'yargs' ) ;
40
+ const {
41
+ addPipelineToInstallationPlan,
42
+ } = require ( './pipeline-helper' ) ;
43
43
44
44
const defaultDockerRegistry = 'quay.io' ;
45
45
const 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({
318
318
httpsProxy = httpsProxy || detectedProxyVars . httpsProxy ;
319
319
noProxy = noProxy || detectedProxyVars . noProxy ;
320
320
321
- if ( shouldUseHelm ) {
322
- shouldExecutePipeline = false ;
323
- }
324
-
325
321
if ( noQuestions ) {
326
322
// use defaults
327
323
kubeContextName = kubeContextName || getKubeContext ( kubeConfigPath ) ;
@@ -415,7 +411,7 @@ const initCmd = new Command({
415
411
type : 'confirm' ,
416
412
name : 'shouldExecutePipeline' ,
417
413
default : INSTALLATION_DEFAULTS . RUN_DEMO_PIPELINE ,
418
- message : 'Run demo pipeline after install?' ,
414
+ message : shouldUseHelm ? 'Create demo pipeline?' : 'Run demo pipeline after install?' ,
419
415
} ) ;
420
416
}
421
417
@@ -503,7 +499,7 @@ const initCmd = new Command({
503
499
bypassDownload,
504
500
} ,
505
501
installationEvent : installationProgress . events . ACCEPTANCE_TESTS_RAN ,
506
- condition : ! skipClusterTest ,
502
+ condition : ! skipClusterTest && ! shouldUseHelm ,
507
503
} ) ;
508
504
509
505
// generate new agent name
@@ -834,6 +830,20 @@ const initCmd = new Command({
834
830
condition : ! shouldUseHelm ,
835
831
} ) ;
836
832
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
+
837
847
// install monitoring
838
848
installationPlan . addStep ( {
839
849
name : 'install cluster monitoring' ,
@@ -858,22 +868,7 @@ const initCmd = new Command({
858
868
successMessage : 'Successfully installed cluster monitoring' ,
859
869
installationEvent : installationProgress . events . MONITOR_INSTALLED ,
860
870
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 ,
877
872
} ) ;
878
873
879
874
// helm value files if its enabled
@@ -888,6 +883,16 @@ const initCmd = new Command({
888
883
kubeNamespace ,
889
884
) ;
890
885
886
+ const _appProxy = {
887
+ enabled : appProxy || false ,
888
+ host : appProxyHost || '' ,
889
+ } ;
890
+
891
+ const monitor = {
892
+ enabled : shouldInstallMonitoringFn ( ) ,
893
+ clusterId : kubeContextName ,
894
+ } ;
895
+
891
896
const global = {
892
897
namespace : kubeNamespace ,
893
898
codefreshHost : sdk . config . context . url ,
@@ -899,7 +904,7 @@ const initCmd = new Command({
899
904
keys,
900
905
} ;
901
906
902
- const content = JSON . stringify ( { global } , null , 4 ) ;
907
+ const content = JSON . stringify ( { appProxy : _appProxy , monitor , global } , null , 4 ) ;
903
908
904
909
fs . writeFileSync (
905
910
helmValuesFile ,
@@ -914,51 +919,7 @@ const initCmd = new Command({
914
919
915
920
// Post Installation
916
921
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 ) ;
962
923
}
963
924
964
925
await installationPlan . execute ( ) ;
@@ -972,11 +933,22 @@ const initCmd = new Command({
972
933
if ( installMonitor ) {
973
934
console . log ( `Go to ${ colors . blue ( 'https://g.codefresh.io/kubernetes/services/' ) } to view your cluster in Codefresh dashbaord` ) ;
974
935
}
936
+
975
937
console . log ( `Link to the new runtime: ${ colors . blue ( `https://g.codefresh.io/account-admin/account-conf/runtime-environments?runtime=${ encodeURI ( installationPlan . getContext ( 'runtimeName' ) ) } ` ) } ` ) ;
976
938
console . log ( `\nDocumentation link: ${ colors . blue ( 'https://codefresh.io/docs/docs/enterprise/codefresh-runner/#codefresh-runner-preview-release' ) } ` ) ;
977
939
console . log ( `If you had any issues with the installation please report them at: ${ colors . blue ( 'https://github.com/codefresh-io/cli/issues/new' ) } ` ) ;
978
940
await to ( progressReporter . report ( installationProgress . events . FINISHED , installationProgress . status . SUCCESS ) ) ;
979
941
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
+
980
952
process . exit ( ) ; // TODO : This is not needed - needed to be fixed
981
953
} ,
982
954
} ) ;
0 commit comments