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 {
302302 }
303303 }
304304 if ( process . platform === 'win32' && shelljs . which ( 'wsl.exe' ) ) {
305- // TODO: Handle if someome set $KUBECONFIG in wsl here...
306305 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' ] ) ;
308323 if ( result . exitCode === 0 ) {
309324 this . loadFromString ( result . stdout , opts ) ;
310325 return ;
You can’t perform that action at this time.
0 commit comments