Skip to content

Commit efb66d9

Browse files
Saas-7259 fixed demo pipeline runtime not changing if it already exists (#473)
1 parent 5a9b3d4 commit efb66d9

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

lib/interface/cli/commands/hybrid/init.cmd.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,34 @@ async function createDemoPipeline(runtimeName, progressReporter) {
6565
}
6666

6767
async function createAndExecuteDemoPipeline(runtimeName, progressReporter) {
68-
let demoPipelineExists = false;
68+
let demoPipeline;
6969

7070
const [getPipelinesError, pipelines] = await to(sdk.pipelines.list({ id: INSTALLATION_DEFAULTS.DEMO_PIPELINE_NAME }));
7171
if (getPipelinesError) {
7272
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]');
7575
}
7676

77-
if (!demoPipelineExists) {
77+
if (!demoPipeline) {
7878
console.log(`Creating demo pipeline with the name: "${colors.cyan(INSTALLATION_DEFAULTS.DEMO_PIPELINE_NAME)}"`);
7979
const [createDemoPipelineError] = await to(createDemoPipeline(runtimeName, progressReporter));
8080
await handleError(createDemoPipelineError, 'Failed to create demo pipeline', progressReporter, installationProgress.events.PIPELINE_CREATED);
8181
} else {
8282
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+
}
8396
}
8497

8598
console.log(`${colors.yellow('*NOTE* Running a pipeline for the first time might take longer than usual.')}`);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codefresh",
3-
"version": "0.64.0",
3+
"version": "0.64.2",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)