1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Export KubeJsonApi to extensions (#4496)

* Export KubeJsonApi to extensions

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Make forCluster() to consume clusterId as arg

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Fix lint

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2021-12-09 15:11:34 +03:00 committed by GitHub
parent 25f4a1f3ba
commit 3dd6b432c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

@ -21,7 +21,6 @@
import { JsonApi, JsonApiData, JsonApiError } from "./json-api"; import { JsonApi, JsonApiData, JsonApiError } from "./json-api";
import type { Response } from "node-fetch"; import type { Response } from "node-fetch";
import type { Cluster } from "../../main/cluster";
import { LensProxy } from "../../main/lens-proxy"; import { LensProxy } from "../../main/lens-proxy";
import { apiKubePrefix, isDebugging } from "../vars"; import { apiKubePrefix, isDebugging } from "../vars";
@ -73,7 +72,7 @@ export interface KubeJsonApiError extends JsonApiError {
} }
export class KubeJsonApi extends JsonApi<KubeJsonApiData> { export class KubeJsonApi extends JsonApi<KubeJsonApiData> {
static forCluster(cluster: Cluster): KubeJsonApi { static forCluster(clusterId: string): KubeJsonApi {
const port = LensProxy.getInstance().port; const port = LensProxy.getInstance().port;
return new this({ return new this({
@ -82,7 +81,7 @@ export class KubeJsonApi extends JsonApi<KubeJsonApiData> {
debug: isDebugging, debug: isDebugging,
}, { }, {
headers: { headers: {
"Host": `${cluster.id}.localhost:${port}`, "Host": `${clusterId}.localhost:${port}`,
}, },
}); });
} }

View File

@ -55,6 +55,7 @@ export { ClusterRole, clusterRoleApi } from "../../common/k8s-api/endpoints";
export { ClusterRoleBinding, clusterRoleBindingApi } from "../../common/k8s-api/endpoints"; export { ClusterRoleBinding, clusterRoleBindingApi } from "../../common/k8s-api/endpoints";
export { CustomResourceDefinition, crdApi } from "../../common/k8s-api/endpoints"; export { CustomResourceDefinition, crdApi } from "../../common/k8s-api/endpoints";
export { KubeObjectStatusLevel } from "./kube-object-status"; export { KubeObjectStatusLevel } from "./kube-object-status";
export { KubeJsonApi } from "../../common/k8s-api/kube-json-api";
// types // types
export type { ILocalKubeApiConfig, IRemoteKubeApiConfig, IKubeApiCluster } from "../../common/k8s-api/kube-api"; export type { ILocalKubeApiConfig, IRemoteKubeApiConfig, IKubeApiCluster } from "../../common/k8s-api/kube-api";

View File

@ -64,7 +64,7 @@ export class NodeShellSession extends ShellSession {
const args = ["exec", "-i", "-t", "-n", "kube-system", this.podName, "--"]; const args = ["exec", "-i", "-t", "-n", "kube-system", this.podName, "--"];
const nodeApi = new NodesApi({ const nodeApi = new NodesApi({
objectConstructor: Node, objectConstructor: Node,
request: KubeJsonApi.forCluster(this.cluster), request: KubeJsonApi.forCluster(this.cluster.id),
}); });
const node = await nodeApi.get({ name: this.nodeName }); const node = await nodeApi.get({ name: this.nodeName });
const nodeOs = node.getOperatingSystem(); const nodeOs = node.getOperatingSystem();