import k8s from "@kubernetes/client-node"; const MCL_KUBECONFIG = process.env.MCL_KUBECONFIG; const envConfig = MCL_KUBECONFIG ? MCL_KUBECONFIG : null; const kc = new k8s.KubeConfig(); try { if (!!envConfig) kc.loadFromString(Buffer.from(envConfig, "base64").toString("utf8")); else kc.loadFromDefault(); } catch (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;