Skip to content

Commit

Permalink
fixed runner init not using token (#497)
Browse files Browse the repository at this point in the history
Co-authored-by: Roi Kramer <[email protected]>
  • Loading branch information
roi-codefresh and Roi Kramer authored Jun 11, 2020
1 parent f8a9a61 commit 9777d23
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
30 changes: 13 additions & 17 deletions lib/interface/cli/commands/hybrid/init.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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',
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.68.5",
"version": "0.68.6",
"description": "Codefresh command line utility",
"main": "index.js",
"preferGlobal": true,
Expand Down

0 comments on commit 9777d23

Please sign in to comment.