mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix getKubeConfigLocal()
Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
parent
d4ff99f3bf
commit
5e97ba1f70
@ -16,7 +16,7 @@ function resolveTilde(filePath: string) {
|
|||||||
|
|
||||||
export function loadConfig(pathOrContent?: string): KubeConfig {
|
export function loadConfig(pathOrContent?: string): KubeConfig {
|
||||||
const kc = new KubeConfig();
|
const kc = new KubeConfig();
|
||||||
|
|
||||||
if (fse.pathExistsSync(pathOrContent)) {
|
if (fse.pathExistsSync(pathOrContent)) {
|
||||||
kc.loadFromFile(path.resolve(resolveTilde(pathOrContent)));
|
kc.loadFromFile(path.resolve(resolveTilde(pathOrContent)));
|
||||||
} else {
|
} else {
|
||||||
@ -160,7 +160,7 @@ export async function getKubeConfigLocal(): Promise<string> {
|
|||||||
const file = await readFile(configFile, "utf8");
|
const file = await readFile(configFile, "utf8");
|
||||||
const obj = yaml.safeLoad(file);
|
const obj = yaml.safeLoad(file);
|
||||||
if (obj.contexts) {
|
if (obj.contexts) {
|
||||||
obj.contexts = obj.context.filter((ctx: any) => ctx?.context?.cluster && ctx?.name)
|
obj.contexts = obj.contexts.filter((ctx: any) => ctx?.context?.cluster && ctx?.name)
|
||||||
}
|
}
|
||||||
return yaml.safeDump(obj);
|
return yaml.safeDump(obj);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user