File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -231,8 +231,10 @@ export class KubeConfig {
231
231
this . currentContext = contextName ;
232
232
}
233
233
234
- public mergeConfig ( config : KubeConfig ) : void {
235
- this . currentContext = config . currentContext ;
234
+ public mergeConfig ( config : KubeConfig , preserveContext : boolean = false ) : void {
235
+ if ( ! preserveContext ) {
236
+ this . currentContext = config . currentContext ;
237
+ }
236
238
config . clusters . forEach ( ( cluster : Cluster ) => {
237
239
this . addCluster ( cluster ) ;
238
240
} ) ;
@@ -280,14 +282,14 @@ export class KubeConfig {
280
282
this . contexts . push ( ctx ) ;
281
283
}
282
284
283
- public loadFromDefault ( opts ?: Partial < ConfigOptions > ) : void {
285
+ public loadFromDefault ( opts ?: Partial < ConfigOptions > , contextFromStartingConfig : boolean = false ) : void {
284
286
if ( process . env . KUBECONFIG && process . env . KUBECONFIG . length > 0 ) {
285
287
const files = process . env . KUBECONFIG . split ( path . delimiter ) ;
286
288
this . loadFromFile ( files [ 0 ] , opts ) ;
287
289
for ( let i = 1 ; i < files . length ; i ++ ) {
288
290
const kc = new KubeConfig ( ) ;
289
291
kc . loadFromFile ( files [ i ] , opts ) ;
290
- this . mergeConfig ( kc ) ;
292
+ this . mergeConfig ( kc , contextFromStartingConfig ) ;
291
293
}
292
294
return ;
293
295
}
You can’t perform that action at this time.
0 commit comments