Skip to content

Commit e4939d3

Browse files
Improve idiomatic installation (#495)
* improved installationPlan
1 parent a1c98bf commit e4939d3

File tree

3 files changed

+28
-26
lines changed

3 files changed

+28
-26
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class InstallationPlan {
4242
finishedSteps: finishedSteps || [],
4343
context: context || {},
4444
};
45-
this.completedSteps = {};
45+
this.completedSteps = {}; // used for fast lookup of completed steps
4646
this.progressReporter = progressReporter;
4747
this.errHandler = errHandler;
4848
_ensureDirectory(RUNNER_INSTALLATIONS_PATH);

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

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ const initCmd = new Command({
136136
if (oldInstallationPlan) {
137137
console.log(colors.cyan('Previous installation state:'));
138138
oldInstallationPlan.printState();
139+
oldInstallationPlan.reset(); // needs to be called after printState()
139140
const answer = await inquirer.prompt({
140141
type: 'confirm',
141142
name: 'resumeInstallation',
@@ -254,19 +255,6 @@ const initCmd = new Command({
254255
shouldExecutePipeline,
255256
});
256257

257-
if (token) {
258-
// Create a new context and switch to that context
259-
const [err] = await to(createContext.handler({
260-
apiKey: token,
261-
name: INSTALLATION_DEFAULTS.CF_CONTEXT_NAME,
262-
url,
263-
}));
264-
await handleError(err, 'Failed to use the provided token');
265-
const config = await getConfigForSdk();
266-
await sdk.configure(config);
267-
console.log(`A Codefresh context named '${INSTALLATION_DEFAULTS.CF_CONTEXT_NAME}' was added to your "cfconfig" file.`);
268-
}
269-
270258
const [, progress] = await to(async () => installationProgress.create(sdk['runner-installation'], {
271259
options: {
272260
kubeContextName,
@@ -293,17 +281,31 @@ const initCmd = new Command({
293281
_argv['exec-demo-pipeline'] = shouldExecutePipeline;
294282
installationPlan.addContext('argv', _argv);
295283

296-
if (skipClusterTest) {
297-
console.log('Skipping cluster requirements tests...');
298-
} else {
299-
installationPlan.addStep({
300-
name: 'run cluster acceptance tests',
301-
func: runClusterAcceptanceTests,
302-
arg: { kubeNamespace, kubeConfigPath },
303-
errMessage: 'Failed to run cluster test',
304-
installationEvent: installationProgress.events.ACCEPTANCE_TESTS_RAN,
305-
});
306-
}
284+
// create new codefresh auth context
285+
installationPlan.addStep({
286+
name: 'create new codefresh auth context',
287+
func: async () => {
288+
await createContext.handler({
289+
apiKey: token,
290+
name: INSTALLATION_DEFAULTS.CF_CONTEXT_NAME,
291+
url,
292+
});
293+
const config = await getConfigForSdk();
294+
await sdk.configure(config);
295+
console.log(`A Codefresh context named '${INSTALLATION_DEFAULTS.CF_CONTEXT_NAME}' was added to your "cfconfig" file.`);
296+
},
297+
condition: token,
298+
299+
});
300+
301+
// run cluster acceptance tests
302+
installationPlan.addStep({
303+
name: 'run cluster acceptance tests',
304+
func: runClusterAcceptanceTests,
305+
arg: { kubeNamespace, kubeConfigPath },
306+
installationEvent: installationProgress.events.ACCEPTANCE_TESTS_RAN,
307+
condition: !skipClusterTest,
308+
});
307309

308310
// generate new agent name
309311
installationPlan.addContext('agentName', name);

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

0 commit comments

Comments
 (0)