From 44cd91053e85b55c661656959ae3eae6235f56cf Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Thu, 3 Mar 2022 11:39:24 +0200 Subject: [PATCH] loosen api-manager kubeobject types Signed-off-by: Jari Kolehmainen --- src/common/k8s-api/api-manager.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/common/k8s-api/api-manager.ts b/src/common/k8s-api/api-manager.ts index d392673364..d4fa4bc707 100644 --- a/src/common/k8s-api/api-manager.ts +++ b/src/common/k8s-api/api-manager.ts @@ -12,15 +12,15 @@ import type { KubeObject } from "./kube-object"; import { IKubeObjectRef, parseKubeApi, createKubeApiURL } from "./kube-api-parse"; export class ApiManager { - private apis = observable.map>(); - private stores = observable.map>(); + private apis = observable.map>(); + private stores = observable.map>(); constructor() { makeObservable(this); autoBind(this); } - getApi(pathOrCallback: string | ((api: KubeApi) => boolean)) { + getApi(pathOrCallback: string | ((api: KubeApi) => boolean)) { if (typeof pathOrCallback === "string") { return this.apis.get(pathOrCallback) || this.apis.get(parseKubeApi(pathOrCallback).apiBase); } @@ -32,7 +32,7 @@ export class ApiManager { return iter.find(this.apis.values(), api => api.kind === kind && api.apiVersionWithGroup === apiVersion); } - registerApi(apiBase: string, api: KubeApi) { + registerApi(apiBase: string, api: KubeApi) { if (!api.apiBase) return; if (!this.apis.has(apiBase)) { @@ -58,7 +58,7 @@ export class ApiManager { return api; } - unregisterApi(api: string | KubeApi) { + unregisterApi(api: string | KubeApi) { if (typeof api === "string") this.apis.delete(api); else { const apis = Array.from(this.apis.entries()); @@ -69,17 +69,17 @@ export class ApiManager { } @action - registerStore(store: KubeObjectStore, apis: KubeApi[] = [store.api]) { + registerStore(store: KubeObjectStore, apis: KubeApi[] = [store.api]) { apis.filter(Boolean).forEach(api => { if (api.apiBase) this.stores.set(api.apiBase, store); }); } - getStore>(api: string | KubeApi): S | undefined { + getStore>(api: string | KubeApi): S | undefined { return this.stores.get(this.resolveApi(api)?.apiBase) as S; } - lookupApiLink(ref: IKubeObjectRef, parentObject?: KubeObject): string { + lookupApiLink(ref: IKubeObjectRef, parentObject?: T): string { const { kind, apiVersion, name, namespace = parentObject?.getNs(),