mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Using metrics parser in hpa list and details
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
7f70c49a5c
commit
cb807d843e
@ -17,6 +17,11 @@ export enum HpaMetricType {
|
|||||||
ContainerResource = "ContainerResource",
|
ContainerResource = "ContainerResource",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MetricCurrentTarget {
|
||||||
|
current?: string;
|
||||||
|
target?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface HorizontalPodAutoscalerMetricTarget {
|
export interface HorizontalPodAutoscalerMetricTarget {
|
||||||
kind: string;
|
kind: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import { withInjectables } from "@ogre-tools/injectable-react";
|
|||||||
import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable";
|
import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable";
|
||||||
import getDetailsUrlInjectable from "../kube-detail-params/get-details-url.injectable";
|
import getDetailsUrlInjectable from "../kube-detail-params/get-details-url.injectable";
|
||||||
import loggerInjectable from "../../../common/logger.injectable";
|
import loggerInjectable from "../../../common/logger.injectable";
|
||||||
|
import getHorizontalPodAutoscalerMetrics from "./get-hpa-metrics.injectable";
|
||||||
|
|
||||||
export interface HpaDetailsProps extends KubeObjectDetailsProps<HorizontalPodAutoscaler> {
|
export interface HpaDetailsProps extends KubeObjectDetailsProps<HorizontalPodAutoscaler> {
|
||||||
}
|
}
|
||||||
@ -30,6 +31,7 @@ interface Dependencies {
|
|||||||
apiManager: ApiManager;
|
apiManager: ApiManager;
|
||||||
logger: Logger;
|
logger: Logger;
|
||||||
getDetailsUrl: GetDetailsUrl;
|
getDetailsUrl: GetDetailsUrl;
|
||||||
|
getMetrics: (hpa: HorizontalPodAutoscaler) => string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
@ -70,19 +72,19 @@ class NonInjectedHpaDetails extends React.Component<HpaDetailsProps & Dependenci
|
|||||||
return `Resource ${metricSpec.name} on Pods${addition}`;
|
return `Resource ${metricSpec.name} on Pods${addition}`;
|
||||||
}
|
}
|
||||||
case HpaMetricType.Pods:
|
case HpaMetricType.Pods:
|
||||||
return `${metric.pods.metricName} on Pods`;
|
return `${metric.pods.metricName ?? metric.pods.metric?.name} on Pods`;
|
||||||
|
|
||||||
case HpaMetricType.Object: {
|
case HpaMetricType.Object: {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{metric.object.metricName}
|
{metric.object.metricName || metric.object.metric?.name}
|
||||||
{" "}
|
{" "}
|
||||||
{this.renderTargetLink(metric.object.target)}
|
{this.renderTargetLink(metric.object.describedObject)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case HpaMetricType.External:
|
case HpaMetricType.External:
|
||||||
return `${metric.external.metricName} on ${JSON.stringify(metric.external.metricSelector)}`;
|
return `${metric.external.metricName ?? metric.external.metric?.name} on ${JSON.stringify(metric.external.metricSelector ?? metric.external.metric?.selector)}`;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -93,11 +95,11 @@ class NonInjectedHpaDetails extends React.Component<HpaDetailsProps & Dependenci
|
|||||||
<TableCell className="metrics">Current / Target</TableCell>
|
<TableCell className="metrics">Current / Target</TableCell>
|
||||||
</TableHead>
|
</TableHead>
|
||||||
{
|
{
|
||||||
hpa.getMetrics()
|
this.props.getMetrics(hpa)
|
||||||
.map((metric, index) => (
|
.map((metrics, index) => (
|
||||||
<TableRow key={index}>
|
<TableRow key={index}>
|
||||||
<TableCell className="name">{renderName(metric)}</TableCell>
|
<TableCell className="name">{renderName(hpa.getMetrics()[index])}</TableCell>
|
||||||
<TableCell className="metrics">{hpa.getMetricValues(metric)}</TableCell>
|
<TableCell className="metrics">{metrics}</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -175,5 +177,6 @@ export const HpaDetails = withInjectables<Dependencies, HpaDetailsProps>(NonInje
|
|||||||
apiManager: di.inject(apiManagerInjectable),
|
apiManager: di.inject(apiManagerInjectable),
|
||||||
getDetailsUrl: di.inject(getDetailsUrlInjectable),
|
getDetailsUrl: di.inject(getDetailsUrlInjectable),
|
||||||
logger: di.inject(loggerInjectable),
|
logger: di.inject(loggerInjectable),
|
||||||
|
getMetrics: di.inject(getHorizontalPodAutoscalerMetrics),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -19,6 +19,7 @@ import type { FilterByNamespace } from "../+namespaces/namespace-select-filter-m
|
|||||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
import filterByNamespaceInjectable from "../+namespaces/namespace-select-filter-model/filter-by-namespace.injectable";
|
import filterByNamespaceInjectable from "../+namespaces/namespace-select-filter-model/filter-by-namespace.injectable";
|
||||||
import horizontalPodAutoscalerStoreInjectable from "./store.injectable";
|
import horizontalPodAutoscalerStoreInjectable from "./store.injectable";
|
||||||
|
import getHorizontalPodAutoscalerMetrics from "./get-hpa-metrics.injectable";
|
||||||
|
|
||||||
enum columnId {
|
enum columnId {
|
||||||
name = "name",
|
name = "name",
|
||||||
@ -34,6 +35,7 @@ enum columnId {
|
|||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
horizontalPodAutoscalerStore: HorizontalPodAutoscalerStore;
|
horizontalPodAutoscalerStore: HorizontalPodAutoscalerStore;
|
||||||
filterByNamespace: FilterByNamespace;
|
filterByNamespace: FilterByNamespace;
|
||||||
|
getMetrics: (hpa: HorizontalPodAutoscaler) => string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
@ -49,7 +51,7 @@ class NonInjectedHorizontalPodAutoscalers extends React.Component<Dependencies>
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<p>
|
<p>
|
||||||
{hpa.getMetricValues(metrics[0])}
|
{this.props.getMetrics(hpa)[0]}
|
||||||
{" "}
|
{" "}
|
||||||
{metricsRemain}
|
{metricsRemain}
|
||||||
</p>
|
</p>
|
||||||
@ -126,5 +128,6 @@ export const HorizontalPodAutoscalers = withInjectables<Dependencies>(NonInjecte
|
|||||||
...props,
|
...props,
|
||||||
filterByNamespace: di.inject(filterByNamespaceInjectable),
|
filterByNamespace: di.inject(filterByNamespaceInjectable),
|
||||||
horizontalPodAutoscalerStore: di.inject(horizontalPodAutoscalerStoreInjectable),
|
horizontalPodAutoscalerStore: di.inject(horizontalPodAutoscalerStoreInjectable),
|
||||||
|
getMetrics: di.inject(getHorizontalPodAutoscalerMetrics),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user