mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Spreading types to V2 and V2Beta1
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
c2bcbe9edc
commit
fc1aa513f4
@ -28,11 +28,9 @@ export interface HorizontalPodAutoscalerMetricTarget {
|
||||
apiVersion: string;
|
||||
}
|
||||
|
||||
export interface ContainerResourceMetricSource {
|
||||
export interface V2ContainerResourceMetricSource {
|
||||
container: string;
|
||||
name: string;
|
||||
targetAverageUtilization?: number;
|
||||
targetAverageValue?: string;
|
||||
target?: {
|
||||
averageUtilization?: number;
|
||||
averageValue?: string;
|
||||
@ -40,11 +38,20 @@ export interface ContainerResourceMetricSource {
|
||||
};
|
||||
}
|
||||
|
||||
export interface ExternalMetricSource {
|
||||
export interface V2Beta1ContainerResourceMetricSource {
|
||||
container: string;
|
||||
name: string;
|
||||
targetAverageUtilization?: number;
|
||||
targetAverageValue?: string;
|
||||
}
|
||||
|
||||
export type ContainerResourceMetricSource =
|
||||
| V2ContainerResourceMetricSource
|
||||
| V2Beta1ContainerResourceMetricSource;
|
||||
|
||||
export interface V2ExternalMetricSource {
|
||||
metricName?: string;
|
||||
metricSelector?: LabelSelector;
|
||||
targetAverageValue?: string;
|
||||
targetValue?: string;
|
||||
metric?: {
|
||||
name?: string;
|
||||
selector?: LabelSelector;
|
||||
@ -56,13 +63,24 @@ export interface ExternalMetricSource {
|
||||
};
|
||||
}
|
||||
|
||||
export interface ObjectMetricSource {
|
||||
averageValue?: string;
|
||||
export interface V2Beta1ExternalMetricSource {
|
||||
metricName?: string;
|
||||
selector?: LabelSelector;
|
||||
metricSelector?: LabelSelector;
|
||||
targetAverageValue?: string;
|
||||
targetValue?: string;
|
||||
metric?: {
|
||||
selector?: LabelSelector;
|
||||
}
|
||||
}
|
||||
|
||||
export type ExternalMetricSource =
|
||||
| V2Beta1ExternalMetricSource
|
||||
| V2ExternalMetricSource;
|
||||
|
||||
export interface V2ObjectMetricSource {
|
||||
metric?: {
|
||||
name?: string;
|
||||
selector?: LabelSelector;
|
||||
};
|
||||
target?: {
|
||||
type?: string;
|
||||
@ -72,12 +90,22 @@ export interface ObjectMetricSource {
|
||||
describedObject?: CrossVersionObjectReference;
|
||||
}
|
||||
|
||||
export interface PodsMetricSource {
|
||||
export interface V2Beta1ObjectMetricSource {
|
||||
averageValue?: string;
|
||||
metricName?: string;
|
||||
selector?: LabelSelector;
|
||||
targetAverageValue?: string;
|
||||
targetValue?: string;
|
||||
describedObject?: CrossVersionObjectReference;
|
||||
}
|
||||
|
||||
export type ObjectMetricSource =
|
||||
| V2ObjectMetricSource
|
||||
| V2Beta1ObjectMetricSource;
|
||||
|
||||
export interface V2PodsMetricSource {
|
||||
metric?: {
|
||||
name?: string;
|
||||
selector?: LabelSelector;
|
||||
};
|
||||
target?: {
|
||||
averageValue?: string;
|
||||
@ -85,10 +113,18 @@ export interface PodsMetricSource {
|
||||
};
|
||||
}
|
||||
|
||||
export interface ResourceMetricSource {
|
||||
name: string;
|
||||
targetAverageUtilization?: number;
|
||||
export interface V2Beta1PodsMetricSource {
|
||||
metricName?: string;
|
||||
selector?: LabelSelector;
|
||||
targetAverageValue?: string;
|
||||
}
|
||||
|
||||
export type PodsMetricSource =
|
||||
| V2PodsMetricSource
|
||||
| V2Beta1PodsMetricSource;
|
||||
|
||||
export interface V2ResourceMetricSource {
|
||||
name: string;
|
||||
target?: {
|
||||
averageUtilization?: number;
|
||||
averageValue?: string;
|
||||
@ -96,6 +132,16 @@ export interface ResourceMetricSource {
|
||||
};
|
||||
}
|
||||
|
||||
export interface V2Beta1ResourceMetricSource {
|
||||
name: string;
|
||||
targetAverageUtilization?: number;
|
||||
targetAverageValue?: string;
|
||||
}
|
||||
|
||||
export type ResourceMetricSource =
|
||||
| V2ResourceMetricSource
|
||||
| V2Beta1ResourceMetricSource;
|
||||
|
||||
export interface BaseHorizontalPodAutoscalerMetricSpec {
|
||||
containerResource: ContainerResourceMetricSource;
|
||||
external: ExternalMetricSource;
|
||||
@ -132,10 +178,8 @@ interface HPAScalingPolicy {
|
||||
|
||||
type HPAScalingPolicyType = string;
|
||||
|
||||
export interface ContainerResourceMetricStatus {
|
||||
export interface V2ContainerResourceMetricStatus {
|
||||
container?: string;
|
||||
currentAverageUtilization?: number;
|
||||
currentAverageValue?: string;
|
||||
name: string;
|
||||
current?: {
|
||||
averageUtilization?: number;
|
||||
@ -143,11 +187,18 @@ export interface ContainerResourceMetricStatus {
|
||||
};
|
||||
}
|
||||
|
||||
export interface ExternalMetricStatus {
|
||||
export interface V2Beta1ContainerResourceMetricStatus {
|
||||
container?: string;
|
||||
currentAverageUtilization?: number;
|
||||
currentAverageValue?: string;
|
||||
currentValue?: string;
|
||||
metricName?: string;
|
||||
metricSelector?: LabelSelector;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export type ContainerResourceMetricStatus =
|
||||
| V2ContainerResourceMetricStatus
|
||||
| V2Beta1ContainerResourceMetricStatus;
|
||||
|
||||
export interface V2ExternalMetricStatus {
|
||||
metric?: {
|
||||
name?: string;
|
||||
selector?: LabelSelector;
|
||||
@ -158,11 +209,18 @@ export interface ExternalMetricStatus {
|
||||
};
|
||||
}
|
||||
|
||||
export interface ObjectMetricStatus {
|
||||
averageValue?: string;
|
||||
export interface V2Beta1ExternalMetricStatus {
|
||||
currentAverageValue?: string;
|
||||
currentValue?: string;
|
||||
metricName?: string;
|
||||
selector?: LabelSelector;
|
||||
metricSelector?: LabelSelector;
|
||||
}
|
||||
|
||||
export type ExternalMetricStatus =
|
||||
| V2Beta1ExternalMetricStatus
|
||||
| V2ExternalMetricStatus;
|
||||
|
||||
export interface V2ObjectMetricStatus {
|
||||
metric?: {
|
||||
name?: string;
|
||||
selector?: LabelSelector;
|
||||
@ -175,21 +233,40 @@ export interface ObjectMetricStatus {
|
||||
describedObject?: CrossVersionObjectReference;
|
||||
}
|
||||
|
||||
export interface PodsMetricStatus {
|
||||
currentAverageValue?: string;
|
||||
export interface V2Beta1ObjectMetricStatus {
|
||||
averageValue?: string;
|
||||
currentValue?: string;
|
||||
metricName?: string;
|
||||
selector?: LabelSelector;
|
||||
describedObject?: CrossVersionObjectReference;
|
||||
}
|
||||
|
||||
export type ObjectMetricStatus =
|
||||
| V2Beta1ObjectMetricStatus
|
||||
| V2ObjectMetricStatus;
|
||||
|
||||
export interface V2PodsMetricStatus {
|
||||
selector?: LabelSelector;
|
||||
metric?: {
|
||||
name?: string;
|
||||
selector?: LabelSelector;
|
||||
};
|
||||
current?: {
|
||||
averageValue?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ResourceMetricStatus {
|
||||
currentAverageUtilization?: number;
|
||||
export interface V2Beta1PodsMetricStatus {
|
||||
currentAverageValue?: string;
|
||||
metricName?: string;
|
||||
selector?: LabelSelector;
|
||||
}
|
||||
|
||||
export type PodsMetricStatus =
|
||||
| V2Beta1PodsMetricStatus
|
||||
| V2PodsMetricStatus;
|
||||
|
||||
export interface V2ResourceMetricStatus {
|
||||
name: string;
|
||||
current?: {
|
||||
averageUtilization?: number;
|
||||
@ -197,6 +274,16 @@ export interface ResourceMetricStatus {
|
||||
};
|
||||
}
|
||||
|
||||
export interface V2Beta1ResourceMetricStatus {
|
||||
currentAverageUtilization?: number;
|
||||
currentAverageValue?: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export type ResourceMetricStatus =
|
||||
| V2Beta1ResourceMetricStatus
|
||||
| V2ResourceMetricStatus;
|
||||
|
||||
export interface BaseHorizontalPodAutoscalerMetricStatus {
|
||||
containerResource: ContainerResourceMetricStatus;
|
||||
external: ExternalMetricStatus;
|
||||
|
||||
@ -2,10 +2,10 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { ContainerResourceMetricSource, ContainerResourceMetricStatus, ExternalMetricSource, ExternalMetricStatus, MetricCurrentTarget, ObjectMetricSource, ObjectMetricStatus, PodsMetricSource, PodsMetricStatus, ResourceMetricSource, ResourceMetricStatus } from "../../../common/k8s-api/endpoints";
|
||||
import type { MetricCurrentTarget, V2Beta1ContainerResourceMetricSource, V2Beta1ContainerResourceMetricStatus, V2Beta1ExternalMetricSource, V2Beta1ExternalMetricStatus, V2Beta1ObjectMetricSource, V2Beta1ObjectMetricStatus, V2Beta1PodsMetricSource, V2Beta1PodsMetricStatus, V2Beta1ResourceMetricSource, V2Beta1ResourceMetricStatus } from "../../../common/k8s-api/endpoints";
|
||||
|
||||
export class HorizontalPodAutoscalerV1MetricParser {
|
||||
public getResource({ current, target }: { current: ResourceMetricStatus | undefined; target: ResourceMetricSource }): MetricCurrentTarget {
|
||||
public getResource({ current, target }: { current: V2Beta1ResourceMetricStatus | undefined; target: V2Beta1ResourceMetricSource }): MetricCurrentTarget {
|
||||
return {
|
||||
current: (
|
||||
typeof current?.currentAverageUtilization === "number"
|
||||
@ -20,14 +20,14 @@ export class HorizontalPodAutoscalerV1MetricParser {
|
||||
};
|
||||
}
|
||||
|
||||
public getPods({ current, target }: { current: PodsMetricStatus | undefined; target: PodsMetricSource }): MetricCurrentTarget {
|
||||
public getPods({ current, target }: { current: V2Beta1PodsMetricStatus | undefined; target: V2Beta1PodsMetricSource }): MetricCurrentTarget {
|
||||
return {
|
||||
current: current?.currentAverageValue,
|
||||
target: target?.targetAverageValue,
|
||||
};
|
||||
}
|
||||
|
||||
public getObject({ current, target }: { current: ObjectMetricStatus | undefined; target: ObjectMetricSource }): MetricCurrentTarget {
|
||||
public getObject({ current, target }: { current: V2Beta1ObjectMetricStatus | undefined; target: V2Beta1ObjectMetricSource }): MetricCurrentTarget {
|
||||
return {
|
||||
current: (
|
||||
current?.currentValue
|
||||
@ -40,7 +40,7 @@ export class HorizontalPodAutoscalerV1MetricParser {
|
||||
};
|
||||
}
|
||||
|
||||
public getExternal({ current, target }: { current: ExternalMetricStatus | undefined; target: ExternalMetricSource }): MetricCurrentTarget {
|
||||
public getExternal({ current, target }: { current: V2Beta1ExternalMetricStatus | undefined; target: V2Beta1ExternalMetricSource }): MetricCurrentTarget {
|
||||
return {
|
||||
current: (
|
||||
current?.currentValue
|
||||
@ -53,7 +53,7 @@ export class HorizontalPodAutoscalerV1MetricParser {
|
||||
};
|
||||
}
|
||||
|
||||
public getContainerResource({ current, target }: { current: ContainerResourceMetricStatus | undefined; target: ContainerResourceMetricSource }): MetricCurrentTarget {
|
||||
public getContainerResource({ current, target }: { current: V2Beta1ContainerResourceMetricStatus | undefined; target: V2Beta1ContainerResourceMetricSource }): MetricCurrentTarget {
|
||||
return {
|
||||
current: (
|
||||
typeof current?.currentAverageUtilization === "number"
|
||||
|
||||
@ -2,10 +2,10 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { ContainerResourceMetricSource, ContainerResourceMetricStatus, ExternalMetricSource, ExternalMetricStatus, MetricCurrentTarget, ObjectMetricSource, ObjectMetricStatus, PodsMetricSource, PodsMetricStatus, ResourceMetricSource, ResourceMetricStatus } from "../../../common/k8s-api/endpoints";
|
||||
import type { MetricCurrentTarget, V2ContainerResourceMetricSource, V2ContainerResourceMetricStatus, V2ExternalMetricSource, V2ExternalMetricStatus, V2ObjectMetricSource, V2ObjectMetricStatus, V2PodsMetricSource, V2PodsMetricStatus, V2ResourceMetricSource, V2ResourceMetricStatus } from "../../../common/k8s-api/endpoints";
|
||||
|
||||
export class HorizontalPodAutoscalerV2MetricParser {
|
||||
public getResource({ current, target }: { current: ResourceMetricStatus | undefined; target: ResourceMetricSource }): MetricCurrentTarget {
|
||||
public getResource({ current, target }: { current: V2ResourceMetricStatus | undefined; target: V2ResourceMetricSource }): MetricCurrentTarget {
|
||||
return {
|
||||
current: (
|
||||
typeof current?.current?.averageUtilization === "number"
|
||||
@ -18,14 +18,14 @@ export class HorizontalPodAutoscalerV2MetricParser {
|
||||
};
|
||||
}
|
||||
|
||||
public getPods({ current, target }: { current: PodsMetricStatus | undefined; target: PodsMetricSource }): MetricCurrentTarget {
|
||||
public getPods({ current, target }: { current: V2PodsMetricStatus | undefined; target: V2PodsMetricSource }): MetricCurrentTarget {
|
||||
return {
|
||||
current: current?.current?.averageValue,
|
||||
target: target?.target?.averageValue,
|
||||
};
|
||||
}
|
||||
|
||||
public getObject({ current, target }: { current: ObjectMetricStatus | undefined; target: ObjectMetricSource }): MetricCurrentTarget {
|
||||
public getObject({ current, target }: { current: V2ObjectMetricStatus | undefined; target: V2ObjectMetricSource }): MetricCurrentTarget {
|
||||
return {
|
||||
current: (
|
||||
current?.current?.value
|
||||
@ -38,7 +38,7 @@ export class HorizontalPodAutoscalerV2MetricParser {
|
||||
};
|
||||
}
|
||||
|
||||
public getExternal({ current, target }: { current: ExternalMetricStatus | undefined; target: ExternalMetricSource }): MetricCurrentTarget {
|
||||
public getExternal({ current, target }: { current: V2ExternalMetricStatus | undefined; target: V2ExternalMetricSource }): MetricCurrentTarget {
|
||||
const currentAverage = current?.current?.averageValue ? `${current?.current?.averageValue} (avg)` : undefined;
|
||||
const targetAverage = target?.target?.averageValue ? `${target?.target?.averageValue} (avg)` : undefined;
|
||||
|
||||
@ -54,7 +54,7 @@ export class HorizontalPodAutoscalerV2MetricParser {
|
||||
};
|
||||
}
|
||||
|
||||
public getContainerResource({ current, target }: { current: ContainerResourceMetricStatus | undefined; target: ContainerResourceMetricSource }): MetricCurrentTarget {
|
||||
public getContainerResource({ current, target }: { current: V2ContainerResourceMetricStatus | undefined; target: V2ContainerResourceMetricSource }): MetricCurrentTarget {
|
||||
return {
|
||||
current: (
|
||||
current?.current?.averageValue
|
||||
|
||||
Loading…
Reference in New Issue
Block a user