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

split out ??= for headers

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2020-11-16 09:25:52 -05:00
parent 12f7834af1
commit a7f7ea2473

View File

@ -86,7 +86,7 @@ export class Cluster implements ClusterModel, ClusterState {
} }
get version(): string { get version(): string {
return String(this.metadata?.version) || "" return String(this.metadata?.version) || ""
} }
constructor(model: ClusterModel) { constructor(model: ClusterModel) {
@ -149,7 +149,7 @@ export class Cluster implements ClusterModel, ClusterState {
} }
@action @action
async activate(force = false ) { async activate(force = false) {
if (this.activated && !force) { if (this.activated && !force) {
return this.pushState(); return this.pushState();
} }
@ -252,12 +252,12 @@ export class Cluster implements ClusterModel, ClusterState {
} }
protected async k8sRequest<T = any>(path: string, options: RequestPromiseOptions = {}): Promise<T> { protected async k8sRequest<T = any>(path: string, options: RequestPromiseOptions = {}): Promise<T> {
(options.headers ??= {}).Host = `${this.id}.${new URL(this.kubeProxyUrl).host}` // required in ClusterManager.getClusterForRequest() options.headers ??= {}
options.json ??= true options.json ??= true
options.timeout ??= 30000 options.timeout ??= 30000
options.headers.Host = `${this.id}.${new URL(this.kubeProxyUrl).host}` // required in ClusterManager.getClusterForRequest()
const apiUrl = this.kubeProxyUrl + path; return request(this.kubeProxyUrl + path, options)
return request(apiUrl, options)
} }
getMetrics(prometheusPath: string, queryParams: IMetricsReqParams & { query: string }) { getMetrics(prometheusPath: string, queryParams: IMetricsReqParams & { query: string }) {