From 4f51a5431c9e75fb4854038d6a52917f89112251 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Wed, 17 Aug 2022 10:50:42 -0400 Subject: [PATCH] Fix crash will looking up api refs Signed-off-by: Sebastian Malton --- src/common/k8s-api/kube-api.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/common/k8s-api/kube-api.ts b/src/common/k8s-api/kube-api.ts index 3df8f3216f..d1e2a2c7ca 100644 --- a/src/common/k8s-api/kube-api.ts +++ b/src/common/k8s-api/kube-api.ts @@ -394,16 +394,12 @@ export class KubeApi< } getUrl({ name, namespace }: Partial = {}, query?: Partial) { - if (!this.isNamespaced && namespace) { - throw new Error("Tried to delete cluster scoped resource in a namespace"); - } - const resourcePath = createKubeApiURL({ apiPrefix: this.apiPrefix, apiVersion: this.apiVersionWithGroup, resource: this.apiResource, namespace: this.isNamespaced - ? namespace || "default" + ? namespace ?? "default" // allow `""` to mean all namespaces : undefined, name, }); @@ -612,6 +608,8 @@ export class KubeApi< watchId = `${this.kind.toLowerCase()}-${this.watchId++}`, } = opts ?? {}; + console.log(`watching ${this.apiBase} in namespace="${namespace}"`); + // Create AbortController for this request const abortController = new WrappedAbortController(opts?.abortController);