File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -302,9 +302,24 @@ export class KubeConfig {
302
302
}
303
303
}
304
304
if ( process . platform === 'win32' && shelljs . which ( 'wsl.exe' ) ) {
305
- // TODO: Handle if someome set $KUBECONFIG in wsl here...
306
305
try {
307
- const result = execa . sync ( 'wsl.exe' , [ 'cat' , shelljs . homedir ( ) + '/.kube/config' ] ) ;
306
+ const envKubeconfigPathResult = execa . sync ( 'wsl.exe' , [ 'bash' , '-ic' , 'printenv KUBECONFIG' ] ) ;
307
+ if ( envKubeconfigPathResult . exitCode === 0 && envKubeconfigPathResult . stdout . length > 0 ) {
308
+ const result = execa . sync ( 'wsl.exe' , [ 'cat' , envKubeconfigPathResult . stdout ] ) ;
309
+ if ( result . exitCode === 0 ) {
310
+ this . loadFromString ( result . stdout , opts ) ;
311
+ return ;
312
+ }
313
+ if ( result . exitCode === 0 ) {
314
+ this . loadFromString ( result . stdout , opts ) ;
315
+ return ;
316
+ }
317
+ }
318
+ } catch ( err ) {
319
+ // Falling back to default kubeconfig
320
+ }
321
+ try {
322
+ const result = execa . sync ( 'wsl.exe' , [ 'cat' , '~/.kube/config' ] ) ;
308
323
if ( result . exitCode === 0 ) {
309
324
this . loadFromString ( result . stdout , opts ) ;
310
325
return ;
You can’t perform that action at this time.
0 commit comments