1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use super::*;

pub trait MetricExt {
    fn container_resource(source: autoscalingv2::ContainerResourceMetricSource) -> Self;
    fn external(source: autoscalingv2::ExternalMetricSource) -> Self;
    fn object(source: autoscalingv2::ObjectMetricSource) -> Self;
    fn pods(source: autoscalingv2::PodsMetricSource) -> Self;
    fn resource(source: autoscalingv2::ResourceMetricSource) -> Self;
}

impl MetricExt for autoscalingv2::MetricSpec {
    fn container_resource(source: autoscalingv2::ContainerResourceMetricSource) -> Self {
        Self {
            container_resource: Some(source),
            type_: String::from("ContainerResource"),
            ..default()
        }
    }

    fn external(source: autoscalingv2::ExternalMetricSource) -> Self {
        Self {
            external: Some(source),
            type_: String::from("External"),
            ..default()
        }
    }

    fn object(source: autoscalingv2::ObjectMetricSource) -> Self {
        Self {
            object: Some(source),
            type_: String::from("Object"),
            ..default()
        }
    }

    fn pods(source: autoscalingv2::PodsMetricSource) -> Self {
        Self {
            pods: Some(source),
            type_: String::from("Pods"),
            ..default()
        }
    }

    fn resource(source: autoscalingv2::ResourceMetricSource) -> Self {
        Self {
            resource: Some(source),
            type_: String::from("Resource"),
            ..default()
        }
    }
}