Skip to content

Commit b7a4de8

Browse files
Saas 7125 - fixed runner init wording (#453)
1 parent 43893b6 commit b7a4de8

File tree

4 files changed

+84
-66
lines changed

4 files changed

+84
-66
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const installAgentCmd = new Command({
108108
agent = await sdk.agents.create({ name });
109109
// eslint-disable-next-line prefer-destructuring
110110
token = agent.token;
111-
console.log(`An agent with name: ${colors.blue(name)} has been created\nMake sure to copy your access token now. You won’t be able to see it again`);
111+
console.log(`A Codefresh Runner with name: ${colors.cyan(name)} has been created.\n${colors.yellow('*IMPORTANT*')} Make sure to copy your access token now and store it in a safe location. You won’t be able to see it again.`);
112112
console.log(token);
113113
} else {
114114
// take the agent id from the token
@@ -120,7 +120,7 @@ const installAgentCmd = new Command({
120120
const { subject } = agentData;
121121

122122
if (subject.type !== 'agent') {
123-
throw new Error('token is not assosicated with agent');
123+
throw new Error('token is not assosicated with a runner');
124124
}
125125
const agentId = agentData.subject.ref;
126126
const data = await sdk.agents.get({ agentId });
@@ -133,7 +133,7 @@ const installAgentCmd = new Command({
133133
const progressBar = new cliProgress.SingleBar({ stopOnComplete: true, format }, cliProgress.Presets.shades_classic);
134134
let totalSize;
135135
events.onStart((size) => {
136-
console.log('Downloading agent\'s installer \n');
136+
console.log('Downloading Codefresh Runner installer \n');
137137
progressBar.start(size, 0);
138138
totalSize = size;
139139
});
@@ -163,7 +163,7 @@ const installAgentCmd = new Command({
163163
events,
164164
});
165165
if (agentInstallStatusCode !== 0) {
166-
throw new Error(`\nAgent installation failed with code ${agentInstallStatusCode}`);
166+
throw new Error(`\nRunner installation failed with code ${agentInstallStatusCode}`);
167167
}
168168
if (installRuntime) {
169169
await installRuntimeCmd.handler({

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

Lines changed: 70 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@ const { getConfigForSdk } = require('../../commad-line-interface');
1010
const colors = require('colors');
1111
const DEFAULTS = require('../../defaults');
1212
const sdk = require('../../../../logic/sdk');
13-
const Output = require('../../../../output/Output');
1413
const _ = require('lodash');
1514

16-
const defaultNamespace = 'codefresh';
15+
const INSTALLATION_DEFAULTS = {
16+
NAMESPACE: 'codefresh',
17+
MAKE_DEFAULT_RE: true,
18+
RUN_DEMO_PIPELINE: true,
19+
};
1720

1821
const initCmd = new Command({
1922
root: false,
2023
parent: runnerRoot,
2124
command: 'init',
2225
requiresAuthentication: false,
23-
description: 'Install codefresh runner solution\'s components on kubernetes cluster',
26+
description: 'Install Codefresh Runner solution\'s components on kubernetes cluster',
2427
webDocs: {
2528
category: 'Runner',
2629
title: 'Init',
@@ -48,6 +51,19 @@ const initCmd = new Command({
4851
.option('dry-run', {
4952
describe: 'Set to true to simulate installation',
5053
})
54+
.option('yes', {
55+
describe: 'Use installation defaults (don\'t ask any questions)',
56+
alias: 'y',
57+
type: 'boolean',
58+
})
59+
.option('set-default-runtime', {
60+
describe: 'Set this as the default runtime environment for your Codefresh account',
61+
type: 'boolean',
62+
})
63+
.option('exec-demo-pipeline', {
64+
describe: 'Run a demo pipeline after the installation completes',
65+
type: 'boolean',
66+
})
5167
.option('in-cluster', {
5268
describe: 'Set flag if venona is been installed from inside a cluster',
5369
})
@@ -82,78 +98,100 @@ const initCmd = new Command({
8298
'venona-version': venonaVersion,
8399
'kube-config-path': kubeConfigPath,
84100
'skip-version-check': skipVersionCheck,
101+
yes: noQuestions,
85102
verbose,
86103
name, token, url,
87104
} = argv;
88105
let {
89106
'kube-context-name': kubeContextName,
90107
'kube-namespace': kubeNamespace,
108+
'set-default-runtime': shouldMakeDefaultRe,
109+
'exec-demo-pipeline': shouldExecutePipeline,
91110
} = argv;
92111

93112
if (_.get(sdk, 'config.context.isNoAuth') && !token) {
94113
console.log('Not authenticated as a Codefresh account: ');
95114
console.log('In order to install a Codefresh Runner you need to provide ' +
96-
`an authentication token which can be generated here: ${colors.blue(`${argv.url}/user/settings`)}.` +
97-
'\nAfter getting the token you may run this command again with the [--token] option or use the codefresh auth command to create an authenticated context.');
115+
`an authentication token which can be generated here: ${colors.blue(`${argv.url}/user/settings`)}` +
116+
'\nAfter getting the token you may run this command again with the [--token] option or use the \'codefresh auth\' command to create an authenticated context.');
98117
process.exit(1);
99118
}
100119

120+
if (noQuestions) {
121+
// set defaults
122+
kubeContextName = getKubeContext(kubeConfigPath);
123+
kubeNamespace = INSTALLATION_DEFAULTS.NAMESPACE;
124+
shouldMakeDefaultRe = INSTALLATION_DEFAULTS.MAKE_DEFAULT_RE;
125+
shouldExecutePipeline = INSTALLATION_DEFAULTS.RUN_DEMO_PIPELINE;
126+
}
127+
101128
const questions = [];
102-
if (!kubeContextName) {
129+
if (!kubeContextName && !noQuestions) {
103130
const contexts = getAllKubeContexts(kubeConfigPath);
104131
const currentKubeContext = getKubeContext(kubeConfigPath);
105132

106133
questions.push({
107134
type: 'list',
108135
name: 'context',
109-
message: 'Select Kubernetes context',
136+
message: 'Name of Kubernetes context to use',
110137
default: currentKubeContext,
111138
choices: contexts,
112139
});
113140
}
114-
if (!kubeNamespace) {
141+
if (!kubeNamespace && !noQuestions) {
115142
questions.push({
116143
type: 'input',
117144
name: 'namespace',
118-
default: defaultNamespace,
119-
message: 'Insert Kubernetes namespace (will be created if not exists) ',
145+
default: INSTALLATION_DEFAULTS.NAMESPACE,
146+
message: 'Kubernetes namespace to install into (will be created if it does not exist)',
120147
validate: value => (value !== undefined && value !== '') || 'Please enter namespace\'s name',
121148
});
122149
}
123150

124-
questions.push({
125-
type: 'confirm',
126-
name: 'shouldMakeDefaultRe',
127-
default: true,
128-
message: 'Should mark the hybrid runtime as default runtime ?',
129-
130-
});
131-
132-
questions.push({
133-
type: 'confirm',
134-
name: 'shouldExecutePipeline',
135-
default: true,
136-
message: 'Run demo pipeline ?',
151+
if (_.isUndefined(shouldMakeDefaultRe) && !noQuestions) {
152+
questions.push({
153+
type: 'confirm',
154+
name: 'shouldMakeDefaultRe',
155+
default: INSTALLATION_DEFAULTS.MAKE_DEFAULT_RE,
156+
message: 'Set this as the default runtime environment for your Codefresh account? (Y/N)',
157+
});
158+
}
137159

138-
});
160+
if (_.isUndefined(shouldExecutePipeline) && !noQuestions) {
161+
questions.push({
162+
type: 'confirm',
163+
name: 'shouldExecutePipeline',
164+
default: INSTALLATION_DEFAULTS.RUN_DEMO_PIPELINE,
165+
message: 'Run demo pipeline after install? (Y/N)',
166+
});
167+
}
139168

140-
console.log(colors.green('This installer will guide you through the hybrid installation process'));
169+
console.log(colors.green('This installer will guide you through the Codefresh Runner installation process'));
141170
const answers = await inquirer.prompt(questions);
142171
kubeContextName = kubeContextName || answers.context;
143172
kubeNamespace = kubeNamespace || answers.namespace;
144-
const { shouldMakeDefaultRe, shouldExecutePipeline } = answers;
145-
console.log(colors.green(`Installation options summary : \n Context: ${colors.blue(kubeContextName)} \n Namespace: ${colors.blue(kubeNamespace)} \n Make hybrid runime as default: ${colors.blue(shouldMakeDefaultRe)}\nExecute hello hyrbird pipeline: ${colors.blue(shouldExecutePipeline)}`));
173+
shouldMakeDefaultRe = shouldMakeDefaultRe || answers.shouldMakeDefaultRe;
174+
shouldExecutePipeline = shouldExecutePipeline || answers.shouldExecutePipeline;
175+
176+
console.log(colors.green(`\nInstallation options summary:
177+
${colors.white('1. Kubernetes Context:')} ${colors.cyan(kubeContextName)}
178+
${colors.white('2. Kubernetes Namespace:')} ${colors.cyan(kubeNamespace)}
179+
${colors.white('3. Set this as default account runtime-environment:')} ${colors.cyan(shouldMakeDefaultRe)}
180+
${colors.white('4. Execute demo pipeline after install:')} ${colors.cyan(shouldExecutePipeline)}
181+
`));
182+
146183
if (token) { // Add context
147184
await createContext.handler({
148185
apiKey: token,
149-
name: 'hybrid',
186+
name: 'cf-runner',
150187
url,
151188
});
152189
const config = await getConfigForSdk();
153190
await sdk.configure(config);
154-
console.log('A codefresh context named hybrid was added in your $HOME folder');
191+
console.log('A Codefresh context named "cf-runner" was added to your "cfconfig" file.');
155192
}
156193

194+
// Install runner and runtime
157195
await installAgent.handler({
158196
name,
159197
'kube-context-name': kubeContextName,
@@ -173,10 +211,10 @@ const initCmd = new Command({
173211
createDemoPipeline: true,
174212
executeDemoPipeline: shouldExecutePipeline,
175213
});
176-
console.log(colors.green('Agent Status:\n'));
214+
console.log(colors.green('Runner Status:\n'));
177215
await getAgents.handler({});
178-
console.log(colors.green(`\nDocumenation link: ${colors.blue('https://codefresh.io/docs/docs/enterprise/codefresh-runner/#codefresh-runner-preview-release')}`));
179-
console.log(colors.green('\nTo report issues please follow this link: https://github.com/codefresh-io/cli/issues/new'));
216+
console.log(colors.green(`\nDocumenation link: ${colors.blue('https://codefresh.io/docs/docs/enterprise/codefresh-runner/#codefresh-runner-preview-release')}`));
217+
console.log(colors.green(`\nIf you had any issues with the installation please report them at: ${colors.blue('https://github.com/codefresh-io/cli/issues/new')}`));
180218
process.exit(); // TODO : This is not needed - needed to be fixed
181219
},
182220
});

lib/interface/cli/commands/runtimeEnvironments/install.cmd.js

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,6 @@ const colors = require('colors');
1313
const defaultNamespace = 'codefresh';
1414
const pipelineName = 'hello_hybrid';
1515

16-
const _getAgentData = async (token) => {
17-
// take the agent id from the token
18-
const apiKey = token.split('.')[0];
19-
const agentKey = await sdk.tokens.getById({ id: apiKey });
20-
if (!agentKey) {
21-
throw new Error('token is not valid');
22-
}
23-
const { subject } = agentKey;
24-
25-
if (subject.type !== 'agent') {
26-
throw new Error('token is not assosicated with agent');
27-
}
28-
const agentId = agentKey.subject.ref;
29-
const agentData = await sdk.agents.get({ agentId });
30-
if (!agentData || agentData === '') {
31-
throw new Error('failed to get agent data');
32-
}
33-
return agentData;
34-
};
35-
3616
const createHelloWorlPipeline = async (runtime) => {
3717
const pipeline = await sdk.pipelines.create({ metadata: { name: pipelineName } });
3818
pipeline.spec.runtimeEnvironment = {
@@ -132,7 +112,7 @@ const installRuntimeCmd = new Command({
132112
describe: 'service account for cluster default is default',
133113
})
134114
.option('make-default-runtime', {
135-
describe: 'should all pipelines run on the hybrid runtime (default is false)',
115+
describe: 'should all pipelines run on the this runtime (default is false)',
136116
})
137117
.option('skip-cluster-test', {
138118
describe: 'Do not run cluster acceptance test',
@@ -210,13 +190,13 @@ const installRuntimeCmd = new Command({
210190
clusterName,
211191
agent: true,
212192
});
213-
console.log(`Runtime envrionment ${colors.blue(runtimeName)} has been created`);
193+
console.log(`Runtime environment "${colors.cyan(runtimeName)}" has been created`);
214194
if (shouldMakeDefaultRe) {
215195
const re = await sdk.runtimeEnvs.get({
216196
name: runtimeName,
217197
});
218198
await sdk.onPrem.runtimeEnvs.account.setDefault({ account: re.accountId, name: re.metadata.name });
219-
console.log(`Runtime envrionment ${colors.blue(runtimeName)} has been set to default runtme`);
199+
console.log(`Runtime environment "${colors.cyan(runtimeName)}" has been set as the default runtime`);
220200
}
221201

222202
// create the cluster in codefresh
@@ -229,20 +209,20 @@ const installRuntimeCmd = new Command({
229209
terminateProcess: false,
230210
});
231211
} catch (error) {
232-
console.log(`Failed to register cluster on codefresh, cause: ${error.message}`);
212+
console.log(`Failed to register cluster on Codefresh, cause: ${error.message}`);
233213
}
234214
if (createDemoPipeline) {
235215
await createHelloWorlPipeline(runtimeName);
236-
console.log(`Pipeline ${colors.blue(pipelineName)} has been created`);
216+
console.log(`Pipeline "${colors.cyan(pipelineName)}" has been created`);
237217
}
238218
// install RE on cluster
239219

240220
const runtimeEvents = new ProgressEvents();
241-
const runtimeFormat = 'downloading runtime installer [{bar}] {percentage}% | {value}/{total}';
221+
const runtimeFormat = 'downloading runtime installer [{bar}] {percentage}% | {value}/{total}';
242222
const runtimmrProgressBar = new cliProgress.SingleBar({ stopOnComplete: true, format: runtimeFormat }, cliProgress.Presets.shades_classic);
243223
let runtimeTotalSize;
244224
runtimeEvents.onStart((size) => {
245-
console.log('Downloading runtime\'s installer \n');
225+
console.log('Downloading runtime installer:\n');
246226
runtimmrProgressBar.start(size, 0);
247227
runtimeTotalSize = size;
248228
});
@@ -274,7 +254,7 @@ const installRuntimeCmd = new Command({
274254
// attach RE to agent in codefresh
275255

276256
if (installRuntimeExitCode !== 0) {
277-
throw new Error(`Runtime envrionment install failed with exit code ${installRuntimeExitCode}`);
257+
throw new Error(`Runtime environment installation failed with exit code: ${installRuntimeExitCode}`);
278258
}
279259

280260
if (attachRuntime) {
@@ -305,7 +285,7 @@ const installRuntimeCmd = new Command({
305285
throw new Error(`Attach runtime failed with exit code ${attachRuntimeStatusCode}`);
306286
}
307287
if (executeDemoPipeline) {
308-
console.log(`Executing pipeline ${colors.blue(pipelineName)}`);
288+
console.log(`Executing pipeline "${colors.cyan(pipelineName)}"`);
309289
await runCmd.handler({
310290
name: pipelineName,
311291
exitProcess: false,

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

0 commit comments

Comments
 (0)