File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -284,7 +284,7 @@ export class KubeConfig {
284284
285285 public loadFromDefault ( opts ?: Partial < ConfigOptions > , contextFromStartingConfig : boolean = false ) : void {
286286 if ( process . env . KUBECONFIG && process . env . KUBECONFIG . length > 0 ) {
287- const files = process . env . KUBECONFIG . split ( path . delimiter ) ;
287+ const files = process . env . KUBECONFIG . split ( path . delimiter ) . filter ( ( filename : string ) => filename ) ;
288288 this . loadFromFile ( files [ 0 ] , opts ) ;
289289 for ( let i = 1 ; i < files . length ; i ++ ) {
290290 const kc = new KubeConfig ( ) ;
Original file line number Diff line number Diff line change @@ -1064,6 +1064,18 @@ describe('KubeConfig', () => {
10641064 const kc = new KubeConfig ( ) ;
10651065 expect ( ( ) => kc . loadFromDefault ( ) ) . to . throw ( 'Duplicate user: user1' ) ;
10661066 } ) ;
1067+
1068+ it ( 'should ignore extra path delimiters' , ( ) => {
1069+ process . env . KUBECONFIG = path . delimiter + kcFileName + path . delimiter ;
1070+
1071+ const kc = new KubeConfig ( ) ;
1072+ kc . loadFromDefault ( ) ;
1073+
1074+ expect ( kc . clusters . length ) . to . equal ( 2 ) ;
1075+ expect ( kc . users . length ) . to . equal ( 3 ) ;
1076+ expect ( kc . contexts . length ) . to . equal ( 3 ) ;
1077+ expect ( kc . getCurrentContext ( ) ) . to . equal ( 'context2' ) ;
1078+ } ) ;
10671079 } ) ;
10681080
10691081 function platformPath ( path : string ) {
You can’t perform that action at this time.
0 commit comments