@@ -7,20 +7,23 @@ import { Context, KubernetesObject } from '@kubernetes/client-node';
77import * as fs from 'fs' ;
88import * as path from 'path' ;
99import {
10- commands , Disposable ,
10+ Disposable ,
1111 Event ,
12- EventEmitter , extensions , ThemeIcon ,
12+ EventEmitter ,
13+ ThemeIcon ,
1314 TreeDataProvider ,
1415 TreeItem ,
1516 TreeItemCollapsibleState ,
1617 TreeView ,
17- Uri , version ,
18+ Uri ,
19+ commands ,
20+ extensions ,
21+ version ,
1822 window
1923} from 'vscode' ;
20- import { CliChannel } from './cli' ;
2124import * as Helm from './helm/helm' ;
22- import { Command } from './odo/command ' ;
23- import { newInstance , Odo3 } from './odo3 ' ;
25+ import { Oc } from './oc/ocWrapper ' ;
26+ import { Odo } from './odo/odoWrapper ' ;
2427import { KubeConfigUtils } from './util/kubeUtils' ;
2528import { Platform } from './util/platform' ;
2629import { Progress } from './util/progress' ;
@@ -59,8 +62,6 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
5962 readonly onDidChangeTreeData : Event < ExplorerItem | undefined > = this
6063 . eventEmitter . event ;
6164
62- private odo3 : Odo3 = newInstance ( ) ;
63-
6465 private constructor ( ) {
6566 try {
6667 this . kubeConfig = new KubeConfigUtils ( ) ;
@@ -90,17 +91,6 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
9091 } ) ;
9192 }
9293
93- async getCurrentClusterUrl ( ) : Promise < string | undefined > {
94- // print odo version and Server URL if user is logged in
95- const result = await CliChannel . getInstance ( ) . executeTool ( Command . printOdoVersion ( ) ) ;
96- // search for line with 'Server:' substring
97- const clusterLine = result . stdout . trim ( ) . split ( '\n' ) . find ( ( value ) => value . includes ( 'Server:' ) ) ;
98- // if line with Server: is printed out it means user is logged in
99- void commands . executeCommand ( 'setContext' , 'isLoggedIn' , ! ! clusterLine ) ;
100- // cut out server url after 'Server:' substring
101- return clusterLine ? clusterLine . substring ( clusterLine . indexOf ( ':' ) + 1 ) . trim ( ) : undefined ;
102- }
103-
10494 static getInstance ( ) : OpenShiftExplorer {
10595 if ( ! OpenShiftExplorer . instance ) {
10696 OpenShiftExplorer . instance = new OpenShiftExplorer ( ) ;
@@ -182,7 +172,7 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
182172 let result : ExplorerItem [ ] = [ ] ;
183173 if ( ! element ) {
184174 try {
185- await this . odo3 . getNamespaces ( )
175+ await Odo . Instance . getProjects ( ) ;
186176 result = [ this . kubeContext ] ;
187177 if ( this . kubeContext ) {
188178 const homeDir = this . kubeConfig . findHomeDir ( ) ;
@@ -205,9 +195,9 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
205195 // * example is sandbox context created when login to sandbox first time
206196 // (3) there is namespace set in context and namespace exists in the cluster
207197 // (4) there is namespace set in context and namespace does not exist in the cluster
208- const namespaces = await this . odo3 . getNamespaces ( ) ;
198+ const namespaces = await Odo . Instance . getProjects ( ) ;
209199 if ( this . kubeContext . namespace ) {
210- if ( namespaces . find ( item => item ?. metadata . name === this . kubeContext . namespace ) ) {
200+ if ( namespaces . find ( item => item . name === this . kubeContext . namespace ) ) {
211201 result = [ {
212202 kind : 'project' ,
213203 metadata : {
@@ -216,14 +206,14 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
216206 } as KubernetesObject ]
217207 } else if ( namespaces . length >= 1 ) {
218208 // switch to first accessible namespace
219- await this . odo3 . setNamespace ( namespaces [ 0 ] . metadata . name ) ;
209+ await Odo . Instance . setProject ( namespaces [ 0 ] . name ) ;
220210 } else {
221211 result = [ CREATE_OR_SET_PROJECT_ITEM ]
222212 }
223213 } else {
224214 // get list of projects or namespaces
225215 // find default namespace
226- if ( namespaces . find ( item => item ?. metadata . name === 'default' ) ) {
216+ if ( namespaces . find ( item => item ?. name === 'default' ) ) {
227217 result = [ {
228218 kind : 'project' ,
229219 metadata : {
@@ -235,14 +225,14 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
235225 }
236226 }
237227 } else {
238- result = [ ...await this . odo3 . getDeploymentConfigs ( ) , ...await this . odo3 . getDeployments ( ) , ...await Helm . getHelmReleases ( ) ] ;
228+ result = [
229+ ...await Oc . Instance . getKubernetesObjects ( 'DeploymentConfig' ) ,
230+ ...await Oc . Instance . getKubernetesObjects ( 'Deployment' ) ,
231+ ...await Helm . getHelmReleases ( )
232+ ] ;
239233 }
240234 // don't show Open In Developer Dashboard if not openshift cluster
241- const openshiftResources = await CliChannel . getInstance ( ) . executeTool ( Command . isOpenshiftCluster ( ) , undefined , false ) ;
242- let isOpenshiftCluster = true ;
243- if ( openshiftResources . stdout . length === 0 ) {
244- isOpenshiftCluster = false ;
245- }
235+ const isOpenshiftCluster = await Oc . Instance . isOpenShiftCluster ( ) ;
246236 void commands . executeCommand ( 'setContext' , 'isOpenshiftCluster' , isOpenshiftCluster ) ;
247237
248238 if ( ! element ) {
0 commit comments