cleanup main side of metrics route for readability (#988)

* cleanup main side of metrics route for readability

* split out ??= for headers

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2020-11-16 10:43:53 -05:00
1 parent 9d6158a620
commit 25be6401e2
2 files changed
+61 -64

No files matched your search

+6 -10
View File
@@ -253,16 +253,12 @@ export class Cluster implements ClusterModel, ClusterState {
}
protected async k8sRequest<T = any>(path: string, options: RequestPromiseOptions = {}): Promise<T> {
const apiUrl = this.kubeProxyUrl + path;
return request(apiUrl, {
json: true,
timeout: 30000,
...options,
headers: {
Host: `${this.id}.${new URL(this.kubeProxyUrl).host}`, // required in ClusterManager.getClusterForRequest()
...(options.headers || {}),
},
})
options.headers ??= {}
options.json ??= true
options.timeout ??= 30000
options.headers.Host = `${this.id}.${new URL(this.kubeProxyUrl).host}` // required in ClusterManager.getClusterForRequest()
return request(this.kubeProxyUrl + path, options)
}
getMetrics(prometheusPath: string, queryParams: IMetricsReqParams & { query: string }) {