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 {
284
284
285
285
public loadFromDefault ( opts ?: Partial < ConfigOptions > , contextFromStartingConfig : boolean = false ) : void {
286
286
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 ) ;
288
288
this . loadFromFile ( files [ 0 ] , opts ) ;
289
289
for ( let i = 1 ; i < files . length ; i ++ ) {
290
290
const kc = new KubeConfig ( ) ;
Original file line number Diff line number Diff line change @@ -1064,6 +1064,18 @@ describe('KubeConfig', () => {
1064
1064
const kc = new KubeConfig ( ) ;
1065
1065
expect ( ( ) => kc . loadFromDefault ( ) ) . to . throw ( 'Duplicate user: user1' ) ;
1066
1066
} ) ;
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
+ } ) ;
1067
1079
} ) ;
1068
1080
1069
1081
function platformPath ( path : string ) {
You can’t perform that action at this time.
0 commit comments