mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Adding test cases for autoscaling/v1 metrics
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
1 parent
8d8993798e
commit
9dc0eb55d7
2 files changed
+466
-3
No files matched your search
@@ -1,11 +1,13 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { HorizontalPodAutoscaler, HorizontalPodAutoscalerMetricSpec, HorizontalPodAutoscalerMetricStatus, HpaMetricType } from "../../../common/k8s-api/endpoints";
|
||||
import horizonalPodAutoscalerV1MetricParser from "./hpa-v1-metric-parser.injectable";
|
||||
import type { HorizontalPodAutoscalerV2MetricParser } from "./hpa-v2-metric-parser";
|
||||
import horizonalPodAutoscalerV2MetricParser from "./hpa-v2-metric-parser.injectable";
|
||||
|
||||
const getHorizontalPodAutoscalerMetrics = getInjectable({
|
||||
id: "get-horizontal-pod-autoscaler-metrics",
|
||||
instantiate: (di) => (hpa: HorizontalPodAutoscaler) => {
|
||||
const hpaV1Parser = di.inject(horizonalPodAutoscalerV1MetricParser);
|
||||
const hpaV2Parser = di.inject(horizonalPodAutoscalerV2MetricParser);
|
||||
const metrics = hpa.spec?.metrics ?? [];
|
||||
const currentMetrics = hpa.status?.currentMetrics ?? [];
|
||||
@@ -15,7 +17,7 @@ const getHorizontalPodAutoscalerMetrics = getInjectable({
|
||||
current.type === metric.type
|
||||
&& getMetricName(current) === getMetricName(metric)
|
||||
);
|
||||
const parser = hpa.apiVersion.includes("v2") ? hpaV2Parser : hpaV2Parser;
|
||||
const parser = hpa.apiVersion.includes("v2") ? hpaV2Parser : hpaV1Parser;
|
||||
|
||||
const values = getMetricValues(parser, currentMetric, metric);
|
||||
|
||||
|
||||
Reference in new issue
Block a user