From 0095c779b2be93c1a9a6afaf2cbbda245d66cf20 Mon Sep 17 00:00:00 2001 From: Lauri Nevala Date: Tue, 4 Aug 2020 10:24:11 +0300 Subject: [PATCH] Fix getKubeConfigLocal() (#635) --- src/common/kube-helpers.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/kube-helpers.ts b/src/common/kube-helpers.ts index 3df03a8211..3709f0ac94 100644 --- a/src/common/kube-helpers.ts +++ b/src/common/kube-helpers.ts @@ -16,7 +16,7 @@ function resolveTilde(filePath: string) { export function loadConfig(pathOrContent?: string): KubeConfig { const kc = new KubeConfig(); - + if (fse.pathExistsSync(pathOrContent)) { kc.loadFromFile(path.resolve(resolveTilde(pathOrContent))); } else { @@ -160,7 +160,7 @@ export async function getKubeConfigLocal(): Promise { const file = await readFile(configFile, "utf8"); const obj = yaml.safeLoad(file); 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); } catch (err) {