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

Show metric name is targetCPUUtilizationPercentage is used

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2023-01-25 14:38:08 +03:00
parent 7cab68b403
commit c14c237a84
2 changed files with 5 additions and 3 deletions

View File

@ -19,8 +19,8 @@ interface Metric extends MetricNames {
type: HpaMetricType;
}
export function getMetricName(metric: Metric): string | undefined {
switch (metric.type) {
export function getMetricName(metric: Metric | undefined): string | undefined {
switch (metric?.type) {
case HpaMetricType.Resource:
return metric.resource?.name;
case HpaMetricType.Pods:

View File

@ -62,7 +62,7 @@ class NonInjectedHpaDetails extends React.Component<HpaDetailsProps & Dependenci
const renderName = (metric: HorizontalPodAutoscalerMetricSpec) => {
const metricName = getMetricName(metric);
switch (metric.type) {
switch (metric?.type) {
case HpaMetricType.ContainerResource:
// fallthrough
@ -85,6 +85,8 @@ class NonInjectedHpaDetails extends React.Component<HpaDetailsProps & Dependenci
}
case HpaMetricType.External:
return `${metricName} on ${JSON.stringify(metric.external.metricSelector ?? metric.external.metric?.selector)}`;
default:
return hpa.spec?.targetCPUUtilizationPercentage ? "CPU Utilization percentage" : "unknown";
}
};