Skip to content

Commit

Permalink
Less hardcoded values
Browse files Browse the repository at this point in the history
  • Loading branch information
dex4er committed Oct 22, 2023
1 parent 4ff49bd commit 0d67f35
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions packages/core/src/common/cluster-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ export enum ClusterMetricsResourceType {
Namespace = "Namespace",
}

/**
* The default filesystem mountpoints for metrics
*/
export const initialFilesystemMountpoints = "/";

/**
* The default node shell image
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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>[] {
Expand Down Expand Up @@ -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 ".*".`}
Expand Down

0 comments on commit 0d67f35

Please sign in to comment.