@@ -481,15 +481,6 @@ export class OdoImpl implements Odo {
481481
482482 private static instance : Odo ;
483483
484- private readonly odoLoginMessages = [
485- 'Please log in to the cluster' ,
486- 'the server has asked for the client to provide credentials' ,
487- 'Please login to your server' ,
488- 'Unauthorized' ,
489- 'User "system:anonymous" cannot list resource "projects"' ,
490- '"system:anonymous"' ,
491- ] ;
492-
493484 public readonly subject : Subject < OdoEvent > = new Subject < OdoEvent > ( ) ;
494485
495486 public static get Instance ( ) : Odo {
@@ -508,37 +499,17 @@ export class OdoImpl implements Odo {
508499 }
509500
510501 public async _getClusters ( ) : Promise < OpenShiftObject [ ] > {
511- let clusters : OpenShiftObject [ ] = await this . getClustersWithOdo ( ) ;
512- if ( clusters . length === 0 ) {
513- clusters = await this . getClustersWithOc ( ) ;
514- }
515- return clusters ;
516- }
517-
518- private async getClustersWithOc ( ) : Promise < OpenShiftObject [ ] > {
519- let clusters : OpenShiftObject [ ] = [ ] ;
520- const result : cliInstance . CliExitData = await this . execute ( Command . printOcVersion ( ) , process . cwd ( ) , false ) ;
521- clusters = result . stdout . trim ( ) . split ( '\n' ) . filter ( ( value ) => {
522- return value . includes ( 'Server ' ) ;
523- } ) . map ( ( value ) => {
524- const server : string = value . substr ( value . indexOf ( ' ' ) + 1 ) . trim ( ) ;
525- return new OpenShiftCluster ( server ) ;
526- } ) ;
527- return clusters ;
528- }
529-
530- private async getClustersWithOdo ( ) : Promise < OpenShiftObject [ ] > {
531502 let clusters : OpenShiftObject [ ] = [ ] ;
532503 const result : cliInstance . CliExitData = await this . execute (
533- Command . printOdoVersionAndProjects ( ) , process . cwd ( ) , false
504+ Command . printOdoVersion ( ) , process . cwd ( ) , false
534505 ) ;
535- commands . executeCommand ( 'setContext' , 'isLoggedIn' , true ) ;
536- clusters = result . stdout . trim ( ) . split ( '\n' ) . filter ( ( value ) => {
537- return value . includes ( 'Server:' ) ;
538- } ) . map ( ( value ) => {
539- const server : string = value . substr ( value . indexOf ( ':' ) + 1 ) . trim ( ) ;
540- return new OpenShiftCluster ( server ) ;
541- } ) ;
506+ commands . executeCommand ( 'setContext' , 'isLoggedIn' , false ) ;
507+ clusters = result . stdout . trim ( ) . split ( '\n' )
508+ . filter ( ( value ) => value . includes ( 'Server:' ) )
509+ . map ( ( value ) => {
510+ commands . executeCommand ( 'setContext' , 'isLoggedIn' , true ) ;
511+ return new OpenShiftCluster ( value . substr ( value . indexOf ( ':' ) + 1 ) . trim ( ) )
512+ } ) ;
542513 return clusters ;
543514 }
544515
@@ -801,8 +772,8 @@ export class OdoImpl implements Odo {
801772 }
802773
803774 public async requireLogin ( ) : Promise < boolean > {
804- const result : cliInstance . CliExitData = await this . execute ( Command . printOdoVersionAndProjects ( ) , process . cwd ( ) , false ) ;
805- return this . odoLoginMessages . some ( ( msg ) => result . stderr . includes ( msg ) ) ;
775+ const result : cliInstance . CliExitData = await this . execute ( 'oc whoami' , process . cwd ( ) , false ) ;
776+ return ! ! result . error ;
806777 }
807778
808779 private async insertAndReveal ( item : OpenShiftObject ) : Promise < OpenShiftObject > {
0 commit comments