@@ -65,21 +65,34 @@ async function createDemoPipeline(runtimeName, progressReporter) {
65
65
}
66
66
67
67
async function createAndExecuteDemoPipeline ( runtimeName , progressReporter ) {
68
- let demoPipelineExists = false ;
68
+ let demoPipeline ;
69
69
70
70
const [ getPipelinesError , pipelines ] = await to ( sdk . pipelines . list ( { id : INSTALLATION_DEFAULTS . DEMO_PIPELINE_NAME } ) ) ;
71
71
if ( getPipelinesError ) {
72
72
console . log ( `Failed to fetch account pipelines, cause: ${ getPipelinesError . message } ` ) ;
73
- } else if ( _ . get ( pipelines , 'docs.length' ) ) {
74
- demoPipelineExists = true ;
73
+ } else {
74
+ demoPipeline = _ . get ( pipelines , 'docs[0]' ) ;
75
75
}
76
76
77
- if ( ! demoPipelineExists ) {
77
+ if ( ! demoPipeline ) {
78
78
console . log ( `Creating demo pipeline with the name: "${ colors . cyan ( INSTALLATION_DEFAULTS . DEMO_PIPELINE_NAME ) } "` ) ;
79
79
const [ createDemoPipelineError ] = await to ( createDemoPipeline ( runtimeName , progressReporter ) ) ;
80
80
await handleError ( createDemoPipelineError , 'Failed to create demo pipeline' , progressReporter , installationProgress . events . PIPELINE_CREATED ) ;
81
81
} else {
82
82
console . log ( `Demo pipeline with the name: "${ colors . cyan ( INSTALLATION_DEFAULTS . DEMO_PIPELINE_NAME ) } " already exists` ) ;
83
+ _ . set ( demoPipeline , 'spec.runtimeEnvironment' , { name : runtimeName } ) ;
84
+ const [ updatePipelineErr ] = await to ( sdk . pipelines . replace (
85
+ { name : INSTALLATION_DEFAULTS . DEMO_PIPELINE_NAME } ,
86
+ {
87
+ kind : demoPipeline . kind ,
88
+ spec : demoPipeline . spec ,
89
+ metadata : demoPipeline . metadata ,
90
+ version : demoPipeline . version ,
91
+ } ,
92
+ ) ) ;
93
+ if ( updatePipelineErr ) {
94
+ console . log ( `${ colors . red ( 'Error:' ) } failed to update demo pipeline's runtime: ${ prettyError ( updatePipelineErr ) } ` ) ;
95
+ }
83
96
}
84
97
85
98
console . log ( `${ colors . yellow ( '*NOTE* Running a pipeline for the first time might take longer than usual.' ) } ` ) ;
0 commit comments