Skip to content

Commit

Permalink
CR-4248 (#647)
Browse files Browse the repository at this point in the history
* bump

* for cr

* after cr

* for approval

* without resolveDemoStepImage function

* without resolveDemoStepImage function

* fixed parameter
  • Loading branch information
elad-codefresh authored Apr 20, 2021
1 parent 97ec4ee commit 9cffb3d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
21 changes: 17 additions & 4 deletions lib/interface/cli/commands/hybrid/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ const RUNTIME_IMAGES = {
PIPELINE_DEBUGGER_IMAGE: 'codefresh/cf-debugger:1.1.2',
};

const DEMO_STEP_IMAGE = {
'docker.io': 'alpine:latest',
'quay.io': 'quay.io/codefresh/alpine:3.11',
'gcr.io': 'gcr.io/google-containers/alpine-with-bash',
default: 'quay.io/codefresh/alpine:3.11'
}

const maxRuntimeNameLength = 63;
const DefaultLogFormatter = 'plain';

Expand Down Expand Up @@ -86,7 +93,7 @@ async function getTestPipelineLink(pipelineName, pipeline) {
return '';
}

async function createTestPipeline(runtimeName, pipelineName, pipelineCommands) {
async function createTestPipeline(runtimeName, pipelineName, pipelineCommands, dockerRegistry) {
await _createRunnerProjectIfNotExists();
console.log(`Creating test pipeline with the name: "${colors.cyan(pipelineName)}" ` +
`in project "${colors.cyan(INSTALLATION_DEFAULTS.PROJECT_NAME)}"`);
Expand All @@ -95,12 +102,15 @@ async function createTestPipeline(runtimeName, pipelineName, pipelineCommands) {
pipeline.spec.runtimeEnvironment = {
name: runtimeName,
};

const demoStepImage = DEMO_STEP_IMAGE[dockerRegistry] || DEMO_STEP_IMAGE.default;

pipeline.spec.steps = {};
pipeline.spec.stages = ['test'];
pipeline.spec.steps.test = {
stage: 'test',
title: 'test',
image: 'alpine:latest',
image: demoStepImage,
commands: pipelineCommands || ['echo hello Codefresh Runner!'],
};

Expand Down Expand Up @@ -130,11 +140,10 @@ async function getTestPipeline(pipelineName) {
return pipeline;
}


return null;
}

async function updateTestPipelineRuntime(pipeline, runtimeName, pipelineName) {
async function updateTestPipelineRuntime(pipeline, runtimeName, pipelineName, dockerRegistry) {
let _pipeline = pipeline;
if (!_pipeline) {
const testPipeline = await getTestPipeline(pipelineName);
Expand All @@ -147,6 +156,10 @@ async function updateTestPipelineRuntime(pipeline, runtimeName, pipelineName) {
name: runtimeName,
};

let demoStepImage = DEMO_STEP_IMAGE[dockerRegistry] || DEMO_STEP_IMAGE.default;

_pipeline.spec.steps.test.image = demoStepImage;

await sdk.pipelines.replace(
{ name: _pipeline.metadata.name },
{
Expand Down
6 changes: 4 additions & 2 deletions lib/interface/cli/commands/hybrid/init.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -843,18 +843,20 @@ const initCmd = new Command({
installationPlan.getContext('runtimeName'),
INSTALLATION_DEFAULTS.DEMO_PIPELINE_NAME,
['echo hello Codefresh Runner!'],
dockerRegistry
);
},
installationEvent: installationProgress.events.PIPELINE_CREATED,
});
} else {
installationPlan.addStep({
installationPlan.addStep({
name: 'update test pipeline runtime',
func: async () => {
await updateTestPipelineRuntime(
await updateTestPipelineRuntime(
undefined,
installationPlan.getContext('runtimeName'),
INSTALLATION_DEFAULTS.DEMO_PIPELINE_NAME,
dockerRegistry
);
},
errMessage: colors.yellow('*warning* could not update test pipeline runtime, you can' +
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codefresh",
"version": "0.75.10",
"version": "0.75.11",
"description": "Codefresh command line utility",
"main": "index.js",
"preferGlobal": true,
Expand Down

0 comments on commit 9cffb3d

Please sign in to comment.