@@ -7,20 +7,23 @@ import { Context, KubernetesObject } from '@kubernetes/client-node';
7
7
import * as fs from 'fs' ;
8
8
import * as path from 'path' ;
9
9
import {
10
- commands , Disposable ,
10
+ Disposable ,
11
11
Event ,
12
- EventEmitter , extensions , ThemeIcon ,
12
+ EventEmitter ,
13
+ ThemeIcon ,
13
14
TreeDataProvider ,
14
15
TreeItem ,
15
16
TreeItemCollapsibleState ,
16
17
TreeView ,
17
- Uri , version ,
18
+ Uri ,
19
+ commands ,
20
+ extensions ,
21
+ version ,
18
22
window
19
23
} from 'vscode' ;
20
- import { CliChannel } from './cli' ;
21
24
import * 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 ' ;
24
27
import { KubeConfigUtils } from './util/kubeUtils' ;
25
28
import { Platform } from './util/platform' ;
26
29
import { Progress } from './util/progress' ;
@@ -59,8 +62,6 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
59
62
readonly onDidChangeTreeData : Event < ExplorerItem | undefined > = this
60
63
. eventEmitter . event ;
61
64
62
- private odo3 : Odo3 = newInstance ( ) ;
63
-
64
65
private constructor ( ) {
65
66
try {
66
67
this . kubeConfig = new KubeConfigUtils ( ) ;
@@ -90,17 +91,6 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
90
91
} ) ;
91
92
}
92
93
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
-
104
94
static getInstance ( ) : OpenShiftExplorer {
105
95
if ( ! OpenShiftExplorer . instance ) {
106
96
OpenShiftExplorer . instance = new OpenShiftExplorer ( ) ;
@@ -182,7 +172,7 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
182
172
let result : ExplorerItem [ ] = [ ] ;
183
173
if ( ! element ) {
184
174
try {
185
- await this . odo3 . getNamespaces ( )
175
+ await Odo . Instance . getProjects ( ) ;
186
176
result = [ this . kubeContext ] ;
187
177
if ( this . kubeContext ) {
188
178
const homeDir = this . kubeConfig . findHomeDir ( ) ;
@@ -205,9 +195,9 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
205
195
// * example is sandbox context created when login to sandbox first time
206
196
// (3) there is namespace set in context and namespace exists in the cluster
207
197
// (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 ( ) ;
209
199
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 ) ) {
211
201
result = [ {
212
202
kind : 'project' ,
213
203
metadata : {
@@ -216,14 +206,14 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
216
206
} as KubernetesObject ]
217
207
} else if ( namespaces . length >= 1 ) {
218
208
// switch to first accessible namespace
219
- await this . odo3 . setNamespace ( namespaces [ 0 ] . metadata . name ) ;
209
+ await Odo . Instance . setProject ( namespaces [ 0 ] . name ) ;
220
210
} else {
221
211
result = [ CREATE_OR_SET_PROJECT_ITEM ]
222
212
}
223
213
} else {
224
214
// get list of projects or namespaces
225
215
// find default namespace
226
- if ( namespaces . find ( item => item ?. metadata . name === 'default' ) ) {
216
+ if ( namespaces . find ( item => item ?. name === 'default' ) ) {
227
217
result = [ {
228
218
kind : 'project' ,
229
219
metadata : {
@@ -235,14 +225,14 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
235
225
}
236
226
}
237
227
} 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
+ ] ;
239
233
}
240
234
// 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 ( ) ;
246
236
void commands . executeCommand ( 'setContext' , 'isOpenshiftCluster' , isOpenshiftCluster ) ;
247
237
248
238
if ( ! element ) {
0 commit comments