From 120ae5bb5f55b868bdcc032f4e5ad52736ff4785 Mon Sep 17 00:00:00 2001 From: Nick Mitchell Date: Wed, 17 Jun 2020 20:29:52 -0400 Subject: [PATCH] fix(plugins/plugin-kubectl): windows powershell fails to get default namespace Fixes #4912 --- plugins/plugin-kubectl/src/controller/kubectl/contexts.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/plugin-kubectl/src/controller/kubectl/contexts.ts b/plugins/plugin-kubectl/src/controller/kubectl/contexts.ts index 15524f50511..602fb819947 100644 --- a/plugins/plugin-kubectl/src/controller/kubectl/contexts.ts +++ b/plugins/plugin-kubectl/src/controller/kubectl/contexts.ts @@ -136,7 +136,11 @@ export async function getCurrentContextName({ REPL }: { REPL: REPLType }) { /** Extract the namespace from the current context */ export async function getCurrentDefaultNamespace({ REPL }: { REPL: REPLType }) { - const ns = await REPL.qexec(`kubectl config view --minify --output 'jsonpath={..namespace}'`) + const ns = await REPL.qexec(`kubectl config view --minify --output "jsonpath={..namespace}"`).catch(err => { + console.error('error determining default namespace', err) + return 'default' + }) + if (typeof ns !== 'string') { // e.g. microk8s return 'default'