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

Fix type errors

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-11-07 14:21:05 -05:00
parent d173e45177
commit b96e115e17
4 changed files with 12 additions and 11 deletions

View File

@ -17,7 +17,6 @@ import plimit from "p-limit";
import type { ClusterState, ClusterMetricsResourceType, ClusterId, ClusterMetadata, ClusterModel, ClusterPreferences, ClusterPrometheusPreferences, UpdateClusterModel, KubeAuthUpdate, ClusterConfigData } from "../cluster-types"; import type { ClusterState, ClusterMetricsResourceType, ClusterId, ClusterMetadata, ClusterModel, ClusterPreferences, ClusterPrometheusPreferences, UpdateClusterModel, KubeAuthUpdate, ClusterConfigData } from "../cluster-types";
import { ClusterMetadataKey, initialNodeShellImage, ClusterStatus, clusterModelIdChecker, updateClusterModelChecker } from "../cluster-types"; import { ClusterMetadataKey, initialNodeShellImage, ClusterStatus, clusterModelIdChecker, updateClusterModelChecker } from "../cluster-types";
import { disposer, isDefined, isRequestError, toJS } from "../utils"; import { disposer, isDefined, isRequestError, toJS } from "../utils";
import type { Response } from "request";
import { clusterListNamespaceForbiddenChannel } from "../ipc/cluster"; import { clusterListNamespaceForbiddenChannel } from "../ipc/cluster";
import type { CanI } from "./authorization-review.injectable"; import type { CanI } from "./authorization-review.injectable";
import type { ListNamespacesFor } from "./list-namespaces.injectable"; import type { ListNamespacesFor } from "./list-namespaces.injectable";
@ -652,7 +651,7 @@ export class Cluster implements ClusterModel {
const namespaceList = [ctx?.namespace].filter(isDefined); const namespaceList = [ctx?.namespace].filter(isDefined);
if (namespaceList.length === 0 && error instanceof HttpError && error.statusCode === 403) { if (namespaceList.length === 0 && error instanceof HttpError && error.statusCode === 403) {
const { response } = error as HttpError & { response: Response }; const { response } = error as HttpError & { response: { body: unknown }};
this.dependencies.logger.info("[CLUSTER]: listing namespaces is forbidden, broadcasting", { clusterId: this.id, error: response.body }); this.dependencies.logger.info("[CLUSTER]: listing namespaces is forbidden, broadcasting", { clusterId: this.id, error: response.body });
this.dependencies.broadcastMessage(clusterListNamespaceForbiddenChannel, this.id); this.dependencies.broadcastMessage(clusterListNamespaceForbiddenChannel, this.id);

View File

@ -3,6 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import FormData from "form-data";
import type { Cluster } from "../common/cluster/cluster"; import type { Cluster } from "../common/cluster/cluster";
import type { RequestMetricsParams } from "../common/k8s-api/endpoints/metrics.api/request-metrics.injectable"; import type { RequestMetricsParams } from "../common/k8s-api/endpoints/metrics.api/request-metrics.injectable";
import k8sRequestInjectable from "./k8s-request.injectable"; import k8sRequestInjectable from "./k8s-request.injectable";
@ -22,13 +23,16 @@ const getMetricsInjectable = getInjectable({
) => { ) => {
const prometheusPrefix = cluster.preferences.prometheus?.prefix || ""; const prometheusPrefix = cluster.preferences.prometheus?.prefix || "";
const metricsPath = `/api/v1/namespaces/${prometheusPath}/proxy${prometheusPrefix}/api/v1/query_range`; const metricsPath = `/api/v1/namespaces/${prometheusPath}/proxy${prometheusPrefix}/api/v1/query_range`;
const body = new FormData();
for (const [key, value] of Object.entries(queryParams)) {
body.append(key, value);
}
return k8sRequest(cluster, metricsPath, { return k8sRequest(cluster, metricsPath, {
timeout: 0, timeout: 0,
resolveWithFullResponse: false,
json: true,
method: "POST", method: "POST",
form: queryParams, body,
}); });
}; };
}, },

View File

@ -4,6 +4,7 @@
*/ */
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import { beforeQuitOfBackEndInjectionToken } from "../start-main-application/runnable-tokens/before-quit-of-back-end-injection-token"; import { beforeQuitOfBackEndInjectionToken } from "../start-main-application/runnable-tokens/before-quit-of-back-end-injection-token";
import stopSettingUpLensProxyInjectable from "../start-main-application/runnables/lens-proxy/teardown.injectable";
import lensProxyInjectable from "./lens-proxy.injectable"; import lensProxyInjectable from "./lens-proxy.injectable";
const stopLensProxyOnQuitInjectable = getInjectable({ const stopLensProxyOnQuitInjectable = getInjectable({
@ -13,9 +14,8 @@ const stopLensProxyOnQuitInjectable = getInjectable({
return { return {
id: "stop-lens-proxy", id: "stop-lens-proxy",
run: () => { run: () => void lensProxy.close(),
lensProxy.close(); runAfter: di.inject(stopSettingUpLensProxyInjectable),
},
}; };
}, },
injectionToken: beforeQuitOfBackEndInjectionToken, injectionToken: beforeQuitOfBackEndInjectionToken,

View File

@ -13,9 +13,7 @@ const stopSettingUpLensProxyInjectable = getInjectable({
return { return {
id: "stop-setting-up-lens-proxy", id: "stop-setting-up-lens-proxy",
run: () => { run: () => void setupLensProxyStartableStoppable.stop(),
setupLensProxyStartableStoppable.stop();
},
}; };
}, },
injectionToken: beforeQuitOfBackEndInjectionToken, injectionToken: beforeQuitOfBackEndInjectionToken,