Skip to content

Commit dbad7bb

Browse files
committed
Less hardcoded values
Signed-off-by: Piotr Roszatycki <[email protected]>
1 parent 4ff49bd commit dbad7bb

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

packages/core/src/common/cluster-types.ts

+5
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ export enum ClusterMetricsResourceType {
175175
Namespace = "Namespace",
176176
}
177177

178+
/**
179+
* The default filesystem mountpoints for metrics
180+
*/
181+
export const initialFilesystemMountpoints = "/";
182+
178183
/**
179184
* The default node shell image
180185
*/

packages/core/src/main/routes/metrics/add-metrics-route.injectable.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { apiPrefix } from "../../../common/vars";
77
import { getRouteInjectable } from "../../router/router.injectable";
88
import type { ClusterPrometheusMetadata } from "../../../common/cluster-types";
9-
import { ClusterMetadataKey } from "../../../common/cluster-types";
9+
import { ClusterMetadataKey, initialFilesystemMountpoints } from "../../../common/cluster-types";
1010
import type { Cluster } from "../../../common/cluster/cluster";
1111
import { clusterRoute } from "../../router/route";
1212
import { isObject } from "lodash";
@@ -69,7 +69,7 @@ const addMetricsRouteInjectable = getRouteInjectable({
6969
const queryParams: Partial<Record<string, string>> = Object.fromEntries(query.entries());
7070
const prometheusMetadata: ClusterPrometheusMetadata = {};
7171
const prometheusHandler = di.inject(prometheusHandlerInjectable, cluster);
72-
const mountpoints = cluster.preferences.filesystemMountpoints || "/";
72+
const mountpoints = cluster.preferences.filesystemMountpoints || initialFilesystemMountpoints;
7373

7474
try {
7575
const { prometheusPath, provider } = await prometheusHandler.getPrometheusDetails();

packages/core/src/renderer/components/cluster-settings/prometheus-setting.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import React from "react";
77
import { observer, disposeOnUnmount } from "mobx-react";
88
import type { Cluster } from "../../../common/cluster/cluster";
9+
import { initialFilesystemMountpoints } from "../../../common/cluster-types";
910
import { SubTitle } from "../layout/sub-title";
1011
import type { SelectOption } from "../select";
1112
import { Select } from "../select";
@@ -36,6 +37,7 @@ class NonInjectedClusterPrometheusSetting extends React.Component<ClusterPrometh
3637
@observable path = "";
3738
@observable selectedOption: ProviderValue = autoDetectPrometheus;
3839
@observable loading = true;
40+
readonly initialFilesystemMountpoints = initialFilesystemMountpoints;
3941
readonly loadedOptions = observable.map<string, MetricProviderInfo>();
4042

4143
@computed get options(): SelectOption<ProviderValue>[] {
@@ -183,7 +185,7 @@ class NonInjectedClusterPrometheusSetting extends React.Component<ClusterPrometh
183185
value={this.mountpoints}
184186
onChange={(value) => this.mountpoints = value}
185187
onBlur={this.onSaveMountpoints}
186-
placeholder="/"
188+
placeholder={this.initialFilesystemMountpoints}
187189
/>
188190
<small className="hint">
189191
{`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 ".*".`}

0 commit comments

Comments
 (0)