1
0
mirror of https://github.com/lensapp/lens.git synced 2024-09-11 09:25:26 +03:00

Less hardcoded values

Signed-off-by: Piotr Roszatycki <piotr.roszatycki@gmail.com>
This commit is contained in:
Piotr Roszatycki 2023-10-22 11:50:38 +02:00
parent 4ff49bdbd7
commit dbad7bbdc9
3 changed files with 10 additions and 3 deletions

View File

@ -175,6 +175,11 @@ export enum ClusterMetricsResourceType {
Namespace = "Namespace",
}
/**
* The default filesystem mountpoints for metrics
*/
export const initialFilesystemMountpoints = "/";
/**
* The default node shell image
*/

View File

@ -6,7 +6,7 @@
import { apiPrefix } from "../../../common/vars";
import { getRouteInjectable } from "../../router/router.injectable";
import type { ClusterPrometheusMetadata } from "../../../common/cluster-types";
import { ClusterMetadataKey } from "../../../common/cluster-types";
import { ClusterMetadataKey, initialFilesystemMountpoints } from "../../../common/cluster-types";
import type { Cluster } from "../../../common/cluster/cluster";
import { clusterRoute } from "../../router/route";
import { isObject } from "lodash";
@ -69,7 +69,7 @@ const addMetricsRouteInjectable = getRouteInjectable({
const queryParams: Partial<Record<string, string>> = Object.fromEntries(query.entries());
const prometheusMetadata: ClusterPrometheusMetadata = {};
const prometheusHandler = di.inject(prometheusHandlerInjectable, cluster);
const mountpoints = cluster.preferences.filesystemMountpoints || "/";
const mountpoints = cluster.preferences.filesystemMountpoints || initialFilesystemMountpoints;
try {
const { prometheusPath, provider } = await prometheusHandler.getPrometheusDetails();

View File

@ -6,6 +6,7 @@
import React from "react";
import { observer, disposeOnUnmount } from "mobx-react";
import type { Cluster } from "../../../common/cluster/cluster";
import { initialFilesystemMountpoints } from "../../../common/cluster-types";
import { SubTitle } from "../layout/sub-title";
import type { SelectOption } from "../select";
import { Select } from "../select";
@ -36,6 +37,7 @@ class NonInjectedClusterPrometheusSetting extends React.Component<ClusterPrometh
@observable path = "";
@observable selectedOption: ProviderValue = autoDetectPrometheus;
@observable loading = true;
readonly initialFilesystemMountpoints = initialFilesystemMountpoints;
readonly loadedOptions = observable.map<string, MetricProviderInfo>();
@computed get options(): SelectOption<ProviderValue>[] {
@ -183,7 +185,7 @@ class NonInjectedClusterPrometheusSetting extends React.Component<ClusterPrometh
value={this.mountpoints}
onChange={(value) => this.mountpoints = value}
onBlur={this.onSaveMountpoints}
placeholder="/"
placeholder={this.initialFilesystemMountpoints}
/>
<small className="hint">
{`A regexp for the label with the filesystem mountpoints that will create a graph for disk usage. For the root disk only use "/" and for all disks use ".*".`}