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 {
231231 this . currentContext = contextName ;
232232 }
233233
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+ }
236238 config . clusters . forEach ( ( cluster : Cluster ) => {
237239 this . addCluster ( cluster ) ;
238240 } ) ;
@@ -280,14 +282,14 @@ export class KubeConfig {
280282 this . contexts . push ( ctx ) ;
281283 }
282284
283- public loadFromDefault ( opts ?: Partial < ConfigOptions > ) : void {
285+ public loadFromDefault ( opts ?: Partial < ConfigOptions > , contextFromStartingConfig : boolean = false ) : void {
284286 if ( process . env . KUBECONFIG && process . env . KUBECONFIG . length > 0 ) {
285287 const files = process . env . KUBECONFIG . split ( path . delimiter ) ;
286288 this . loadFromFile ( files [ 0 ] , opts ) ;
287289 for ( let i = 1 ; i < files . length ; i ++ ) {
288290 const kc = new KubeConfig ( ) ;
289291 kc . loadFromFile ( files [ i ] , opts ) ;
290- this . mergeConfig ( kc ) ;
292+ this . mergeConfig ( kc , contextFromStartingConfig ) ;
291293 }
292294 return ;
293295 }
You can’t perform that action at this time.
0 commit comments