From 27b11fcd502c815d7489b3914c390751306f99dd Mon Sep 17 00:00:00 2001 From: Dunemask Date: Sun, 25 Aug 2024 11:52:25 -0600 Subject: [PATCH] [FIX] Infer Current Context --- .gitignore | 1 + lib/k8s/k8s-config.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index d570088..5c86a6a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ +.env diff --git a/lib/k8s/k8s-config.js b/lib/k8s/k8s-config.js index d481f77..cbe55b6 100644 --- a/lib/k8s/k8s-config.js +++ b/lib/k8s/k8s-config.js @@ -7,8 +7,8 @@ try { kc.loadFromString(Buffer.from(envConfig, "base64").toString("utf8")); else kc.loadFromDefault(); } catch (e) { - console.error("There was an issue loading the config from an envar! Using default permissions!"); - console.error(e); kc.loadFromDefault(); } +if(kc.contexts.length === 1) kc.setCurrentContext(kc.contexts[0].name); +if(!kc.currentContext) throw new Error("Could not infer current context! Please set it manually in the Kubeconfig!"); export default kc;