-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(config): support multiple config files in KUBECONFIG #326
Conversation
Follow up after discussion in #322. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great.
Can you add some tests?
Of course. I will deal with it ASAP. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @silasbw. Looks good but tests would be 💯
lib/config.js
Outdated
|
||
return config; | ||
} | ||
|
||
function loadKubeconfig(cfgPath) { | ||
cfgPath = cfgPath || defaultConfigPath(); | ||
const cfgPaths = cfgPath ? [cfgPath] : defaultConfigPath(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JacopoDaeli was thinking, should we support passing an array of config paths in here as well? i.e.
let cfgPaths;
if (!cfgPath) { cfgPaths = defaultConfigPath(); }
else if(Array.isArray(cfgPath)) { cfgPaths = cfgPath; }
else { cfgPaths = [cfgPath]; }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking that too. Not sure. In any case, that doesn't hurt, but is it useful?
@silasbw what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sgtm 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JacopoDaeli LGTM, an extra test for the new API possibility could be nice but I won't block it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: rename defaultConfigPath
to defaultConfigPaths
Adding support for multiple config files in
KUBECONFIG
env variable.Official ref: https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/#create-a-second-configuration-file
Output of
![image](https://user-images.githubusercontent.com/6058569/45189104-3686c400-b1ec-11e8-9140-13d755707d6a.png)
![image](https://user-images.githubusercontent.com/6058569/45189120-4e5e4800-b1ec-11e8-99b7-e9cb4c7e0d9e.png)
console.log(yaml.dump(merge.all(configs)))
(ref to configs) is:which matches the output of
kubectl config view
: