Skip to content

Commit 202c429

Browse files
committed
Try to load kubeconfig from wsl if present.
1 parent 01b721a commit 202c429

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import yaml = require('js-yaml');
88
// workaround for issue https://github.com/dchester/jsonpath/issues/96
99
import jsonpath = require('jsonpath/jsonpath.min');
1010
import request = require('request');
11+
import shelljs = require('shelljs');
1112

1213
import api = require('./api');
1314
import { Cluster, Context, newClusters, newContexts, newUsers, User } from './config_types';
@@ -205,6 +206,13 @@ export class KubeConfig {
205206
return;
206207
}
207208
}
209+
if (process.platform === 'win32' && shelljs.which('wsl.exe')) {
210+
const result = shelljs.exec('wsl.exe cat $HOME/.kube/config', { silent: true });
211+
if (result.code === 0) {
212+
this.loadFromString(result.stdout);
213+
return;
214+
}
215+
}
208216

209217
if (fs.existsSync(Config.SERVICEACCOUNT_TOKEN_PATH)) {
210218
this.loadFromCluster();

0 commit comments

Comments
 (0)