@@ -507,13 +507,22 @@ export class OdoImpl implements Odo {
507507 const result : cliInstance . CliExitData = await this . execute (
508508 Command . printOdoVersion ( ) , process . cwd ( ) , false
509509 ) ;
510- commands . executeCommand ( 'setContext' , 'isLoggedIn' , false ) ;
510+ void commands . executeCommand ( 'setContext' , 'isLoggedIn' , false ) ;
511511 clusters = result . stdout . trim ( ) . split ( '\n' )
512512 . filter ( ( value ) => value . includes ( 'Server:' ) )
513513 . map ( ( value ) => {
514- commands . executeCommand ( 'setContext' , 'isLoggedIn' , true ) ;
515- return new OpenShiftCluster ( value . substr ( value . indexOf ( ':' ) + 1 ) . trim ( ) )
514+ void commands . executeCommand ( 'setContext' , 'isLoggedIn' , true ) ;
515+ return new OpenShiftCluster ( value . substr ( value . indexOf ( ':' ) + 1 ) . trim ( ) ) ;
516516 } ) ;
517+ if ( clusters . length === 0 ) {
518+ const projects = await this . execute (
519+ Command . listProjects ( ) , process . cwd ( ) , false
520+ ) ;
521+ if ( ! projects . error ) {
522+ clusters . push ( new OpenShiftCluster ( new KubeConfigUtils ( ) . getCurrentCluster ( ) . server ) ) ;
523+ void commands . executeCommand ( 'setContext' , 'isLoggedIn' , true ) ;
524+ }
525+ }
517526 return clusters ;
518527 }
519528
@@ -786,8 +795,10 @@ export class OdoImpl implements Odo {
786795 }
787796
788797 public async requireLogin ( ) : Promise < boolean > {
789- const result : cliInstance . CliExitData = await this . execute ( new CommandText ( 'oc whoami' ) , process . cwd ( ) , false ) ;
790- return ! ! result . error ;
798+ return await Promise . any ( [
799+ this . execute ( new CommandText ( 'oc whoami' ) ) ,
800+ this . execute ( Command . listProjects ( ) )
801+ ] ) . then ( ( ) => false ) . catch ( ( ) => true ) ;
791802 }
792803
793804 private async insertAndReveal ( item : OpenShiftObject , notification = true ) : Promise < OpenShiftObject > {
0 commit comments