mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add kludge to extension api to maintain functionality
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
5f8ea56223
commit
94d2e993fb
@ -26,10 +26,12 @@ import loggerInjectable from "../../common/logger.injectable";
|
|||||||
import { getLegacyGlobalDiForExtensionApi } from "../as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
|
import { getLegacyGlobalDiForExtensionApi } from "../as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
|
||||||
import maybeKubeApiInjectable from "../../common/k8s-api/maybe-kube-api.injectable";
|
import maybeKubeApiInjectable from "../../common/k8s-api/maybe-kube-api.injectable";
|
||||||
import { DeploymentApi as InternalDeploymentApi, IngressApi as InternalIngressApi, NodeApi, PersistentVolumeClaimApi, PodApi } from "../../common/k8s-api/endpoints";
|
import { DeploymentApi as InternalDeploymentApi, IngressApi as InternalIngressApi, NodeApi, PersistentVolumeClaimApi, PodApi } from "../../common/k8s-api/endpoints";
|
||||||
|
import { storesAndApisCanBeCreatedInjectionToken } from "../../common/k8s-api/stores-apis-can-be-created.token";
|
||||||
|
|
||||||
export const apiManager = asLegacyGlobalForExtensionApi(apiManagerInjectable);
|
export const apiManager = asLegacyGlobalForExtensionApi(apiManagerInjectable);
|
||||||
export const forCluster = asLegacyGlobalFunctionForExtensionApi(createKubeApiForClusterInjectable);
|
export const forCluster = asLegacyGlobalFunctionForExtensionApi(createKubeApiForClusterInjectable);
|
||||||
export const forRemoteCluster = asLegacyGlobalFunctionForExtensionApi(createKubeApiForRemoteClusterInjectable);
|
export const forRemoteCluster = asLegacyGlobalFunctionForExtensionApi(createKubeApiForRemoteClusterInjectable);
|
||||||
|
export const createResourceStack = asLegacyGlobalFunctionForExtensionApi(createResourceStackInjectable);
|
||||||
|
|
||||||
const getKubeApiDeps = (): KubeApiDependencies => {
|
const getKubeApiDeps = (): KubeApiDependencies => {
|
||||||
const di = getLegacyGlobalDiForExtensionApi();
|
const di = getLegacyGlobalDiForExtensionApi();
|
||||||
@ -45,7 +47,16 @@ function KubeApiCstr<
|
|||||||
Object extends KubeObject = KubeObject,
|
Object extends KubeObject = KubeObject,
|
||||||
Data extends KubeJsonApiDataFor<Object> = KubeJsonApiDataFor<Object>,
|
Data extends KubeJsonApiDataFor<Object> = KubeJsonApiDataFor<Object>,
|
||||||
>(opts: KubeApiOptions<Object, Data>) {
|
>(opts: KubeApiOptions<Object, Data>) {
|
||||||
return new InternalKubeApi(getKubeApiDeps(), opts);
|
const api = new InternalKubeApi(getKubeApiDeps(), opts);
|
||||||
|
|
||||||
|
const di = getLegacyGlobalDiForExtensionApi();
|
||||||
|
const storesAndApisCanBeCreated = di.inject(storesAndApisCanBeCreatedInjectionToken);
|
||||||
|
|
||||||
|
if (storesAndApisCanBeCreated) {
|
||||||
|
apiManager.registerApi(api);
|
||||||
|
}
|
||||||
|
|
||||||
|
return api;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const KubeApi = KubeApiCstr as unknown as new<
|
export const KubeApi = KubeApiCstr as unknown as new<
|
||||||
@ -53,8 +64,6 @@ export const KubeApi = KubeApiCstr as unknown as new<
|
|||||||
Data extends KubeJsonApiDataFor<Object> = KubeJsonApiDataFor<Object>,
|
Data extends KubeJsonApiDataFor<Object> = KubeJsonApiDataFor<Object>,
|
||||||
>(opts: KubeApiOptions<Object, Data>) => InternalKubeApi<Object, Data>;
|
>(opts: KubeApiOptions<Object, Data>) => InternalKubeApi<Object, Data>;
|
||||||
|
|
||||||
export const createResourceStack = asLegacyGlobalFunctionForExtensionApi(createResourceStackInjectable);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Switch to using `Common.createResourceStack` instead
|
* @deprecated Switch to using `Common.createResourceStack` instead
|
||||||
*/
|
*/
|
||||||
@ -174,31 +183,31 @@ export interface IgnoredKubeApiOptions {
|
|||||||
|
|
||||||
// NOTE: these *Constructor functions MUST be `function` to work with `new X()`
|
// NOTE: these *Constructor functions MUST be `function` to work with `new X()`
|
||||||
function PodsApiConstructor(opts?: DerivedKubeApiOptions & IgnoredKubeApiOptions) {
|
function PodsApiConstructor(opts?: DerivedKubeApiOptions & IgnoredKubeApiOptions) {
|
||||||
return new PodApi(getKubeApiDeps(), opts ?? {});
|
return new PodApi(getKubeApiDeps(), opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PodsApi = PodsApiConstructor as unknown as new (opts?: DerivedKubeApiOptions & IgnoredKubeApiOptions) => PodApi;
|
export const PodsApi = PodsApiConstructor as unknown as new (opts?: DerivedKubeApiOptions & IgnoredKubeApiOptions) => PodApi;
|
||||||
|
|
||||||
function NodesApiConstructor(opts?: DerivedKubeApiOptions & IgnoredKubeApiOptions) {
|
function NodesApiConstructor(opts?: DerivedKubeApiOptions & IgnoredKubeApiOptions) {
|
||||||
return new NodeApi(getKubeApiDeps(), opts ?? {});
|
return new NodeApi(getKubeApiDeps(), opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const NodesApi = NodesApiConstructor as unknown as new (opts?: DerivedKubeApiOptions & IgnoredKubeApiOptions) => NodeApi;
|
export const NodesApi = NodesApiConstructor as unknown as new (opts?: DerivedKubeApiOptions & IgnoredKubeApiOptions) => NodeApi;
|
||||||
|
|
||||||
function DeploymentApiConstructor(opts?: DerivedKubeApiOptions) {
|
function DeploymentApiConstructor(opts?: DerivedKubeApiOptions) {
|
||||||
return new InternalDeploymentApi(getKubeApiDeps(), opts ?? {});
|
return new InternalDeploymentApi(getKubeApiDeps(), opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DeploymentApi = DeploymentApiConstructor as unknown as new (opts?: DerivedKubeApiOptions) => InternalDeploymentApi;
|
export const DeploymentApi = DeploymentApiConstructor as unknown as new (opts?: DerivedKubeApiOptions) => InternalDeploymentApi;
|
||||||
|
|
||||||
function IngressApiConstructor(opts?: DerivedKubeApiOptions & IgnoredKubeApiOptions) {
|
function IngressApiConstructor(opts?: DerivedKubeApiOptions & IgnoredKubeApiOptions) {
|
||||||
return new InternalIngressApi(getKubeApiDeps(), opts ?? {});
|
return new InternalIngressApi(getKubeApiDeps(), opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const IngressApi = IngressApiConstructor as unknown as new (opts?: DerivedKubeApiOptions & IgnoredKubeApiOptions) => InternalIngressApi;
|
export const IngressApi = IngressApiConstructor as unknown as new (opts?: DerivedKubeApiOptions & IgnoredKubeApiOptions) => InternalIngressApi;
|
||||||
|
|
||||||
function PersistentVolumeClaimsApiConstructor(opts?: DerivedKubeApiOptions & IgnoredKubeApiOptions) {
|
function PersistentVolumeClaimsApiConstructor(opts?: DerivedKubeApiOptions & IgnoredKubeApiOptions) {
|
||||||
return new PersistentVolumeClaimApi(getKubeApiDeps(), opts ?? {});
|
return new PersistentVolumeClaimApi(getKubeApiDeps(), opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PersistentVolumeClaimsApi = PersistentVolumeClaimsApiConstructor as unknown as new (opts?: DerivedKubeApiOptions & IgnoredKubeApiOptions) => PersistentVolumeClaimApi;
|
export const PersistentVolumeClaimsApi = PersistentVolumeClaimsApiConstructor as unknown as new (opts?: DerivedKubeApiOptions & IgnoredKubeApiOptions) => PersistentVolumeClaimApi;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user