@@ -46,14 +46,14 @@ export class ClusterCommandTasks {
46
46
if ( ! context ) {
47
47
const isQuiet = self . parent . getConfigManager ( ) . getFlag ( flags . quiet ) ;
48
48
if ( isQuiet ) {
49
- context = self . parent . getK8Factory ( ) . contexts ( ) . readCurrent ( ) ;
49
+ context = self . parent . getK8Factory ( ) . default ( ) . contexts ( ) . readCurrent ( ) ;
50
50
} else {
51
51
context = await self . promptForContext ( parentTask , cluster ) ;
52
52
}
53
53
54
54
localConfig . clusterContextMapping [ cluster ] = context ;
55
55
}
56
- if ( ! ( await self . parent . getK8Factory ( ) . contexts ( ) . testContextConnection ( context ) ) ) {
56
+ if ( ! ( await self . parent . getK8Factory ( ) . default ( ) . contexts ( ) . testContextConnection ( context ) ) ) {
57
57
subTask . title = `${ subTask . title } - ${ chalk . red ( 'Cluster connection failed' ) } ` ;
58
58
throw new SoloError ( `${ ErrorMessages . INVALID_CONTEXT_FOR_CLUSTER_DETAILED ( context , cluster ) } ` ) ;
59
59
}
@@ -72,7 +72,7 @@ export class ClusterCommandTasks {
72
72
title : `Pull and validate remote configuration for cluster: ${ chalk . cyan ( cluster ) } ` ,
73
73
task : async ( _ , subTask : ListrTaskWrapper < any , any , any > ) => {
74
74
const context = localConfig . clusterContextMapping [ cluster ] ;
75
- self . parent . getK8Factory ( ) . contexts ( ) . updateCurrent ( context ) ;
75
+ self . parent . getK8Factory ( ) . default ( ) . contexts ( ) . updateCurrent ( context ) ;
76
76
const remoteConfigFromOtherCluster = await self . parent . getRemoteConfigManager ( ) . get ( ) ;
77
77
if ( ! RemoteConfigManager . compare ( currentRemoteConfig , remoteConfigFromOtherCluster ) ) {
78
78
throw new SoloError ( ErrorMessages . REMOTE_CONFIGS_DO_NOT_MATCH ( currentClusterName , cluster ) ) ;
@@ -87,7 +87,7 @@ export class ClusterCommandTasks {
87
87
title : 'Read clusters from remote config' ,
88
88
task : async ( ctx , task ) => {
89
89
const localConfig = this . parent . getLocalConfig ( ) ;
90
- const currentClusterName = this . parent . getK8Factory ( ) . clusters ( ) . readCurrent ( ) ;
90
+ const currentClusterName = this . parent . getK8Factory ( ) . default ( ) . clusters ( ) . readCurrent ( ) ;
91
91
const currentRemoteConfig : RemoteConfigDataWrapper = await this . parent . getRemoteConfigManager ( ) . get ( ) ;
92
92
const subTasks = [ ] ;
93
93
const remoteConfigClusters = Object . keys ( currentRemoteConfig . clusters ) ;
@@ -162,7 +162,11 @@ export class ClusterCommandTasks {
162
162
} else if ( ! localConfig . clusterContextMapping [ cluster ] ) {
163
163
// In quiet mode, use the currently selected context to update the mapping
164
164
if ( isQuiet ) {
165
- localConfig . clusterContextMapping [ cluster ] = this . parent . getK8Factory ( ) . contexts ( ) . readCurrent ( ) ;
165
+ localConfig . clusterContextMapping [ cluster ] = this . parent
166
+ . getK8Factory ( )
167
+ . default ( )
168
+ . contexts ( )
169
+ . readCurrent ( ) ;
166
170
}
167
171
168
172
// Prompt the user to select a context if mapping value is missing
@@ -185,7 +189,7 @@ export class ClusterCommandTasks {
185
189
) {
186
190
let selectedContext ;
187
191
if ( isQuiet ) {
188
- selectedContext = this . parent . getK8Factory ( ) . contexts ( ) . readCurrent ( ) ;
192
+ selectedContext = this . parent . getK8Factory ( ) . default ( ) . contexts ( ) . readCurrent ( ) ;
189
193
} else {
190
194
selectedContext = await this . promptForContext ( task , selectedCluster ) ;
191
195
localConfig . clusterContextMapping [ selectedCluster ] = selectedContext ;
@@ -194,7 +198,7 @@ export class ClusterCommandTasks {
194
198
}
195
199
196
200
private async promptForContext ( task : SoloListrTaskWrapper < SelectClusterContextContext > , cluster : string ) {
197
- const kubeContexts = this . parent . getK8Factory ( ) . contexts ( ) . list ( ) ;
201
+ const kubeContexts = this . parent . getK8Factory ( ) . default ( ) . contexts ( ) . list ( ) ;
198
202
return flags . context . prompt ( task , kubeContexts , cluster ) ;
199
203
}
200
204
@@ -306,8 +310,8 @@ export class ClusterCommandTasks {
306
310
else {
307
311
// Add the deployment to the LocalConfig with the currently selected cluster and context in KubeConfig
308
312
if ( isQuiet ) {
309
- selectedContext = this . parent . getK8Factory ( ) . contexts ( ) . readCurrent ( ) ;
310
- selectedCluster = this . parent . getK8Factory ( ) . clusters ( ) . readCurrent ( ) ;
313
+ selectedContext = this . parent . getK8Factory ( ) . default ( ) . contexts ( ) . readCurrent ( ) ;
314
+ selectedCluster = this . parent . getK8Factory ( ) . default ( ) . clusters ( ) . readCurrent ( ) ;
311
315
localConfig . deployments [ deploymentName ] = {
312
316
clusters : [ selectedCluster ] ,
313
317
namespace : namespace ? namespace . name : '' ,
@@ -335,11 +339,15 @@ export class ClusterCommandTasks {
335
339
}
336
340
}
337
341
338
- const connectionValid = await this . parent . getK8Factory ( ) . contexts ( ) . testContextConnection ( selectedContext ) ;
342
+ const connectionValid = await this . parent
343
+ . getK8Factory ( )
344
+ . default ( )
345
+ . contexts ( )
346
+ . testContextConnection ( selectedContext ) ;
339
347
if ( ! connectionValid ) {
340
348
throw new SoloError ( ErrorMessages . INVALID_CONTEXT_FOR_CLUSTER ( selectedContext , selectedCluster ) ) ;
341
349
}
342
- this . parent . getK8Factory ( ) . contexts ( ) . updateCurrent ( selectedContext ) ;
350
+ this . parent . getK8Factory ( ) . default ( ) . contexts ( ) . updateCurrent ( selectedContext ) ;
343
351
this . parent . getConfigManager ( ) . setFlag ( flags . context , selectedContext ) ;
344
352
} ,
345
353
} ;
@@ -361,14 +369,14 @@ export class ClusterCommandTasks {
361
369
362
370
showClusterList ( ) {
363
371
return new Task ( 'List all available clusters' , async ( ctx : any , task : ListrTaskWrapper < any , any , any > ) => {
364
- this . parent . logger . showList ( 'Clusters' , this . parent . getK8Factory ( ) . clusters ( ) . list ( ) ) ;
372
+ this . parent . logger . showList ( 'Clusters' , this . parent . getK8Factory ( ) . default ( ) . clusters ( ) . list ( ) ) ;
365
373
} ) ;
366
374
}
367
375
368
376
getClusterInfo ( ) {
369
377
return new Task ( 'Get cluster info' , async ( ctx : any , task : ListrTaskWrapper < any , any , any > ) => {
370
378
try {
371
- const clusterName = this . parent . getK8Factory ( ) . clusters ( ) . readCurrent ( ) ;
379
+ const clusterName = this . parent . getK8Factory ( ) . default ( ) . clusters ( ) . readCurrent ( ) ;
372
380
this . parent . logger . showUser ( `Cluster Name (${ clusterName } )` ) ;
373
381
this . parent . logger . showUser ( '\n' ) ;
374
382
} catch ( e : Error | unknown ) {
0 commit comments