k8s_openapi_ext/ext/
metric.rs

1use super::*;
2
3pub trait MetricExt {
4    fn container_resource(source: autoscalingv2::ContainerResourceMetricSource) -> Self;
5    fn external(source: autoscalingv2::ExternalMetricSource) -> Self;
6    fn object(source: autoscalingv2::ObjectMetricSource) -> Self;
7    fn pods(source: autoscalingv2::PodsMetricSource) -> Self;
8    fn resource(source: autoscalingv2::ResourceMetricSource) -> Self;
9}
10
11impl MetricExt for autoscalingv2::MetricSpec {
12    fn container_resource(source: autoscalingv2::ContainerResourceMetricSource) -> Self {
13        Self {
14            container_resource: Some(source),
15            type_: String::from("ContainerResource"),
16            ..default()
17        }
18    }
19
20    fn external(source: autoscalingv2::ExternalMetricSource) -> Self {
21        Self {
22            external: Some(source),
23            type_: String::from("External"),
24            ..default()
25        }
26    }
27
28    fn object(source: autoscalingv2::ObjectMetricSource) -> Self {
29        Self {
30            object: Some(source),
31            type_: String::from("Object"),
32            ..default()
33        }
34    }
35
36    fn pods(source: autoscalingv2::PodsMetricSource) -> Self {
37        Self {
38            pods: Some(source),
39            type_: String::from("Pods"),
40            ..default()
41        }
42    }
43
44    fn resource(source: autoscalingv2::ResourceMetricSource) -> Self {
45        Self {
46            resource: Some(source),
47            type_: String::from("Resource"),
48            ..default()
49        }
50    }
51}