mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix api-manager kubeobject types (#4959)
* loosen api-manager kubeobject types Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * less any Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * less any Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix typings Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix typings Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
54b87efd89
commit
8dbc0b82f8
@ -32,7 +32,7 @@ export class ApiManager {
|
|||||||
return iter.find(this.apis.values(), api => api.kind === kind && api.apiVersionWithGroup === apiVersion);
|
return iter.find(this.apis.values(), api => api.kind === kind && api.apiVersionWithGroup === apiVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
registerApi(apiBase: string, api: KubeApi<KubeObject>) {
|
registerApi<K extends KubeObject>(apiBase: string, api: KubeApi<K>) {
|
||||||
if (!api.apiBase) return;
|
if (!api.apiBase) return;
|
||||||
|
|
||||||
if (!this.apis.has(apiBase)) {
|
if (!this.apis.has(apiBase)) {
|
||||||
@ -46,13 +46,13 @@ export class ApiManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected resolveApi<K extends KubeObject>(api?: string | KubeApi<K>): KubeApi<K> | undefined {
|
protected resolveApi(api?: string | KubeApi<KubeObject>): KubeApi<KubeObject> | undefined {
|
||||||
if (!api) {
|
if (!api) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof api === "string") {
|
if (typeof api === "string") {
|
||||||
return this.getApi(api) as KubeApi<K>;
|
return this.getApi(api) as KubeApi<KubeObject>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return api;
|
return api;
|
||||||
@ -69,7 +69,7 @@ export class ApiManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
registerStore(store: KubeObjectStore<KubeObject>, apis: KubeApi<KubeObject>[] = [store.api]) {
|
registerStore<K extends KubeObject>(store: KubeObjectStore<K>, apis: KubeApi<K>[] = [store.api]) {
|
||||||
apis.filter(Boolean).forEach(api => {
|
apis.filter(Boolean).forEach(api => {
|
||||||
if (api.apiBase) this.stores.set(api.apiBase, store);
|
if (api.apiBase) this.stores.set(api.apiBase, store);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user