Skip to content

Commit 29344f7

Browse files
intorduce runner info (#478)
* introduce runner info
1 parent 1b89be4 commit 29344f7

File tree

5 files changed

+49
-8
lines changed

5 files changed

+49
-8
lines changed

lib/interface/cli/commands/agent/get.cmd.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ const { sdk } = require('../../../../logic');
33
const Agent = require('../../../../logic/entities/Agent');
44
const Output = require('../../../../output/Output');
55
const _ = require('lodash');
6+
const colors = require('colors');
67
const { ignoreHttpError } = require('../../helpers/general');
8+
const { getTestPipelineLink, INSTALLATION_DEFAULTS } = require('../hybrid/helper');
79

810
const getRoot = require('../root/get.cmd');
911

@@ -38,6 +40,12 @@ const command = new Command({
3840
});
3941
}
4042
Output.print(_.map(agents, Agent.fromResponse));
43+
const pipelineLink = await getTestPipelineLink(INSTALLATION_DEFAULTS.DEMO_PIPELINE_NAME, false);
44+
if (pipelineLink) {
45+
// eslint-disable-next-line max-len
46+
console.log(`\nTest pipeline with the name: '${colors.cyan(INSTALLATION_DEFAULTS.DEMO_PIPELINE_NAME)}' exists for this account.` +
47+
`\nWatch it here: ${colors.blue(pipelineLink)}`);
48+
}
4149
},
4250
});
4351

lib/interface/cli/commands/hybrid/helper.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ const { followLogs } = require('../../helpers/logs');
1111
const ProgressEvents = require('../../helpers/progressEvents');
1212
const cliProgress = require('cli-progress');
1313

14+
const INSTALLATION_DEFAULTS = {
15+
NAMESPACE: 'codefresh',
16+
MAKE_DEFAULT_RE: false,
17+
RUN_DEMO_PIPELINE: true,
18+
DEMO_PIPELINE_NAME: 'Codefresh-Runner Demo',
19+
CF_CONTEXT_NAME: 'cf-runner',
20+
};
21+
1422
const defaultOpenIssueMessage = 'If you had any issues with this process please report them at: ' +
1523
`${colors.blue('https://github.com/codefresh-io/cli/issues/new')}`;
1624
const url = _.get(sdk, 'config.context.url', 'https://g.codefresh.io');
@@ -51,6 +59,14 @@ async function createTestPipeline(runtimeName, pipelineName, pipelineCommands, p
5159
return pipeline;
5260
}
5361

62+
async function getTestPipelineLink(pipelineName) {
63+
const pipelines = await sdk.pipelines.list({ id: pipelineName });
64+
if (_.get(pipelines, 'docs.length')) {
65+
const pipeline = pipelines.docs[0];
66+
return `${url}/pipelines/edit/workflow?id=${pipeline.metadata.id}&pipeline=${encodeURI(pipeline.metadata.name)}`;
67+
}
68+
}
69+
5470
async function getTestPipeline(pipelineName) {
5571
const pipelines = await sdk.pipelines.list({ id: pipelineName });
5672
if (_.get(pipelines, 'docs.length')) {
@@ -61,6 +77,7 @@ async function getTestPipeline(pipelineName) {
6177
return pipeline;
6278
}
6379

80+
6481
return null;
6582
}
6683

@@ -205,4 +222,6 @@ module.exports = {
205222
getTestPipeline,
206223
executeTestPipeline,
207224
createProgressBar,
225+
getTestPipelineLink,
226+
INSTALLATION_DEFAULTS,
208227
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const Command = require('../../Command');
2+
const runnerRoot = require('../root/runner.cmd');
3+
const getAgents = require('../agent/get.cmd');
4+
5+
6+
const command = new Command({
7+
command: 'info',
8+
parent: runnerRoot,
9+
description: 'Get info on your runner installations',
10+
webDocs: {
11+
category: 'Runner',
12+
title: 'Info',
13+
},
14+
handler: async () => {
15+
await getAgents.handler({});
16+
},
17+
});
18+
19+
module.exports = command;

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,10 @@ const {
1919
getTestPipeline,
2020
createTestPipeline,
2121
executeTestPipeline,
22+
INSTALLATION_DEFAULTS,
2223
} = require('./helper');
2324

24-
const INSTALLATION_DEFAULTS = {
25-
NAMESPACE: 'codefresh',
26-
MAKE_DEFAULT_RE: false,
27-
RUN_DEMO_PIPELINE: true,
28-
DEMO_PIPELINE_NAME: 'Codefresh-Runner Demo',
29-
CF_CONTEXT_NAME: 'cf-runner',
30-
};
25+
3126

3227
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')}`);
3328

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.4",
3+
"version": "0.64.6",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)