Skip to content

Commit

Permalink
feat(kube-config): add support for KUBECONFIG env var (#322)
Browse files Browse the repository at this point in the history
  • Loading branch information
JacopoDaeli authored and silasbw committed Sep 6, 2018
1 parent 98f0a1a commit c6810de
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ const tokenPath = '/var/run/secrets/kubernetes.io/serviceaccount/token';
const namespacePath = '/var/run/secrets/kubernetes.io/serviceaccount/namespace';

function defaultConfigPath() {
if (process.env.KUBECONFIG) {
// From https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/#set-the-kubeconfig-environment-variable
// KUBECONFIG can support multiple config files.
// If multiple config files in KUBECONFIG, then return the first one.
const delimiter = process.platform === 'win32' ? ';' : ':';
const configPaths = process.env.KUBECONFIG.split(delimiter);
return configPaths[0];
}
const homeDir = process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'];
return path.join(homeDir, '.kube', 'config');
}
Expand Down

0 comments on commit c6810de

Please sign in to comment.