mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Replace usage of request in k8sRequest and cluster detectors
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
f522d23662
commit
37955f03e2
6 files changed
+14
-29
No files matched your search
@@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { RequestPromiseOptions } from "request-promise-native";
|
||||
import type { RequestInit } from "node-fetch";
|
||||
import type { Cluster } from "../../common/cluster/cluster";
|
||||
import type { K8sRequest } from "../k8s-request.injectable";
|
||||
|
||||
@@ -19,7 +19,7 @@ export abstract class BaseClusterDetector {
|
||||
|
||||
abstract detect(): Promise<ClusterDetectionResult | null>;
|
||||
|
||||
protected async k8sRequest<T = any>(path: string, options: RequestPromiseOptions = {}): Promise<T> {
|
||||
protected async k8sRequest(path: string, options?: RequestInit): Promise<unknown> {
|
||||
return this._k8sRequest(this.cluster, path, options);
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ export class ClusterIdDetector extends BaseClusterDetector {
|
||||
}
|
||||
|
||||
protected async getDefaultNamespaceId() {
|
||||
const response = await this.k8sRequest("/api/v1/namespaces/default");
|
||||
const response = await this.k8sRequest("/api/v1/namespaces/default") as { metadata: { uid: string }};
|
||||
|
||||
return response.metadata.uid;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ export class DistributionDetector extends BaseClusterDetector {
|
||||
}
|
||||
|
||||
public async getKubernetesVersion() {
|
||||
const response = await this.k8sRequest("/version");
|
||||
const response = await this.k8sRequest("/version") as { gitVersion: string };
|
||||
|
||||
return response.gitVersion;
|
||||
}
|
||||
@@ -179,7 +179,7 @@ export class DistributionDetector extends BaseClusterDetector {
|
||||
|
||||
protected async isOpenshift() {
|
||||
try {
|
||||
const response = await this.k8sRequest("");
|
||||
const response = await this.k8sRequest("") as { paths?: string[] };
|
||||
|
||||
return response.paths?.includes("/apis/project.openshift.io");
|
||||
} catch (e) {
|
||||
|
||||
@@ -17,7 +17,7 @@ export class NodesCountDetector extends BaseClusterDetector {
|
||||
}
|
||||
|
||||
protected async getNodeCount(): Promise<number> {
|
||||
const response = await this.k8sRequest("/api/v1/nodes");
|
||||
const response = await this.k8sRequest("/api/v1/nodes") as { items: unknown[] };
|
||||
|
||||
return response.items.length;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ export class VersionDetector extends BaseClusterDetector {
|
||||
}
|
||||
|
||||
public async getKubernetesVersion() {
|
||||
const response = await this.k8sRequest("/version");
|
||||
const response = await this.k8sRequest("/version") as { gitVersion: string };
|
||||
|
||||
return response.gitVersion;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user