@@ -255,6 +255,19 @@ const initCmd = new Command({
255
255
shouldExecutePipeline,
256
256
} ) ;
257
257
258
+ if ( token ) {
259
+ // Create a new context and switch to that context
260
+ const [ err ] = await to ( createContext . handler ( {
261
+ apiKey : token ,
262
+ name : INSTALLATION_DEFAULTS . CF_CONTEXT_NAME ,
263
+ url,
264
+ } ) ) ;
265
+ await handleError ( err , 'Failed to use the provided token' ) ;
266
+ const config = await getConfigForSdk ( ) ;
267
+ await sdk . configure ( config ) ;
268
+ console . log ( `A Codefresh context named '${ INSTALLATION_DEFAULTS . CF_CONTEXT_NAME } ' was added to your "cfconfig" file.` ) ;
269
+ }
270
+
258
271
const [ , progress ] = await to ( async ( ) => installationProgress . create ( sdk [ 'runner-installation' ] , {
259
272
options : {
260
273
kubeContextName,
@@ -281,23 +294,6 @@ const initCmd = new Command({
281
294
_argv [ 'exec-demo-pipeline' ] = shouldExecutePipeline ;
282
295
installationPlan . addContext ( 'argv' , _argv ) ;
283
296
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
297
// run cluster acceptance tests
302
298
installationPlan . addStep ( {
303
299
name : 'run cluster acceptance tests' ,
0 commit comments