From 9777d238e2986416d66401be04f47f4ab63e7a90 Mon Sep 17 00:00:00 2001 From: roi-codefresh <60569147+roi-codefresh@users.noreply.github.com> Date: Thu, 11 Jun 2020 19:35:33 +0300 Subject: [PATCH] fixed runner init not using token (#497) Co-authored-by: Roi Kramer --- lib/interface/cli/commands/hybrid/init.cmd.js | 30 ++++++++----------- package.json | 2 +- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/lib/interface/cli/commands/hybrid/init.cmd.js b/lib/interface/cli/commands/hybrid/init.cmd.js index c40aa7cd0..66db62f02 100644 --- a/lib/interface/cli/commands/hybrid/init.cmd.js +++ b/lib/interface/cli/commands/hybrid/init.cmd.js @@ -255,6 +255,19 @@ const initCmd = new Command({ shouldExecutePipeline, }); + if (token) { + // Create a new context and switch to that context + const [err] = await to(createContext.handler({ + apiKey: token, + name: INSTALLATION_DEFAULTS.CF_CONTEXT_NAME, + url, + })); + await handleError(err, 'Failed to use the provided token'); + const config = await getConfigForSdk(); + await sdk.configure(config); + console.log(`A Codefresh context named '${INSTALLATION_DEFAULTS.CF_CONTEXT_NAME}' was added to your "cfconfig" file.`); + } + const [, progress] = await to(async () => installationProgress.create(sdk['runner-installation'], { options: { kubeContextName, @@ -281,23 +294,6 @@ const initCmd = new Command({ _argv['exec-demo-pipeline'] = shouldExecutePipeline; installationPlan.addContext('argv', _argv); - // create new codefresh auth context - installationPlan.addStep({ - name: 'create new codefresh auth context', - func: async () => { - await createContext.handler({ - apiKey: token, - name: INSTALLATION_DEFAULTS.CF_CONTEXT_NAME, - url, - }); - const config = await getConfigForSdk(); - await sdk.configure(config); - console.log(`A Codefresh context named '${INSTALLATION_DEFAULTS.CF_CONTEXT_NAME}' was added to your "cfconfig" file.`); - }, - condition: token, - - }); - // run cluster acceptance tests installationPlan.addStep({ name: 'run cluster acceptance tests', diff --git a/package.json b/package.json index 14649d822..8cc663d43 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codefresh", - "version": "0.68.5", + "version": "0.68.6", "description": "Codefresh command line utility", "main": "index.js", "preferGlobal": true,