1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/main/cluster-detectors/base-cluster-detector.ts
Alex Andreev 2cd5e129f1 Revert "Use @typescript-eslint/semi."
This reverts commit 890fa5dd9e.
2020-11-20 07:51:42 +03:00

33 lines
862 B
TypeScript

import request, { RequestPromiseOptions } from "request-promise-native";
import { Cluster } from "../cluster";
export type ClusterDetectionResult = {
value: string | number | boolean
accuracy: number
}
export class BaseClusterDetector {
cluster: Cluster
key: string
constructor(cluster: Cluster) {
this.cluster = cluster;
}
detect(): Promise<ClusterDetectionResult> {
return null;
}
protected async k8sRequest<T = any>(path: string, options: RequestPromiseOptions = {}): Promise<T> {
const apiUrl = this.cluster.kubeProxyUrl + path;
return request(apiUrl, {
json: true,
timeout: 30000,
...options,
headers: {
Host: `${this.cluster.id}.${new URL(this.cluster.kubeProxyUrl).host}`, // required in ClusterManager.getClusterForRequest()
...(options.headers || {}),
},
});
}
}