@@ -507,13 +507,22 @@ export class OdoImpl implements Odo {
507
507
const result : cliInstance . CliExitData = await this . execute (
508
508
Command . printOdoVersion ( ) , process . cwd ( ) , false
509
509
) ;
510
- commands . executeCommand ( 'setContext' , 'isLoggedIn' , false ) ;
510
+ void commands . executeCommand ( 'setContext' , 'isLoggedIn' , false ) ;
511
511
clusters = result . stdout . trim ( ) . split ( '\n' )
512
512
. filter ( ( value ) => value . includes ( 'Server:' ) )
513
513
. 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 ( ) ) ;
516
516
} ) ;
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
+ }
517
526
return clusters ;
518
527
}
519
528
@@ -786,8 +795,10 @@ export class OdoImpl implements Odo {
786
795
}
787
796
788
797
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 ) ;
791
802
}
792
803
793
804
private async insertAndReveal ( item : OpenShiftObject , notification = true ) : Promise < OpenShiftObject > {
0 commit comments