@@ -255,6 +255,19 @@ const initCmd = new Command({
255255 shouldExecutePipeline,
256256 } ) ;
257257
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+
258271 const [ , progress ] = await to ( async ( ) => installationProgress . create ( sdk [ 'runner-installation' ] , {
259272 options : {
260273 kubeContextName,
@@ -281,23 +294,6 @@ const initCmd = new Command({
281294 _argv [ 'exec-demo-pipeline' ] = shouldExecutePipeline ;
282295 installationPlan . addContext ( 'argv' , _argv ) ;
283296
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-
301297 // run cluster acceptance tests
302298 installationPlan . addStep ( {
303299 name : 'run cluster acceptance tests' ,
0 commit comments