mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-27 21:26:03 +00:00
Update autoscaling conversion and validation for v2beta2 inclusion
This commit is contained in:
@@ -39,6 +39,7 @@ filegroup(
|
||||
"//pkg/apis/autoscaling/install:all-srcs",
|
||||
"//pkg/apis/autoscaling/v1:all-srcs",
|
||||
"//pkg/apis/autoscaling/v2beta1:all-srcs",
|
||||
"//pkg/apis/autoscaling/v2beta2:all-srcs",
|
||||
"//pkg/apis/autoscaling/validation:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
|
@@ -52,19 +52,28 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
|
||||
}
|
||||
|
||||
targetUtilization := int32(c.RandUint64())
|
||||
averageValue := randomQuantity()
|
||||
s.Metrics = []autoscaling.MetricSpec{
|
||||
{
|
||||
Type: autoscaling.PodsMetricSourceType,
|
||||
Pods: &autoscaling.PodsMetricSource{
|
||||
MetricName: c.RandString(),
|
||||
TargetAverageValue: randomQuantity(),
|
||||
Metric: autoscaling.MetricIdentifier{
|
||||
Name: c.RandString(),
|
||||
},
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.AverageValueMetricType,
|
||||
AverageValue: &averageValue,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: autoscaling.ResourceMetricSourceType,
|
||||
Resource: &autoscaling.ResourceMetricSource{
|
||||
Name: api.ResourceCPU,
|
||||
TargetAverageUtilization: &targetUtilization,
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.UtilizationMetricType,
|
||||
AverageUtilization: &targetUtilization,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -78,20 +87,28 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
|
||||
_ = q.String()
|
||||
return q
|
||||
}
|
||||
averageValue := randomQuantity()
|
||||
currentUtilization := int32(c.RandUint64())
|
||||
s.CurrentMetrics = []autoscaling.MetricStatus{
|
||||
{
|
||||
Type: autoscaling.PodsMetricSourceType,
|
||||
Pods: &autoscaling.PodsMetricStatus{
|
||||
MetricName: c.RandString(),
|
||||
CurrentAverageValue: randomQuantity(),
|
||||
Metric: autoscaling.MetricIdentifier{
|
||||
Name: c.RandString(),
|
||||
},
|
||||
Current: autoscaling.MetricValueStatus{
|
||||
AverageValue: &averageValue,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: autoscaling.ResourceMetricSourceType,
|
||||
Resource: &autoscaling.ResourceMetricStatus{
|
||||
Name: api.ResourceCPU,
|
||||
CurrentAverageUtilization: ¤tUtilization,
|
||||
Current: autoscaling.MetricValueStatus{
|
||||
AverageUtilization: ¤tUtilization,
|
||||
AverageValue: &averageValue,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@@ -1,19 +1,16 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["install.go"],
|
||||
importpath = "k8s.io/kubernetes/pkg/apis/autoscaling/install",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/api/legacyscheme:go_default_library",
|
||||
"//pkg/apis/autoscaling:go_default_library",
|
||||
"//pkg/apis/autoscaling/v1:go_default_library",
|
||||
"//pkg/apis/autoscaling/v2beta1:go_default_library",
|
||||
"//pkg/apis/autoscaling/v2beta2:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
||||
],
|
||||
@@ -30,4 +27,5 @@ filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
@@ -25,6 +25,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling/v1"
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling/v2beta1"
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling/v2beta2"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -34,7 +35,8 @@ func init() {
|
||||
// Install registers the API group and adds types to a scheme
|
||||
func Install(scheme *runtime.Scheme) {
|
||||
utilruntime.Must(autoscaling.AddToScheme(scheme))
|
||||
utilruntime.Must(v2beta2.AddToScheme(scheme))
|
||||
utilruntime.Must(v2beta1.AddToScheme(scheme))
|
||||
utilruntime.Must(v1.AddToScheme(scheme))
|
||||
utilruntime.Must(scheme.SetVersionPriority(v1.SchemeGroupVersion, v2beta1.SchemeGroupVersion))
|
||||
utilruntime.Must(scheme.SetVersionPriority(v1.SchemeGroupVersion, v2beta1.SchemeGroupVersion, v2beta2.SchemeGroupVersion))
|
||||
}
|
||||
|
@@ -251,6 +251,7 @@ type HorizontalPodAutoscalerStatus struct {
|
||||
DesiredReplicas int32
|
||||
|
||||
// CurrentMetrics is the last read state of the metrics used by this autoscaler.
|
||||
// +optional
|
||||
CurrentMetrics []MetricStatus
|
||||
|
||||
// Conditions is the set of conditions required for this autoscaler to scale its target,
|
||||
@@ -343,6 +344,8 @@ type MetricStatus struct {
|
||||
type ObjectMetricStatus struct {
|
||||
Metric MetricIdentifier
|
||||
Current MetricValueStatus
|
||||
|
||||
DescribedObject CrossVersionObjectReference
|
||||
}
|
||||
|
||||
// PodsMetricStatus indicates the current value of a metric describing each pod in
|
||||
@@ -359,19 +362,8 @@ type PodsMetricStatus struct {
|
||||
// normal per-pod metrics using the "pods" source.
|
||||
type ResourceMetricStatus struct {
|
||||
// Name is the name of the resource in question.
|
||||
Name api.ResourceName
|
||||
// CurrentAverageUtilization is the current value of the average of the
|
||||
// resource metric across all relevant pods, represented as a percentage of
|
||||
// the requested value of the resource for the pods. It will only be
|
||||
// present if `targetAverageValue` was set in the corresponding metric
|
||||
// specification.
|
||||
// +optional
|
||||
CurrentAverageUtilization *int32
|
||||
// CurrentAverageValue is the current value of the average of the
|
||||
// resource metric across all relevant pods, as a raw value (instead of as
|
||||
// a percentage of the request), similar to the "pods" metric source type.
|
||||
// It will always be set, regardless of the corresponding metric specification.
|
||||
CurrentAverageValue resource.Quantity
|
||||
Name api.ResourceName
|
||||
Current MetricValueStatus
|
||||
}
|
||||
|
||||
// ExternalMetricStatus indicates the current value of a global metric
|
||||
|
@@ -1,10 +1,4 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
@@ -17,12 +11,12 @@ go_library(
|
||||
"zz_generated.defaults.go",
|
||||
],
|
||||
importpath = "k8s.io/kubernetes/pkg/apis/autoscaling/v1",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/apis/autoscaling:go_default_library",
|
||||
"//pkg/apis/core:go_default_library",
|
||||
"//staging/src/k8s.io/api/autoscaling/v1:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/conversion:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
@@ -55,4 +49,5 @@ filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
@@ -21,10 +21,12 @@ import (
|
||||
|
||||
autoscalingv1 "k8s.io/api/autoscaling/v1"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/conversion"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
core "k8s.io/kubernetes/pkg/apis/core"
|
||||
)
|
||||
|
||||
func addConversionFuncs(scheme *runtime.Scheme) error {
|
||||
@@ -36,6 +38,22 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
|
||||
Convert_v1_HorizontalPodAutoscalerSpec_To_autoscaling_HorizontalPodAutoscalerSpec,
|
||||
Convert_autoscaling_HorizontalPodAutoscalerStatus_To_v1_HorizontalPodAutoscalerStatus,
|
||||
Convert_v1_HorizontalPodAutoscalerStatus_To_autoscaling_HorizontalPodAutoscalerStatus,
|
||||
Convert_autoscaling_ExternalMetricSource_To_v1_ExternalMetricSource,
|
||||
Convert_v1_ExternalMetricSource_To_autoscaling_ExternalMetricSource,
|
||||
Convert_autoscaling_ObjectMetricSource_To_v1_ObjectMetricSource,
|
||||
Convert_v1_ObjectMetricSource_To_autoscaling_ObjectMetricSource,
|
||||
Convert_autoscaling_PodsMetricSource_To_v1_PodsMetricSource,
|
||||
Convert_v1_PodsMetricSource_To_autoscaling_PodsMetricSource,
|
||||
Convert_autoscaling_ExternalMetricStatus_To_v1_ExternalMetricStatus,
|
||||
Convert_v1_ExternalMetricStatus_To_autoscaling_ExternalMetricStatus,
|
||||
Convert_autoscaling_ObjectMetricStatus_To_v1_ObjectMetricStatus,
|
||||
Convert_v1_ObjectMetricStatus_To_autoscaling_ObjectMetricStatus,
|
||||
Convert_autoscaling_PodsMetricStatus_To_v1_PodsMetricStatus,
|
||||
Convert_v1_PodsMetricStatus_To_autoscaling_PodsMetricStatus,
|
||||
Convert_autoscaling_MetricTarget_To_v1_CrossVersionObjectReference,
|
||||
Convert_v1_CrossVersionObjectReference_To_autoscaling_MetricTarget,
|
||||
Convert_autoscaling_ResourceMetricStatus_To_v1_ResourceMetricStatus,
|
||||
Convert_v1_ResourceMetricStatus_To_autoscaling_ResourceMetricStatus,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -44,6 +62,234 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_autoscaling_MetricTarget_To_v1_CrossVersionObjectReference(in *autoscaling.MetricTarget, out *autoscalingv1.CrossVersionObjectReference, s conversion.Scope) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1_CrossVersionObjectReference_To_autoscaling_MetricTarget(in *autoscalingv1.CrossVersionObjectReference, out *autoscaling.MetricTarget, s conversion.Scope) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_autoscaling_ExternalMetricSource_To_v1_ExternalMetricSource(in *autoscaling.ExternalMetricSource, out *autoscalingv1.ExternalMetricSource, s conversion.Scope) error {
|
||||
out.MetricName = in.Metric.Name
|
||||
out.TargetValue = in.Target.Value
|
||||
out.TargetAverageValue = in.Target.AverageValue
|
||||
out.MetricSelector = in.Metric.Selector
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1_ExternalMetricSource_To_autoscaling_ExternalMetricSource(in *autoscalingv1.ExternalMetricSource, out *autoscaling.ExternalMetricSource, s conversion.Scope) error {
|
||||
value := in.TargetValue
|
||||
averageValue := in.TargetAverageValue
|
||||
var metricType autoscaling.MetricTargetType
|
||||
if value == nil {
|
||||
metricType = autoscaling.AverageValueMetricType
|
||||
} else {
|
||||
metricType = autoscaling.ValueMetricType
|
||||
}
|
||||
out.Target = autoscaling.MetricTarget{
|
||||
Type: metricType,
|
||||
Value: value,
|
||||
AverageValue: averageValue,
|
||||
}
|
||||
|
||||
out.Metric = autoscaling.MetricIdentifier{
|
||||
Name: in.MetricName,
|
||||
Selector: in.MetricSelector,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_autoscaling_ObjectMetricSource_To_v1_ObjectMetricSource(in *autoscaling.ObjectMetricSource, out *autoscalingv1.ObjectMetricSource, s conversion.Scope) error {
|
||||
if in.Target.Value != nil {
|
||||
out.TargetValue = *in.Target.Value
|
||||
}
|
||||
out.AverageValue = in.Target.AverageValue
|
||||
out.Target = autoscalingv1.CrossVersionObjectReference{
|
||||
Kind: in.DescribedObject.Kind,
|
||||
Name: in.DescribedObject.Name,
|
||||
APIVersion: in.DescribedObject.APIVersion,
|
||||
}
|
||||
out.MetricName = in.Metric.Name
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1_ObjectMetricSource_To_autoscaling_ObjectMetricSource(in *autoscalingv1.ObjectMetricSource, out *autoscaling.ObjectMetricSource, s conversion.Scope) error {
|
||||
var metricType autoscaling.MetricTargetType
|
||||
if in.AverageValue == nil {
|
||||
metricType = autoscaling.ValueMetricType
|
||||
} else {
|
||||
metricType = autoscaling.AverageValueMetricType
|
||||
}
|
||||
|
||||
out.Target = autoscaling.MetricTarget{
|
||||
Type: metricType,
|
||||
Value: &in.TargetValue,
|
||||
AverageValue: in.AverageValue,
|
||||
}
|
||||
out.DescribedObject = autoscaling.CrossVersionObjectReference{
|
||||
Kind: in.Target.Kind,
|
||||
Name: in.Target.Name,
|
||||
APIVersion: in.Target.APIVersion,
|
||||
}
|
||||
out.Metric = autoscaling.MetricIdentifier{
|
||||
Name: in.MetricName,
|
||||
Selector: in.Selector,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_autoscaling_PodsMetricSource_To_v1_PodsMetricSource(in *autoscaling.PodsMetricSource, out *autoscalingv1.PodsMetricSource, s conversion.Scope) error {
|
||||
if in.Target.AverageValue != nil {
|
||||
out.TargetAverageValue = *in.Target.AverageValue
|
||||
}
|
||||
|
||||
out.MetricName = in.Metric.Name
|
||||
out.Selector = in.Metric.Selector
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1_PodsMetricSource_To_autoscaling_PodsMetricSource(in *autoscalingv1.PodsMetricSource, out *autoscaling.PodsMetricSource, s conversion.Scope) error {
|
||||
var metricType autoscaling.MetricTargetType
|
||||
metricType = autoscaling.AverageValueMetricType
|
||||
|
||||
out.Target = autoscaling.MetricTarget{
|
||||
Type: metricType,
|
||||
AverageValue: &in.TargetAverageValue,
|
||||
}
|
||||
out.Metric = autoscaling.MetricIdentifier{
|
||||
Name: in.MetricName,
|
||||
Selector: in.Selector,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_autoscaling_ExternalMetricStatus_To_v1_ExternalMetricStatus(in *autoscaling.ExternalMetricStatus, out *autoscalingv1.ExternalMetricStatus, s conversion.Scope) error {
|
||||
out.MetricName = in.Metric.Name
|
||||
if in.Current.Value != nil {
|
||||
out.CurrentValue = *in.Current.Value
|
||||
}
|
||||
if in.Current.AverageValue != nil {
|
||||
out.CurrentAverageValue = in.Current.AverageValue
|
||||
}
|
||||
out.MetricSelector = in.Metric.Selector
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1_ExternalMetricStatus_To_autoscaling_ExternalMetricStatus(in *autoscalingv1.ExternalMetricStatus, out *autoscaling.ExternalMetricStatus, s conversion.Scope) error {
|
||||
value := in.CurrentValue
|
||||
averageValue := in.CurrentAverageValue
|
||||
out.Current = autoscaling.MetricValueStatus{
|
||||
Value: &value,
|
||||
AverageValue: averageValue,
|
||||
}
|
||||
out.Metric = autoscaling.MetricIdentifier{
|
||||
Name: in.MetricName,
|
||||
Selector: in.MetricSelector,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_autoscaling_ObjectMetricStatus_To_v1_ObjectMetricStatus(in *autoscaling.ObjectMetricStatus, out *autoscalingv1.ObjectMetricStatus, s conversion.Scope) error {
|
||||
if in.Current.Value != nil {
|
||||
out.CurrentValue = *in.Current.Value
|
||||
}
|
||||
if in.Current.AverageValue != nil {
|
||||
currentAverageValue := *in.Current.AverageValue
|
||||
out.AverageValue = ¤tAverageValue
|
||||
}
|
||||
out.Target = autoscalingv1.CrossVersionObjectReference{
|
||||
Kind: in.DescribedObject.Kind,
|
||||
Name: in.DescribedObject.Name,
|
||||
APIVersion: in.DescribedObject.APIVersion,
|
||||
}
|
||||
out.MetricName = in.Metric.Name
|
||||
out.Selector = in.Metric.Selector
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1_ObjectMetricStatus_To_autoscaling_ObjectMetricStatus(in *autoscalingv1.ObjectMetricStatus, out *autoscaling.ObjectMetricStatus, s conversion.Scope) error {
|
||||
out.Current = autoscaling.MetricValueStatus{
|
||||
Value: &in.CurrentValue,
|
||||
AverageValue: in.AverageValue,
|
||||
}
|
||||
out.DescribedObject = autoscaling.CrossVersionObjectReference{
|
||||
Kind: in.Target.Kind,
|
||||
Name: in.Target.Name,
|
||||
APIVersion: in.Target.APIVersion,
|
||||
}
|
||||
out.Metric = autoscaling.MetricIdentifier{
|
||||
Name: in.MetricName,
|
||||
Selector: in.Selector,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_autoscaling_PodsMetricStatus_To_v1_PodsMetricStatus(in *autoscaling.PodsMetricStatus, out *autoscalingv1.PodsMetricStatus, s conversion.Scope) error {
|
||||
if in.Current.AverageValue != nil {
|
||||
out.CurrentAverageValue = *in.Current.AverageValue
|
||||
}
|
||||
out.MetricName = in.Metric.Name
|
||||
out.Selector = in.Metric.Selector
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1_PodsMetricStatus_To_autoscaling_PodsMetricStatus(in *autoscalingv1.PodsMetricStatus, out *autoscaling.PodsMetricStatus, s conversion.Scope) error {
|
||||
out.Current = autoscaling.MetricValueStatus{
|
||||
AverageValue: &in.CurrentAverageValue,
|
||||
}
|
||||
out.Metric = autoscaling.MetricIdentifier{
|
||||
Name: in.MetricName,
|
||||
Selector: in.Selector,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1_ResourceMetricSource_To_autoscaling_ResourceMetricSource(in *autoscalingv1.ResourceMetricSource, out *autoscaling.ResourceMetricSource, s conversion.Scope) error {
|
||||
out.Name = core.ResourceName(in.Name)
|
||||
utilization := in.TargetAverageUtilization
|
||||
averageValue := in.TargetAverageValue
|
||||
var metricType autoscaling.MetricTargetType
|
||||
if utilization == nil {
|
||||
metricType = autoscaling.AverageValueMetricType
|
||||
} else {
|
||||
metricType = autoscaling.UtilizationMetricType
|
||||
}
|
||||
out.Target = autoscaling.MetricTarget{
|
||||
Type: metricType,
|
||||
AverageValue: averageValue,
|
||||
AverageUtilization: utilization,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_autoscaling_ResourceMetricSource_To_v1_ResourceMetricSource(in *autoscaling.ResourceMetricSource, out *autoscalingv1.ResourceMetricSource, s conversion.Scope) error {
|
||||
out.Name = v1.ResourceName(in.Name)
|
||||
out.TargetAverageUtilization = in.Target.AverageUtilization
|
||||
out.TargetAverageValue = in.Target.AverageValue
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v1_ResourceMetricStatus_To_autoscaling_ResourceMetricStatus(in *autoscalingv1.ResourceMetricStatus, out *autoscaling.ResourceMetricStatus, s conversion.Scope) error {
|
||||
out.Name = core.ResourceName(in.Name)
|
||||
utilization := in.CurrentAverageUtilization
|
||||
averageValue := &in.CurrentAverageValue
|
||||
out.Current = autoscaling.MetricValueStatus{
|
||||
AverageValue: averageValue,
|
||||
AverageUtilization: utilization,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_autoscaling_ResourceMetricStatus_To_v1_ResourceMetricStatus(in *autoscaling.ResourceMetricStatus, out *autoscalingv1.ResourceMetricStatus, s conversion.Scope) error {
|
||||
out.Name = v1.ResourceName(in.Name)
|
||||
out.CurrentAverageUtilization = in.Current.AverageUtilization
|
||||
if in.Current.AverageValue != nil {
|
||||
out.CurrentAverageValue = *in.Current.AverageValue
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_autoscaling_HorizontalPodAutoscaler_To_v1_HorizontalPodAutoscaler(in *autoscaling.HorizontalPodAutoscaler, out *autoscalingv1.HorizontalPodAutoscaler, s conversion.Scope) error {
|
||||
if err := autoConvert_autoscaling_HorizontalPodAutoscaler_To_v1_HorizontalPodAutoscaler(in, out, s); err != nil {
|
||||
return err
|
||||
@@ -51,7 +297,7 @@ func Convert_autoscaling_HorizontalPodAutoscaler_To_v1_HorizontalPodAutoscaler(i
|
||||
|
||||
otherMetrics := make([]autoscalingv1.MetricSpec, 0, len(in.Spec.Metrics))
|
||||
for _, metric := range in.Spec.Metrics {
|
||||
if metric.Type == autoscaling.ResourceMetricSourceType && metric.Resource != nil && metric.Resource.Name == api.ResourceCPU && metric.Resource.TargetAverageUtilization != nil {
|
||||
if metric.Type == autoscaling.ResourceMetricSourceType && metric.Resource != nil && metric.Resource.Name == api.ResourceCPU && metric.Resource.Target.AverageUtilization != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -165,11 +411,14 @@ func Convert_v1_HorizontalPodAutoscaler_To_autoscaling_HorizontalPodAutoscaler(i
|
||||
Type: autoscaling.ResourceMetricSourceType,
|
||||
Resource: &autoscaling.ResourceMetricSource{
|
||||
Name: api.ResourceCPU,
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.UtilizationMetricType,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
out.Spec.Metrics[0].Resource.TargetAverageUtilization = new(int32)
|
||||
*out.Spec.Metrics[0].Resource.TargetAverageUtilization = autoscaling.DefaultCPUUtilization
|
||||
out.Spec.Metrics[0].Resource.Target.AverageUtilization = new(int32)
|
||||
*out.Spec.Metrics[0].Resource.Target.AverageUtilization = autoscaling.DefaultCPUUtilization
|
||||
}
|
||||
|
||||
if currentConditionsEnc, hasCurrentConditions := out.Annotations[autoscaling.HorizontalPodAutoscalerConditionsAnnotation]; hasCurrentConditions {
|
||||
@@ -200,9 +449,9 @@ func Convert_autoscaling_HorizontalPodAutoscalerSpec_To_v1_HorizontalPodAutoscal
|
||||
|
||||
for _, metric := range in.Metrics {
|
||||
if metric.Type == autoscaling.ResourceMetricSourceType && metric.Resource != nil && metric.Resource.Name == api.ResourceCPU {
|
||||
if metric.Resource.TargetAverageUtilization != nil {
|
||||
if metric.Resource.Target.AverageUtilization != nil {
|
||||
out.TargetCPUUtilizationPercentage = new(int32)
|
||||
*out.TargetCPUUtilizationPercentage = *metric.Resource.TargetAverageUtilization
|
||||
*out.TargetCPUUtilizationPercentage = *metric.Resource.Target.AverageUtilization
|
||||
}
|
||||
break
|
||||
}
|
||||
@@ -225,11 +474,14 @@ func Convert_v1_HorizontalPodAutoscalerSpec_To_autoscaling_HorizontalPodAutoscal
|
||||
Type: autoscaling.ResourceMetricSourceType,
|
||||
Resource: &autoscaling.ResourceMetricSource{
|
||||
Name: api.ResourceCPU,
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.UtilizationMetricType,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
out.Metrics[0].Resource.TargetAverageUtilization = new(int32)
|
||||
*out.Metrics[0].Resource.TargetAverageUtilization = *in.TargetCPUUtilizationPercentage
|
||||
out.Metrics[0].Resource.Target.AverageUtilization = new(int32)
|
||||
*out.Metrics[0].Resource.Target.AverageUtilization = *in.TargetCPUUtilizationPercentage
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -244,10 +496,10 @@ func Convert_autoscaling_HorizontalPodAutoscalerStatus_To_v1_HorizontalPodAutosc
|
||||
|
||||
for _, metric := range in.CurrentMetrics {
|
||||
if metric.Type == autoscaling.ResourceMetricSourceType && metric.Resource != nil && metric.Resource.Name == api.ResourceCPU {
|
||||
if metric.Resource.CurrentAverageUtilization != nil {
|
||||
if metric.Resource.Current.AverageUtilization != nil {
|
||||
|
||||
out.CurrentCPUUtilizationPercentage = new(int32)
|
||||
*out.CurrentCPUUtilizationPercentage = *metric.Resource.CurrentAverageUtilization
|
||||
*out.CurrentCPUUtilizationPercentage = *metric.Resource.Current.AverageUtilization
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -270,8 +522,8 @@ func Convert_v1_HorizontalPodAutoscalerStatus_To_autoscaling_HorizontalPodAutosc
|
||||
},
|
||||
},
|
||||
}
|
||||
out.CurrentMetrics[0].Resource.CurrentAverageUtilization = new(int32)
|
||||
*out.CurrentMetrics[0].Resource.CurrentAverageUtilization = *in.CurrentCPUUtilizationPercentage
|
||||
out.CurrentMetrics[0].Resource.Current.AverageUtilization = new(int32)
|
||||
*out.CurrentMetrics[0].Resource.Current.AverageUtilization = *in.CurrentCPUUtilizationPercentage
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
339
pkg/apis/autoscaling/v1/zz_generated.conversion.go
generated
339
pkg/apis/autoscaling/v1/zz_generated.conversion.go
generated
@@ -24,9 +24,14 @@ import (
|
||||
unsafe "unsafe"
|
||||
|
||||
v1 "k8s.io/api/autoscaling/v1"
|
||||
<<<<<<< HEAD
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
resource "k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
=======
|
||||
core_v1 "k8s.io/api/core/v1"
|
||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
>>>>>>> Update autoscaling conversion and validation for v2beta2 inclusion
|
||||
conversion "k8s.io/apimachinery/pkg/conversion"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
autoscaling "k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||
@@ -288,57 +293,61 @@ func Convert_autoscaling_CrossVersionObjectReference_To_v1_CrossVersionObjectRef
|
||||
}
|
||||
|
||||
func autoConvert_v1_ExternalMetricSource_To_autoscaling_ExternalMetricSource(in *v1.ExternalMetricSource, out *autoscaling.ExternalMetricSource, s conversion.Scope) error {
|
||||
<<<<<<< HEAD
|
||||
out.MetricName = in.MetricName
|
||||
out.MetricSelector = (*metav1.LabelSelector)(unsafe.Pointer(in.MetricSelector))
|
||||
out.TargetValue = (*resource.Quantity)(unsafe.Pointer(in.TargetValue))
|
||||
out.TargetAverageValue = (*resource.Quantity)(unsafe.Pointer(in.TargetAverageValue))
|
||||
=======
|
||||
// WARNING: in.MetricName requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.MetricSelector requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.TargetValue requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.TargetAverageValue requires manual conversion: does not exist in peer-type
|
||||
>>>>>>> Update autoscaling conversion and validation for v2beta2 inclusion
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1_ExternalMetricSource_To_autoscaling_ExternalMetricSource is an autogenerated conversion function.
|
||||
func Convert_v1_ExternalMetricSource_To_autoscaling_ExternalMetricSource(in *v1.ExternalMetricSource, out *autoscaling.ExternalMetricSource, s conversion.Scope) error {
|
||||
return autoConvert_v1_ExternalMetricSource_To_autoscaling_ExternalMetricSource(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_autoscaling_ExternalMetricSource_To_v1_ExternalMetricSource(in *autoscaling.ExternalMetricSource, out *v1.ExternalMetricSource, s conversion.Scope) error {
|
||||
<<<<<<< HEAD
|
||||
out.MetricName = in.MetricName
|
||||
out.MetricSelector = (*metav1.LabelSelector)(unsafe.Pointer(in.MetricSelector))
|
||||
out.TargetValue = (*resource.Quantity)(unsafe.Pointer(in.TargetValue))
|
||||
out.TargetAverageValue = (*resource.Quantity)(unsafe.Pointer(in.TargetAverageValue))
|
||||
=======
|
||||
// WARNING: in.Metric requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.Target requires manual conversion: does not exist in peer-type
|
||||
>>>>>>> Update autoscaling conversion and validation for v2beta2 inclusion
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_autoscaling_ExternalMetricSource_To_v1_ExternalMetricSource is an autogenerated conversion function.
|
||||
func Convert_autoscaling_ExternalMetricSource_To_v1_ExternalMetricSource(in *autoscaling.ExternalMetricSource, out *v1.ExternalMetricSource, s conversion.Scope) error {
|
||||
return autoConvert_autoscaling_ExternalMetricSource_To_v1_ExternalMetricSource(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1_ExternalMetricStatus_To_autoscaling_ExternalMetricStatus(in *v1.ExternalMetricStatus, out *autoscaling.ExternalMetricStatus, s conversion.Scope) error {
|
||||
<<<<<<< HEAD
|
||||
out.MetricName = in.MetricName
|
||||
out.MetricSelector = (*metav1.LabelSelector)(unsafe.Pointer(in.MetricSelector))
|
||||
out.CurrentValue = in.CurrentValue
|
||||
out.CurrentAverageValue = (*resource.Quantity)(unsafe.Pointer(in.CurrentAverageValue))
|
||||
=======
|
||||
// WARNING: in.MetricName requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.MetricSelector requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.CurrentValue requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.CurrentAverageValue requires manual conversion: does not exist in peer-type
|
||||
>>>>>>> Update autoscaling conversion and validation for v2beta2 inclusion
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1_ExternalMetricStatus_To_autoscaling_ExternalMetricStatus is an autogenerated conversion function.
|
||||
func Convert_v1_ExternalMetricStatus_To_autoscaling_ExternalMetricStatus(in *v1.ExternalMetricStatus, out *autoscaling.ExternalMetricStatus, s conversion.Scope) error {
|
||||
return autoConvert_v1_ExternalMetricStatus_To_autoscaling_ExternalMetricStatus(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_autoscaling_ExternalMetricStatus_To_v1_ExternalMetricStatus(in *autoscaling.ExternalMetricStatus, out *v1.ExternalMetricStatus, s conversion.Scope) error {
|
||||
<<<<<<< HEAD
|
||||
out.MetricName = in.MetricName
|
||||
out.MetricSelector = (*metav1.LabelSelector)(unsafe.Pointer(in.MetricSelector))
|
||||
out.CurrentValue = in.CurrentValue
|
||||
out.CurrentAverageValue = (*resource.Quantity)(unsafe.Pointer(in.CurrentAverageValue))
|
||||
=======
|
||||
// WARNING: in.Metric requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.Current requires manual conversion: does not exist in peer-type
|
||||
>>>>>>> Update autoscaling conversion and validation for v2beta2 inclusion
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_autoscaling_ExternalMetricStatus_To_v1_ExternalMetricStatus is an autogenerated conversion function.
|
||||
func Convert_autoscaling_ExternalMetricStatus_To_v1_ExternalMetricStatus(in *autoscaling.ExternalMetricStatus, out *v1.ExternalMetricStatus, s conversion.Scope) error {
|
||||
return autoConvert_autoscaling_ExternalMetricStatus_To_v1_ExternalMetricStatus(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1_HorizontalPodAutoscaler_To_autoscaling_HorizontalPodAutoscaler(in *v1.HorizontalPodAutoscaler, out *autoscaling.HorizontalPodAutoscaler, s conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
if err := Convert_v1_HorizontalPodAutoscalerSpec_To_autoscaling_HorizontalPodAutoscalerSpec(&in.Spec, &out.Spec, s); err != nil {
|
||||
@@ -472,10 +481,42 @@ func autoConvert_autoscaling_HorizontalPodAutoscalerStatus_To_v1_HorizontalPodAu
|
||||
|
||||
func autoConvert_v1_MetricSpec_To_autoscaling_MetricSpec(in *v1.MetricSpec, out *autoscaling.MetricSpec, s conversion.Scope) error {
|
||||
out.Type = autoscaling.MetricSourceType(in.Type)
|
||||
out.Object = (*autoscaling.ObjectMetricSource)(unsafe.Pointer(in.Object))
|
||||
out.Pods = (*autoscaling.PodsMetricSource)(unsafe.Pointer(in.Pods))
|
||||
out.Resource = (*autoscaling.ResourceMetricSource)(unsafe.Pointer(in.Resource))
|
||||
out.External = (*autoscaling.ExternalMetricSource)(unsafe.Pointer(in.External))
|
||||
if in.Object != nil {
|
||||
in, out := &in.Object, &out.Object
|
||||
*out = new(autoscaling.ObjectMetricSource)
|
||||
if err := Convert_v1_ObjectMetricSource_To_autoscaling_ObjectMetricSource(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Object = nil
|
||||
}
|
||||
if in.Pods != nil {
|
||||
in, out := &in.Pods, &out.Pods
|
||||
*out = new(autoscaling.PodsMetricSource)
|
||||
if err := Convert_v1_PodsMetricSource_To_autoscaling_PodsMetricSource(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Pods = nil
|
||||
}
|
||||
if in.Resource != nil {
|
||||
in, out := &in.Resource, &out.Resource
|
||||
*out = new(autoscaling.ResourceMetricSource)
|
||||
if err := Convert_v1_ResourceMetricSource_To_autoscaling_ResourceMetricSource(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Resource = nil
|
||||
}
|
||||
if in.External != nil {
|
||||
in, out := &in.External, &out.External
|
||||
*out = new(autoscaling.ExternalMetricSource)
|
||||
if err := Convert_v1_ExternalMetricSource_To_autoscaling_ExternalMetricSource(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.External = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -486,10 +527,42 @@ func Convert_v1_MetricSpec_To_autoscaling_MetricSpec(in *v1.MetricSpec, out *aut
|
||||
|
||||
func autoConvert_autoscaling_MetricSpec_To_v1_MetricSpec(in *autoscaling.MetricSpec, out *v1.MetricSpec, s conversion.Scope) error {
|
||||
out.Type = v1.MetricSourceType(in.Type)
|
||||
out.Object = (*v1.ObjectMetricSource)(unsafe.Pointer(in.Object))
|
||||
out.Pods = (*v1.PodsMetricSource)(unsafe.Pointer(in.Pods))
|
||||
out.Resource = (*v1.ResourceMetricSource)(unsafe.Pointer(in.Resource))
|
||||
out.External = (*v1.ExternalMetricSource)(unsafe.Pointer(in.External))
|
||||
if in.Object != nil {
|
||||
in, out := &in.Object, &out.Object
|
||||
*out = new(v1.ObjectMetricSource)
|
||||
if err := Convert_autoscaling_ObjectMetricSource_To_v1_ObjectMetricSource(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Object = nil
|
||||
}
|
||||
if in.Pods != nil {
|
||||
in, out := &in.Pods, &out.Pods
|
||||
*out = new(v1.PodsMetricSource)
|
||||
if err := Convert_autoscaling_PodsMetricSource_To_v1_PodsMetricSource(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Pods = nil
|
||||
}
|
||||
if in.Resource != nil {
|
||||
in, out := &in.Resource, &out.Resource
|
||||
*out = new(v1.ResourceMetricSource)
|
||||
if err := Convert_autoscaling_ResourceMetricSource_To_v1_ResourceMetricSource(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Resource = nil
|
||||
}
|
||||
if in.External != nil {
|
||||
in, out := &in.External, &out.External
|
||||
*out = new(v1.ExternalMetricSource)
|
||||
if err := Convert_autoscaling_ExternalMetricSource_To_v1_ExternalMetricSource(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.External = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -500,10 +573,42 @@ func Convert_autoscaling_MetricSpec_To_v1_MetricSpec(in *autoscaling.MetricSpec,
|
||||
|
||||
func autoConvert_v1_MetricStatus_To_autoscaling_MetricStatus(in *v1.MetricStatus, out *autoscaling.MetricStatus, s conversion.Scope) error {
|
||||
out.Type = autoscaling.MetricSourceType(in.Type)
|
||||
out.Object = (*autoscaling.ObjectMetricStatus)(unsafe.Pointer(in.Object))
|
||||
out.Pods = (*autoscaling.PodsMetricStatus)(unsafe.Pointer(in.Pods))
|
||||
out.Resource = (*autoscaling.ResourceMetricStatus)(unsafe.Pointer(in.Resource))
|
||||
out.External = (*autoscaling.ExternalMetricStatus)(unsafe.Pointer(in.External))
|
||||
if in.Object != nil {
|
||||
in, out := &in.Object, &out.Object
|
||||
*out = new(autoscaling.ObjectMetricStatus)
|
||||
if err := Convert_v1_ObjectMetricStatus_To_autoscaling_ObjectMetricStatus(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Object = nil
|
||||
}
|
||||
if in.Pods != nil {
|
||||
in, out := &in.Pods, &out.Pods
|
||||
*out = new(autoscaling.PodsMetricStatus)
|
||||
if err := Convert_v1_PodsMetricStatus_To_autoscaling_PodsMetricStatus(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Pods = nil
|
||||
}
|
||||
if in.Resource != nil {
|
||||
in, out := &in.Resource, &out.Resource
|
||||
*out = new(autoscaling.ResourceMetricStatus)
|
||||
if err := Convert_v1_ResourceMetricStatus_To_autoscaling_ResourceMetricStatus(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Resource = nil
|
||||
}
|
||||
if in.External != nil {
|
||||
in, out := &in.External, &out.External
|
||||
*out = new(autoscaling.ExternalMetricStatus)
|
||||
if err := Convert_v1_ExternalMetricStatus_To_autoscaling_ExternalMetricStatus(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.External = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -514,10 +619,42 @@ func Convert_v1_MetricStatus_To_autoscaling_MetricStatus(in *v1.MetricStatus, ou
|
||||
|
||||
func autoConvert_autoscaling_MetricStatus_To_v1_MetricStatus(in *autoscaling.MetricStatus, out *v1.MetricStatus, s conversion.Scope) error {
|
||||
out.Type = v1.MetricSourceType(in.Type)
|
||||
out.Object = (*v1.ObjectMetricStatus)(unsafe.Pointer(in.Object))
|
||||
out.Pods = (*v1.PodsMetricStatus)(unsafe.Pointer(in.Pods))
|
||||
out.Resource = (*v1.ResourceMetricStatus)(unsafe.Pointer(in.Resource))
|
||||
out.External = (*v1.ExternalMetricStatus)(unsafe.Pointer(in.External))
|
||||
if in.Object != nil {
|
||||
in, out := &in.Object, &out.Object
|
||||
*out = new(v1.ObjectMetricStatus)
|
||||
if err := Convert_autoscaling_ObjectMetricStatus_To_v1_ObjectMetricStatus(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Object = nil
|
||||
}
|
||||
if in.Pods != nil {
|
||||
in, out := &in.Pods, &out.Pods
|
||||
*out = new(v1.PodsMetricStatus)
|
||||
if err := Convert_autoscaling_PodsMetricStatus_To_v1_PodsMetricStatus(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Pods = nil
|
||||
}
|
||||
if in.Resource != nil {
|
||||
in, out := &in.Resource, &out.Resource
|
||||
*out = new(v1.ResourceMetricStatus)
|
||||
if err := Convert_autoscaling_ResourceMetricStatus_To_v1_ResourceMetricStatus(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Resource = nil
|
||||
}
|
||||
if in.External != nil {
|
||||
in, out := &in.External, &out.External
|
||||
*out = new(v1.ExternalMetricStatus)
|
||||
if err := Convert_autoscaling_ExternalMetricStatus_To_v1_ExternalMetricStatus(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.External = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -527,153 +664,107 @@ func Convert_autoscaling_MetricStatus_To_v1_MetricStatus(in *autoscaling.MetricS
|
||||
}
|
||||
|
||||
func autoConvert_v1_ObjectMetricSource_To_autoscaling_ObjectMetricSource(in *v1.ObjectMetricSource, out *autoscaling.ObjectMetricSource, s conversion.Scope) error {
|
||||
if err := Convert_v1_CrossVersionObjectReference_To_autoscaling_CrossVersionObjectReference(&in.Target, &out.Target, s); err != nil {
|
||||
if err := Convert_v1_CrossVersionObjectReference_To_autoscaling_MetricTarget(&in.Target, &out.Target, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.MetricName = in.MetricName
|
||||
out.TargetValue = in.TargetValue
|
||||
// WARNING: in.MetricName requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.TargetValue requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.Selector requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.AverageValue requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1_ObjectMetricSource_To_autoscaling_ObjectMetricSource is an autogenerated conversion function.
|
||||
func Convert_v1_ObjectMetricSource_To_autoscaling_ObjectMetricSource(in *v1.ObjectMetricSource, out *autoscaling.ObjectMetricSource, s conversion.Scope) error {
|
||||
return autoConvert_v1_ObjectMetricSource_To_autoscaling_ObjectMetricSource(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_autoscaling_ObjectMetricSource_To_v1_ObjectMetricSource(in *autoscaling.ObjectMetricSource, out *v1.ObjectMetricSource, s conversion.Scope) error {
|
||||
if err := Convert_autoscaling_CrossVersionObjectReference_To_v1_CrossVersionObjectReference(&in.Target, &out.Target, s); err != nil {
|
||||
// WARNING: in.DescribedObject requires manual conversion: does not exist in peer-type
|
||||
if err := Convert_autoscaling_MetricTarget_To_v1_CrossVersionObjectReference(&in.Target, &out.Target, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.MetricName = in.MetricName
|
||||
out.TargetValue = in.TargetValue
|
||||
// WARNING: in.Metric requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_autoscaling_ObjectMetricSource_To_v1_ObjectMetricSource is an autogenerated conversion function.
|
||||
func Convert_autoscaling_ObjectMetricSource_To_v1_ObjectMetricSource(in *autoscaling.ObjectMetricSource, out *v1.ObjectMetricSource, s conversion.Scope) error {
|
||||
return autoConvert_autoscaling_ObjectMetricSource_To_v1_ObjectMetricSource(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1_ObjectMetricStatus_To_autoscaling_ObjectMetricStatus(in *v1.ObjectMetricStatus, out *autoscaling.ObjectMetricStatus, s conversion.Scope) error {
|
||||
if err := Convert_v1_CrossVersionObjectReference_To_autoscaling_CrossVersionObjectReference(&in.Target, &out.Target, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.MetricName = in.MetricName
|
||||
out.CurrentValue = in.CurrentValue
|
||||
// WARNING: in.Target requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.MetricName requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.CurrentValue requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.Selector requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.AverageValue requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1_ObjectMetricStatus_To_autoscaling_ObjectMetricStatus is an autogenerated conversion function.
|
||||
func Convert_v1_ObjectMetricStatus_To_autoscaling_ObjectMetricStatus(in *v1.ObjectMetricStatus, out *autoscaling.ObjectMetricStatus, s conversion.Scope) error {
|
||||
return autoConvert_v1_ObjectMetricStatus_To_autoscaling_ObjectMetricStatus(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_autoscaling_ObjectMetricStatus_To_v1_ObjectMetricStatus(in *autoscaling.ObjectMetricStatus, out *v1.ObjectMetricStatus, s conversion.Scope) error {
|
||||
if err := Convert_autoscaling_CrossVersionObjectReference_To_v1_CrossVersionObjectReference(&in.Target, &out.Target, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.MetricName = in.MetricName
|
||||
out.CurrentValue = in.CurrentValue
|
||||
// WARNING: in.Metric requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.Current requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.DescribedObject requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_autoscaling_ObjectMetricStatus_To_v1_ObjectMetricStatus is an autogenerated conversion function.
|
||||
func Convert_autoscaling_ObjectMetricStatus_To_v1_ObjectMetricStatus(in *autoscaling.ObjectMetricStatus, out *v1.ObjectMetricStatus, s conversion.Scope) error {
|
||||
return autoConvert_autoscaling_ObjectMetricStatus_To_v1_ObjectMetricStatus(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1_PodsMetricSource_To_autoscaling_PodsMetricSource(in *v1.PodsMetricSource, out *autoscaling.PodsMetricSource, s conversion.Scope) error {
|
||||
out.MetricName = in.MetricName
|
||||
out.TargetAverageValue = in.TargetAverageValue
|
||||
// WARNING: in.MetricName requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.TargetAverageValue requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.Selector requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.Value requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1_PodsMetricSource_To_autoscaling_PodsMetricSource is an autogenerated conversion function.
|
||||
func Convert_v1_PodsMetricSource_To_autoscaling_PodsMetricSource(in *v1.PodsMetricSource, out *autoscaling.PodsMetricSource, s conversion.Scope) error {
|
||||
return autoConvert_v1_PodsMetricSource_To_autoscaling_PodsMetricSource(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_autoscaling_PodsMetricSource_To_v1_PodsMetricSource(in *autoscaling.PodsMetricSource, out *v1.PodsMetricSource, s conversion.Scope) error {
|
||||
out.MetricName = in.MetricName
|
||||
out.TargetAverageValue = in.TargetAverageValue
|
||||
// WARNING: in.Metric requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.Target requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_autoscaling_PodsMetricSource_To_v1_PodsMetricSource is an autogenerated conversion function.
|
||||
func Convert_autoscaling_PodsMetricSource_To_v1_PodsMetricSource(in *autoscaling.PodsMetricSource, out *v1.PodsMetricSource, s conversion.Scope) error {
|
||||
return autoConvert_autoscaling_PodsMetricSource_To_v1_PodsMetricSource(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1_PodsMetricStatus_To_autoscaling_PodsMetricStatus(in *v1.PodsMetricStatus, out *autoscaling.PodsMetricStatus, s conversion.Scope) error {
|
||||
out.MetricName = in.MetricName
|
||||
out.CurrentAverageValue = in.CurrentAverageValue
|
||||
// WARNING: in.MetricName requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.CurrentAverageValue requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.Selector requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.Value requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1_PodsMetricStatus_To_autoscaling_PodsMetricStatus is an autogenerated conversion function.
|
||||
func Convert_v1_PodsMetricStatus_To_autoscaling_PodsMetricStatus(in *v1.PodsMetricStatus, out *autoscaling.PodsMetricStatus, s conversion.Scope) error {
|
||||
return autoConvert_v1_PodsMetricStatus_To_autoscaling_PodsMetricStatus(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_autoscaling_PodsMetricStatus_To_v1_PodsMetricStatus(in *autoscaling.PodsMetricStatus, out *v1.PodsMetricStatus, s conversion.Scope) error {
|
||||
out.MetricName = in.MetricName
|
||||
out.CurrentAverageValue = in.CurrentAverageValue
|
||||
// WARNING: in.Metric requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.Current requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_autoscaling_PodsMetricStatus_To_v1_PodsMetricStatus is an autogenerated conversion function.
|
||||
func Convert_autoscaling_PodsMetricStatus_To_v1_PodsMetricStatus(in *autoscaling.PodsMetricStatus, out *v1.PodsMetricStatus, s conversion.Scope) error {
|
||||
return autoConvert_autoscaling_PodsMetricStatus_To_v1_PodsMetricStatus(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1_ResourceMetricSource_To_autoscaling_ResourceMetricSource(in *v1.ResourceMetricSource, out *autoscaling.ResourceMetricSource, s conversion.Scope) error {
|
||||
out.Name = core.ResourceName(in.Name)
|
||||
out.TargetAverageUtilization = (*int32)(unsafe.Pointer(in.TargetAverageUtilization))
|
||||
out.TargetAverageValue = (*resource.Quantity)(unsafe.Pointer(in.TargetAverageValue))
|
||||
// WARNING: in.TargetAverageUtilization requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.TargetAverageValue requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1_ResourceMetricSource_To_autoscaling_ResourceMetricSource is an autogenerated conversion function.
|
||||
func Convert_v1_ResourceMetricSource_To_autoscaling_ResourceMetricSource(in *v1.ResourceMetricSource, out *autoscaling.ResourceMetricSource, s conversion.Scope) error {
|
||||
return autoConvert_v1_ResourceMetricSource_To_autoscaling_ResourceMetricSource(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_autoscaling_ResourceMetricSource_To_v1_ResourceMetricSource(in *autoscaling.ResourceMetricSource, out *v1.ResourceMetricSource, s conversion.Scope) error {
|
||||
<<<<<<< HEAD
|
||||
out.Name = corev1.ResourceName(in.Name)
|
||||
out.TargetAverageUtilization = (*int32)(unsafe.Pointer(in.TargetAverageUtilization))
|
||||
out.TargetAverageValue = (*resource.Quantity)(unsafe.Pointer(in.TargetAverageValue))
|
||||
=======
|
||||
out.Name = core_v1.ResourceName(in.Name)
|
||||
// WARNING: in.Target requires manual conversion: does not exist in peer-type
|
||||
>>>>>>> Update autoscaling conversion and validation for v2beta2 inclusion
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_autoscaling_ResourceMetricSource_To_v1_ResourceMetricSource is an autogenerated conversion function.
|
||||
func Convert_autoscaling_ResourceMetricSource_To_v1_ResourceMetricSource(in *autoscaling.ResourceMetricSource, out *v1.ResourceMetricSource, s conversion.Scope) error {
|
||||
return autoConvert_autoscaling_ResourceMetricSource_To_v1_ResourceMetricSource(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1_ResourceMetricStatus_To_autoscaling_ResourceMetricStatus(in *v1.ResourceMetricStatus, out *autoscaling.ResourceMetricStatus, s conversion.Scope) error {
|
||||
out.Name = core.ResourceName(in.Name)
|
||||
out.CurrentAverageUtilization = (*int32)(unsafe.Pointer(in.CurrentAverageUtilization))
|
||||
out.CurrentAverageValue = in.CurrentAverageValue
|
||||
// WARNING: in.CurrentAverageUtilization requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.CurrentAverageValue requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v1_ResourceMetricStatus_To_autoscaling_ResourceMetricStatus is an autogenerated conversion function.
|
||||
func Convert_v1_ResourceMetricStatus_To_autoscaling_ResourceMetricStatus(in *v1.ResourceMetricStatus, out *autoscaling.ResourceMetricStatus, s conversion.Scope) error {
|
||||
return autoConvert_v1_ResourceMetricStatus_To_autoscaling_ResourceMetricStatus(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_autoscaling_ResourceMetricStatus_To_v1_ResourceMetricStatus(in *autoscaling.ResourceMetricStatus, out *v1.ResourceMetricStatus, s conversion.Scope) error {
|
||||
<<<<<<< HEAD
|
||||
out.Name = corev1.ResourceName(in.Name)
|
||||
out.CurrentAverageUtilization = (*int32)(unsafe.Pointer(in.CurrentAverageUtilization))
|
||||
out.CurrentAverageValue = in.CurrentAverageValue
|
||||
=======
|
||||
out.Name = core_v1.ResourceName(in.Name)
|
||||
// WARNING: in.Current requires manual conversion: does not exist in peer-type
|
||||
>>>>>>> Update autoscaling conversion and validation for v2beta2 inclusion
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_autoscaling_ResourceMetricStatus_To_v1_ResourceMetricStatus is an autogenerated conversion function.
|
||||
func Convert_autoscaling_ResourceMetricStatus_To_v1_ResourceMetricStatus(in *autoscaling.ResourceMetricStatus, out *v1.ResourceMetricStatus, s conversion.Scope) error {
|
||||
return autoConvert_autoscaling_ResourceMetricStatus_To_v1_ResourceMetricStatus(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v1_Scale_To_autoscaling_Scale(in *v1.Scale, out *autoscaling.Scale, s conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
if err := Convert_v1_ScaleSpec_To_autoscaling_ScaleSpec(&in.Spec, &out.Spec, s); err != nil {
|
||||
|
@@ -1,14 +1,9 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"conversion.go",
|
||||
"defaults.go",
|
||||
"doc.go",
|
||||
"register.go",
|
||||
@@ -16,12 +11,12 @@ go_library(
|
||||
"zz_generated.defaults.go",
|
||||
],
|
||||
importpath = "k8s.io/kubernetes/pkg/apis/autoscaling/v2beta1",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/apis/autoscaling:go_default_library",
|
||||
"//pkg/apis/core:go_default_library",
|
||||
"//staging/src/k8s.io/api/autoscaling/v2beta1:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/conversion:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
@@ -29,19 +24,6 @@ go_library(
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["defaults_test.go"],
|
||||
@@ -58,3 +40,17 @@ go_test(
|
||||
"//vendor/k8s.io/utils/pointer:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
410
pkg/apis/autoscaling/v2beta1/conversion.go
Normal file
410
pkg/apis/autoscaling/v2beta1/conversion.go
Normal file
@@ -0,0 +1,410 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v2beta1
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
autoscalingv2beta1 "k8s.io/api/autoscaling/v2beta1"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/conversion"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||
core "k8s.io/kubernetes/pkg/apis/core"
|
||||
)
|
||||
|
||||
func addConversionFuncs(scheme *runtime.Scheme) error {
|
||||
// Add non-generated conversion functions
|
||||
err := scheme.AddConversionFuncs(
|
||||
Convert_autoscaling_ExternalMetricSource_To_v2beta1_ExternalMetricSource,
|
||||
Convert_v2beta1_ExternalMetricSource_To_autoscaling_ExternalMetricSource,
|
||||
Convert_autoscaling_ObjectMetricSource_To_v2beta1_ObjectMetricSource,
|
||||
Convert_v2beta1_ObjectMetricSource_To_autoscaling_ObjectMetricSource,
|
||||
Convert_autoscaling_PodsMetricSource_To_v2beta1_PodsMetricSource,
|
||||
Convert_v2beta1_PodsMetricSource_To_autoscaling_PodsMetricSource,
|
||||
Convert_autoscaling_ExternalMetricStatus_To_v2beta1_ExternalMetricStatus,
|
||||
Convert_v2beta1_ExternalMetricStatus_To_autoscaling_ExternalMetricStatus,
|
||||
Convert_autoscaling_ObjectMetricStatus_To_v2beta1_ObjectMetricStatus,
|
||||
Convert_v2beta1_ObjectMetricStatus_To_autoscaling_ObjectMetricStatus,
|
||||
Convert_autoscaling_PodsMetricStatus_To_v2beta1_PodsMetricStatus,
|
||||
Convert_v2beta1_PodsMetricStatus_To_autoscaling_PodsMetricStatus,
|
||||
Convert_autoscaling_ResourceMetricSource_To_v2beta1_ResourceMetricSource,
|
||||
Convert_v2beta1_ResourceMetricSource_To_autoscaling_ResourceMetricSource,
|
||||
Convert_autoscaling_MetricTarget_To_v2beta1_CrossVersionObjectReference,
|
||||
Convert_v2beta1_CrossVersionObjectReference_To_autoscaling_MetricTarget,
|
||||
Convert_autoscaling_ResourceMetricStatus_To_v2beta1_ResourceMetricStatus,
|
||||
Convert_v2beta1_ResourceMetricStatus_To_autoscaling_ResourceMetricStatus,
|
||||
Convert_autoscaling_HorizontalPodAutoscaler_To_v2beta1_HorizontalPodAutoscaler,
|
||||
Convert_v2beta1_HorizontalPodAutoscaler_To_autoscaling_HorizontalPodAutoscaler,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_autoscaling_MetricTarget_To_v2beta1_CrossVersionObjectReference(in *autoscaling.MetricTarget, out *autoscalingv2beta1.CrossVersionObjectReference, s conversion.Scope) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v2beta1_CrossVersionObjectReference_To_autoscaling_MetricTarget(in *autoscalingv2beta1.CrossVersionObjectReference, out *autoscaling.MetricTarget, s conversion.Scope) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v2beta1_ResourceMetricStatus_To_autoscaling_ResourceMetricStatus(in *autoscalingv2beta1.ResourceMetricStatus, out *autoscaling.ResourceMetricStatus, s conversion.Scope) error {
|
||||
out.Name = core.ResourceName(in.Name)
|
||||
utilization := in.CurrentAverageUtilization
|
||||
averageValue := in.CurrentAverageValue
|
||||
out.Current = autoscaling.MetricValueStatus{
|
||||
AverageValue: &averageValue,
|
||||
AverageUtilization: utilization,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_autoscaling_ResourceMetricStatus_To_v2beta1_ResourceMetricStatus(in *autoscaling.ResourceMetricStatus, out *autoscalingv2beta1.ResourceMetricStatus, s conversion.Scope) error {
|
||||
out.Name = v1.ResourceName(in.Name)
|
||||
out.CurrentAverageUtilization = in.Current.AverageUtilization
|
||||
if in.Current.AverageValue != nil {
|
||||
out.CurrentAverageValue = *in.Current.AverageValue
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v2beta1_ResourceMetricSource_To_autoscaling_ResourceMetricSource(in *autoscalingv2beta1.ResourceMetricSource, out *autoscaling.ResourceMetricSource, s conversion.Scope) error {
|
||||
out.Name = core.ResourceName(in.Name)
|
||||
utilization := in.TargetAverageUtilization
|
||||
averageValue := in.TargetAverageValue
|
||||
|
||||
var metricType autoscaling.MetricTargetType
|
||||
if utilization == nil {
|
||||
metricType = autoscaling.AverageValueMetricType
|
||||
} else {
|
||||
metricType = autoscaling.UtilizationMetricType
|
||||
}
|
||||
out.Target = autoscaling.MetricTarget{
|
||||
Type: metricType,
|
||||
AverageValue: averageValue,
|
||||
AverageUtilization: utilization,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_autoscaling_ResourceMetricSource_To_v2beta1_ResourceMetricSource(in *autoscaling.ResourceMetricSource, out *autoscalingv2beta1.ResourceMetricSource, s conversion.Scope) error {
|
||||
out.Name = v1.ResourceName(in.Name)
|
||||
out.TargetAverageUtilization = in.Target.AverageUtilization
|
||||
out.TargetAverageValue = in.Target.AverageValue
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_autoscaling_ExternalMetricSource_To_v2beta1_ExternalMetricSource(in *autoscaling.ExternalMetricSource, out *autoscalingv2beta1.ExternalMetricSource, s conversion.Scope) error {
|
||||
out.MetricName = in.Metric.Name
|
||||
out.TargetValue = in.Target.Value
|
||||
out.TargetAverageValue = in.Target.AverageValue
|
||||
out.MetricSelector = in.Metric.Selector
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v2beta1_ExternalMetricSource_To_autoscaling_ExternalMetricSource(in *autoscalingv2beta1.ExternalMetricSource, out *autoscaling.ExternalMetricSource, s conversion.Scope) error {
|
||||
value := in.TargetValue
|
||||
averageValue := in.TargetAverageValue
|
||||
|
||||
var metricType autoscaling.MetricTargetType
|
||||
if value == nil {
|
||||
metricType = autoscaling.AverageValueMetricType
|
||||
} else {
|
||||
metricType = autoscaling.ValueMetricType
|
||||
}
|
||||
|
||||
out.Target = autoscaling.MetricTarget{
|
||||
Type: metricType,
|
||||
Value: value,
|
||||
AverageValue: averageValue,
|
||||
}
|
||||
|
||||
out.Metric = autoscaling.MetricIdentifier{
|
||||
Name: in.MetricName,
|
||||
Selector: in.MetricSelector,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_autoscaling_ObjectMetricSource_To_v2beta1_ObjectMetricSource(in *autoscaling.ObjectMetricSource, out *autoscalingv2beta1.ObjectMetricSource, s conversion.Scope) error {
|
||||
if in.Target.Value != nil {
|
||||
out.TargetValue = *in.Target.Value
|
||||
}
|
||||
out.AverageValue = in.Target.AverageValue
|
||||
|
||||
out.Target = autoscalingv2beta1.CrossVersionObjectReference{
|
||||
Kind: in.DescribedObject.Kind,
|
||||
Name: in.DescribedObject.Name,
|
||||
APIVersion: in.DescribedObject.APIVersion,
|
||||
}
|
||||
out.MetricName = in.Metric.Name
|
||||
out.Selector = in.Metric.Selector
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v2beta1_ObjectMetricSource_To_autoscaling_ObjectMetricSource(in *autoscalingv2beta1.ObjectMetricSource, out *autoscaling.ObjectMetricSource, s conversion.Scope) error {
|
||||
var metricType autoscaling.MetricTargetType
|
||||
if in.AverageValue == nil {
|
||||
metricType = autoscaling.ValueMetricType
|
||||
} else {
|
||||
metricType = autoscaling.AverageValueMetricType
|
||||
}
|
||||
out.Target = autoscaling.MetricTarget{
|
||||
Type: metricType,
|
||||
Value: &in.TargetValue,
|
||||
AverageValue: in.AverageValue,
|
||||
}
|
||||
out.DescribedObject = autoscaling.CrossVersionObjectReference{
|
||||
Kind: in.Target.Kind,
|
||||
Name: in.Target.Name,
|
||||
APIVersion: in.Target.APIVersion,
|
||||
}
|
||||
out.Metric = autoscaling.MetricIdentifier{
|
||||
Name: in.MetricName,
|
||||
Selector: in.Selector,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_autoscaling_PodsMetricSource_To_v2beta1_PodsMetricSource(in *autoscaling.PodsMetricSource, out *autoscalingv2beta1.PodsMetricSource, s conversion.Scope) error {
|
||||
targetAverageValue := *in.Target.AverageValue
|
||||
out.TargetAverageValue = targetAverageValue
|
||||
|
||||
out.MetricName = in.Metric.Name
|
||||
out.Selector = in.Metric.Selector
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v2beta1_PodsMetricSource_To_autoscaling_PodsMetricSource(in *autoscalingv2beta1.PodsMetricSource, out *autoscaling.PodsMetricSource, s conversion.Scope) error {
|
||||
targetAverageValue := &in.TargetAverageValue
|
||||
var metricType autoscaling.MetricTargetType
|
||||
metricType = autoscaling.AverageValueMetricType
|
||||
|
||||
out.Target = autoscaling.MetricTarget{
|
||||
Type: metricType,
|
||||
AverageValue: targetAverageValue,
|
||||
}
|
||||
out.Metric = autoscaling.MetricIdentifier{
|
||||
Name: in.MetricName,
|
||||
Selector: in.Selector,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_autoscaling_ExternalMetricStatus_To_v2beta1_ExternalMetricStatus(in *autoscaling.ExternalMetricStatus, out *autoscalingv2beta1.ExternalMetricStatus, s conversion.Scope) error {
|
||||
if &in.Current.AverageValue != nil {
|
||||
out.CurrentAverageValue = in.Current.AverageValue
|
||||
}
|
||||
out.MetricName = in.Metric.Name
|
||||
if in.Current.Value != nil {
|
||||
out.CurrentValue = *in.Current.Value
|
||||
}
|
||||
out.MetricSelector = in.Metric.Selector
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v2beta1_ExternalMetricStatus_To_autoscaling_ExternalMetricStatus(in *autoscalingv2beta1.ExternalMetricStatus, out *autoscaling.ExternalMetricStatus, s conversion.Scope) error {
|
||||
value := in.CurrentValue
|
||||
averageValue := in.CurrentAverageValue
|
||||
out.Current = autoscaling.MetricValueStatus{
|
||||
Value: &value,
|
||||
AverageValue: averageValue,
|
||||
}
|
||||
out.Metric = autoscaling.MetricIdentifier{
|
||||
Name: in.MetricName,
|
||||
Selector: in.MetricSelector,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_autoscaling_ObjectMetricStatus_To_v2beta1_ObjectMetricStatus(in *autoscaling.ObjectMetricStatus, out *autoscalingv2beta1.ObjectMetricStatus, s conversion.Scope) error {
|
||||
if in.Current.Value != nil {
|
||||
out.CurrentValue = *in.Current.Value
|
||||
}
|
||||
out.Target = autoscalingv2beta1.CrossVersionObjectReference{
|
||||
Kind: in.DescribedObject.Kind,
|
||||
Name: in.DescribedObject.Name,
|
||||
APIVersion: in.DescribedObject.APIVersion,
|
||||
}
|
||||
out.MetricName = in.Metric.Name
|
||||
out.Selector = in.Metric.Selector
|
||||
currentAverageValue := *in.Current.AverageValue
|
||||
out.AverageValue = ¤tAverageValue
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v2beta1_ObjectMetricStatus_To_autoscaling_ObjectMetricStatus(in *autoscalingv2beta1.ObjectMetricStatus, out *autoscaling.ObjectMetricStatus, s conversion.Scope) error {
|
||||
out.Current = autoscaling.MetricValueStatus{
|
||||
Value: &in.CurrentValue,
|
||||
AverageValue: in.AverageValue,
|
||||
}
|
||||
out.DescribedObject = autoscaling.CrossVersionObjectReference{
|
||||
Kind: in.Target.Kind,
|
||||
Name: in.Target.Name,
|
||||
APIVersion: in.Target.APIVersion,
|
||||
}
|
||||
out.Metric = autoscaling.MetricIdentifier{
|
||||
Name: in.MetricName,
|
||||
Selector: in.Selector,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_autoscaling_PodsMetricStatus_To_v2beta1_PodsMetricStatus(in *autoscaling.PodsMetricStatus, out *autoscalingv2beta1.PodsMetricStatus, s conversion.Scope) error {
|
||||
if in.Current.AverageValue != nil {
|
||||
out.CurrentAverageValue = *in.Current.AverageValue
|
||||
}
|
||||
out.MetricName = in.Metric.Name
|
||||
out.Selector = in.Metric.Selector
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v2beta1_PodsMetricStatus_To_autoscaling_PodsMetricStatus(in *autoscalingv2beta1.PodsMetricStatus, out *autoscaling.PodsMetricStatus, s conversion.Scope) error {
|
||||
out.Current = autoscaling.MetricValueStatus{
|
||||
AverageValue: &in.CurrentAverageValue,
|
||||
}
|
||||
out.Metric = autoscaling.MetricIdentifier{
|
||||
Name: in.MetricName,
|
||||
Selector: in.Selector,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_v2beta1_HorizontalPodAutoscaler_To_autoscaling_HorizontalPodAutoscaler(in *autoscalingv2beta1.HorizontalPodAutoscaler, out *autoscaling.HorizontalPodAutoscaler, s conversion.Scope) error {
|
||||
if err := autoConvert_v2beta1_HorizontalPodAutoscaler_To_autoscaling_HorizontalPodAutoscaler(in, out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if selectorMetricsEnc, hasOtherMetrics := out.Annotations[autoscaling.MetricSpecsAnnotation]; hasOtherMetrics {
|
||||
var selectorMetrics []autoscalingv2beta1.MetricSpec
|
||||
if err := json.Unmarshal([]byte(selectorMetricsEnc), &selectorMetrics); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
convMetrics := make([]autoscaling.MetricSpec, len(selectorMetrics))
|
||||
for i, metric := range selectorMetrics {
|
||||
if err := Convert_v2beta1_MetricSpec_To_autoscaling_MetricSpec(&metric, &convMetrics[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
outMetrics := make([]autoscaling.MetricSpec, 0, len(selectorMetrics)+len(out.Spec.Metrics))
|
||||
for _, convMetric := range convMetrics {
|
||||
outMetrics = append(outMetrics, convMetric)
|
||||
}
|
||||
|
||||
for _, metric := range out.Spec.Metrics {
|
||||
outMetrics = append(outMetrics, metric)
|
||||
}
|
||||
|
||||
out.Spec.Metrics = outMetrics
|
||||
delete(out.Annotations, autoscaling.MetricSpecsAnnotation)
|
||||
}
|
||||
|
||||
if currentMetricsEnc, hasCurrentMetrics := out.Annotations[autoscaling.MetricStatusesAnnotation]; hasCurrentMetrics {
|
||||
var currentMetrics []autoscalingv2beta1.MetricStatus
|
||||
if err := json.Unmarshal([]byte(currentMetricsEnc), ¤tMetrics); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
outCurrentMetrics := make([]autoscaling.MetricStatus, 0, len(currentMetrics)+len(out.Status.CurrentMetrics))
|
||||
for i, currentMetric := range currentMetrics {
|
||||
if err := Convert_v2beta1_MetricStatus_To_autoscaling_MetricStatus(¤tMetric, &out.Status.CurrentMetrics[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
for _, currentMetric := range out.Status.CurrentMetrics {
|
||||
outCurrentMetrics = append(outCurrentMetrics, currentMetric)
|
||||
}
|
||||
|
||||
out.Status.CurrentMetrics = outCurrentMetrics
|
||||
delete(out.Annotations, autoscaling.MetricStatusesAnnotation)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_autoscaling_HorizontalPodAutoscaler_To_v2beta1_HorizontalPodAutoscaler(in *autoscaling.HorizontalPodAutoscaler, out *autoscalingv2beta1.HorizontalPodAutoscaler, s conversion.Scope) error {
|
||||
if err := autoConvert_autoscaling_HorizontalPodAutoscaler_To_v2beta1_HorizontalPodAutoscaler(in, out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
selectorMetrics := make([]autoscalingv2beta1.MetricSpec, 0, len(in.Spec.Metrics))
|
||||
for _, metric := range in.Spec.Metrics {
|
||||
if (metric.Object != nil && metric.Object.Metric.Selector == nil) ||
|
||||
(metric.Pods != nil && metric.Pods.Metric.Selector == nil) ||
|
||||
(metric.External != nil && metric.External.Metric.Selector == nil) ||
|
||||
(metric.Resource != nil) {
|
||||
continue
|
||||
}
|
||||
|
||||
convMetric := autoscalingv2beta1.MetricSpec{}
|
||||
if err := Convert_autoscaling_MetricSpec_To_v2beta1_MetricSpec(&metric, &convMetric, s); err != nil {
|
||||
return err
|
||||
}
|
||||
selectorMetrics = append(selectorMetrics, convMetric)
|
||||
}
|
||||
|
||||
currentMetrics := make([]autoscalingv2beta1.MetricStatus, 0, len(in.Status.CurrentMetrics))
|
||||
for _, currentMetric := range in.Status.CurrentMetrics {
|
||||
if (currentMetric.Object != nil && currentMetric.Object.Metric.Selector == nil) ||
|
||||
(currentMetric.Pods != nil && currentMetric.Pods.Metric.Selector == nil) ||
|
||||
(currentMetric.External != nil && currentMetric.External.Metric.Selector == nil) ||
|
||||
(currentMetric.Resource != nil) {
|
||||
continue
|
||||
}
|
||||
convMetric := autoscalingv2beta1.MetricStatus{}
|
||||
if err := Convert_autoscaling_MetricStatus_To_v2beta1_MetricStatus(¤tMetric, &convMetric, s); err != nil {
|
||||
return err
|
||||
}
|
||||
currentMetrics = append(currentMetrics, convMetric)
|
||||
}
|
||||
|
||||
if len(selectorMetrics) > 0 || len(currentMetrics) > 0 {
|
||||
old := out.Annotations
|
||||
out.Annotations = make(map[string]string, len(old)+2)
|
||||
if old != nil {
|
||||
for k, v := range old {
|
||||
out.Annotations[k] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(selectorMetrics) > 0 {
|
||||
selectorMetricsEnc, err := json.Marshal(selectorMetrics)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
out.Annotations[autoscaling.MetricSpecsAnnotation] = string(selectorMetricsEnc)
|
||||
}
|
||||
|
||||
if len(currentMetrics) > 0 {
|
||||
currentMetricsEnc, err := json.Marshal(currentMetrics)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
out.Annotations[autoscaling.MetricSpecsAnnotation] = string(currentMetricsEnc)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@@ -41,5 +41,5 @@ func init() {
|
||||
// We only register manually written functions here. The registration of the
|
||||
// generated functions takes place in the generated files. The separation
|
||||
// makes the code compile even when the generated files are missing.
|
||||
localSchemeBuilder.Register(addDefaultingFuncs)
|
||||
localSchemeBuilder.Register(addDefaultingFuncs, addConversionFuncs)
|
||||
}
|
||||
|
433
pkg/apis/autoscaling/v2beta1/zz_generated.conversion.go
generated
433
pkg/apis/autoscaling/v2beta1/zz_generated.conversion.go
generated
@@ -24,9 +24,14 @@ import (
|
||||
unsafe "unsafe"
|
||||
|
||||
v2beta1 "k8s.io/api/autoscaling/v2beta1"
|
||||
<<<<<<< HEAD
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
resource "k8s.io/apimachinery/pkg/api/resource"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
=======
|
||||
v1 "k8s.io/api/core/v1"
|
||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
>>>>>>> Update autoscaling conversion and validation for v2beta2 inclusion
|
||||
conversion "k8s.io/apimachinery/pkg/conversion"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
autoscaling "k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||
@@ -228,57 +233,33 @@ func Convert_autoscaling_CrossVersionObjectReference_To_v2beta1_CrossVersionObje
|
||||
}
|
||||
|
||||
func autoConvert_v2beta1_ExternalMetricSource_To_autoscaling_ExternalMetricSource(in *v2beta1.ExternalMetricSource, out *autoscaling.ExternalMetricSource, s conversion.Scope) error {
|
||||
out.MetricName = in.MetricName
|
||||
out.MetricSelector = (*v1.LabelSelector)(unsafe.Pointer(in.MetricSelector))
|
||||
out.TargetValue = (*resource.Quantity)(unsafe.Pointer(in.TargetValue))
|
||||
out.TargetAverageValue = (*resource.Quantity)(unsafe.Pointer(in.TargetAverageValue))
|
||||
// WARNING: in.MetricName requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.MetricSelector requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.TargetValue requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.TargetAverageValue requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v2beta1_ExternalMetricSource_To_autoscaling_ExternalMetricSource is an autogenerated conversion function.
|
||||
func Convert_v2beta1_ExternalMetricSource_To_autoscaling_ExternalMetricSource(in *v2beta1.ExternalMetricSource, out *autoscaling.ExternalMetricSource, s conversion.Scope) error {
|
||||
return autoConvert_v2beta1_ExternalMetricSource_To_autoscaling_ExternalMetricSource(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_autoscaling_ExternalMetricSource_To_v2beta1_ExternalMetricSource(in *autoscaling.ExternalMetricSource, out *v2beta1.ExternalMetricSource, s conversion.Scope) error {
|
||||
out.MetricName = in.MetricName
|
||||
out.MetricSelector = (*v1.LabelSelector)(unsafe.Pointer(in.MetricSelector))
|
||||
out.TargetValue = (*resource.Quantity)(unsafe.Pointer(in.TargetValue))
|
||||
out.TargetAverageValue = (*resource.Quantity)(unsafe.Pointer(in.TargetAverageValue))
|
||||
// WARNING: in.Metric requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.Target requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_autoscaling_ExternalMetricSource_To_v2beta1_ExternalMetricSource is an autogenerated conversion function.
|
||||
func Convert_autoscaling_ExternalMetricSource_To_v2beta1_ExternalMetricSource(in *autoscaling.ExternalMetricSource, out *v2beta1.ExternalMetricSource, s conversion.Scope) error {
|
||||
return autoConvert_autoscaling_ExternalMetricSource_To_v2beta1_ExternalMetricSource(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v2beta1_ExternalMetricStatus_To_autoscaling_ExternalMetricStatus(in *v2beta1.ExternalMetricStatus, out *autoscaling.ExternalMetricStatus, s conversion.Scope) error {
|
||||
out.MetricName = in.MetricName
|
||||
out.MetricSelector = (*v1.LabelSelector)(unsafe.Pointer(in.MetricSelector))
|
||||
out.CurrentValue = in.CurrentValue
|
||||
out.CurrentAverageValue = (*resource.Quantity)(unsafe.Pointer(in.CurrentAverageValue))
|
||||
// WARNING: in.MetricName requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.MetricSelector requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.CurrentValue requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.CurrentAverageValue requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v2beta1_ExternalMetricStatus_To_autoscaling_ExternalMetricStatus is an autogenerated conversion function.
|
||||
func Convert_v2beta1_ExternalMetricStatus_To_autoscaling_ExternalMetricStatus(in *v2beta1.ExternalMetricStatus, out *autoscaling.ExternalMetricStatus, s conversion.Scope) error {
|
||||
return autoConvert_v2beta1_ExternalMetricStatus_To_autoscaling_ExternalMetricStatus(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_autoscaling_ExternalMetricStatus_To_v2beta1_ExternalMetricStatus(in *autoscaling.ExternalMetricStatus, out *v2beta1.ExternalMetricStatus, s conversion.Scope) error {
|
||||
out.MetricName = in.MetricName
|
||||
out.MetricSelector = (*v1.LabelSelector)(unsafe.Pointer(in.MetricSelector))
|
||||
out.CurrentValue = in.CurrentValue
|
||||
out.CurrentAverageValue = (*resource.Quantity)(unsafe.Pointer(in.CurrentAverageValue))
|
||||
// WARNING: in.Metric requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.Current requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_autoscaling_ExternalMetricStatus_To_v2beta1_ExternalMetricStatus is an autogenerated conversion function.
|
||||
func Convert_autoscaling_ExternalMetricStatus_To_v2beta1_ExternalMetricStatus(in *autoscaling.ExternalMetricStatus, out *v2beta1.ExternalMetricStatus, s conversion.Scope) error {
|
||||
return autoConvert_autoscaling_ExternalMetricStatus_To_v2beta1_ExternalMetricStatus(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v2beta1_HorizontalPodAutoscaler_To_autoscaling_HorizontalPodAutoscaler(in *v2beta1.HorizontalPodAutoscaler, out *autoscaling.HorizontalPodAutoscaler, s conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
if err := Convert_v2beta1_HorizontalPodAutoscalerSpec_To_autoscaling_HorizontalPodAutoscalerSpec(&in.Spec, &out.Spec, s); err != nil {
|
||||
@@ -290,11 +271,6 @@ func autoConvert_v2beta1_HorizontalPodAutoscaler_To_autoscaling_HorizontalPodAut
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v2beta1_HorizontalPodAutoscaler_To_autoscaling_HorizontalPodAutoscaler is an autogenerated conversion function.
|
||||
func Convert_v2beta1_HorizontalPodAutoscaler_To_autoscaling_HorizontalPodAutoscaler(in *v2beta1.HorizontalPodAutoscaler, out *autoscaling.HorizontalPodAutoscaler, s conversion.Scope) error {
|
||||
return autoConvert_v2beta1_HorizontalPodAutoscaler_To_autoscaling_HorizontalPodAutoscaler(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_autoscaling_HorizontalPodAutoscaler_To_v2beta1_HorizontalPodAutoscaler(in *autoscaling.HorizontalPodAutoscaler, out *v2beta1.HorizontalPodAutoscaler, s conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
if err := Convert_autoscaling_HorizontalPodAutoscalerSpec_To_v2beta1_HorizontalPodAutoscalerSpec(&in.Spec, &out.Spec, s); err != nil {
|
||||
@@ -306,11 +282,6 @@ func autoConvert_autoscaling_HorizontalPodAutoscaler_To_v2beta1_HorizontalPodAut
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_autoscaling_HorizontalPodAutoscaler_To_v2beta1_HorizontalPodAutoscaler is an autogenerated conversion function.
|
||||
func Convert_autoscaling_HorizontalPodAutoscaler_To_v2beta1_HorizontalPodAutoscaler(in *autoscaling.HorizontalPodAutoscaler, out *v2beta1.HorizontalPodAutoscaler, s conversion.Scope) error {
|
||||
return autoConvert_autoscaling_HorizontalPodAutoscaler_To_v2beta1_HorizontalPodAutoscaler(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v2beta1_HorizontalPodAutoscalerCondition_To_autoscaling_HorizontalPodAutoscalerCondition(in *v2beta1.HorizontalPodAutoscalerCondition, out *autoscaling.HorizontalPodAutoscalerCondition, s conversion.Scope) error {
|
||||
out.Type = autoscaling.HorizontalPodAutoscalerConditionType(in.Type)
|
||||
out.Status = autoscaling.ConditionStatus(in.Status)
|
||||
@@ -327,7 +298,11 @@ func Convert_v2beta1_HorizontalPodAutoscalerCondition_To_autoscaling_HorizontalP
|
||||
|
||||
func autoConvert_autoscaling_HorizontalPodAutoscalerCondition_To_v2beta1_HorizontalPodAutoscalerCondition(in *autoscaling.HorizontalPodAutoscalerCondition, out *v2beta1.HorizontalPodAutoscalerCondition, s conversion.Scope) error {
|
||||
out.Type = v2beta1.HorizontalPodAutoscalerConditionType(in.Type)
|
||||
<<<<<<< HEAD
|
||||
out.Status = corev1.ConditionStatus(in.Status)
|
||||
=======
|
||||
out.Status = v1.ConditionStatus(in.Status)
|
||||
>>>>>>> Update autoscaling conversion and validation for v2beta2 inclusion
|
||||
out.LastTransitionTime = in.LastTransitionTime
|
||||
out.Reason = in.Reason
|
||||
out.Message = in.Message
|
||||
@@ -341,7 +316,17 @@ func Convert_autoscaling_HorizontalPodAutoscalerCondition_To_v2beta1_HorizontalP
|
||||
|
||||
func autoConvert_v2beta1_HorizontalPodAutoscalerList_To_autoscaling_HorizontalPodAutoscalerList(in *v2beta1.HorizontalPodAutoscalerList, out *autoscaling.HorizontalPodAutoscalerList, s conversion.Scope) error {
|
||||
out.ListMeta = in.ListMeta
|
||||
out.Items = *(*[]autoscaling.HorizontalPodAutoscaler)(unsafe.Pointer(&in.Items))
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]autoscaling.HorizontalPodAutoscaler, len(*in))
|
||||
for i := range *in {
|
||||
if err := Convert_v2beta1_HorizontalPodAutoscaler_To_autoscaling_HorizontalPodAutoscaler(&(*in)[i], &(*out)[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
out.Items = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -352,7 +337,17 @@ func Convert_v2beta1_HorizontalPodAutoscalerList_To_autoscaling_HorizontalPodAut
|
||||
|
||||
func autoConvert_autoscaling_HorizontalPodAutoscalerList_To_v2beta1_HorizontalPodAutoscalerList(in *autoscaling.HorizontalPodAutoscalerList, out *v2beta1.HorizontalPodAutoscalerList, s conversion.Scope) error {
|
||||
out.ListMeta = in.ListMeta
|
||||
out.Items = *(*[]v2beta1.HorizontalPodAutoscaler)(unsafe.Pointer(&in.Items))
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]v2beta1.HorizontalPodAutoscaler, len(*in))
|
||||
for i := range *in {
|
||||
if err := Convert_autoscaling_HorizontalPodAutoscaler_To_v2beta1_HorizontalPodAutoscaler(&(*in)[i], &(*out)[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
out.Items = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -367,7 +362,17 @@ func autoConvert_v2beta1_HorizontalPodAutoscalerSpec_To_autoscaling_HorizontalPo
|
||||
}
|
||||
out.MinReplicas = (*int32)(unsafe.Pointer(in.MinReplicas))
|
||||
out.MaxReplicas = in.MaxReplicas
|
||||
out.Metrics = *(*[]autoscaling.MetricSpec)(unsafe.Pointer(&in.Metrics))
|
||||
if in.Metrics != nil {
|
||||
in, out := &in.Metrics, &out.Metrics
|
||||
*out = make([]autoscaling.MetricSpec, len(*in))
|
||||
for i := range *in {
|
||||
if err := Convert_v2beta1_MetricSpec_To_autoscaling_MetricSpec(&(*in)[i], &(*out)[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
out.Metrics = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -382,7 +387,17 @@ func autoConvert_autoscaling_HorizontalPodAutoscalerSpec_To_v2beta1_HorizontalPo
|
||||
}
|
||||
out.MinReplicas = (*int32)(unsafe.Pointer(in.MinReplicas))
|
||||
out.MaxReplicas = in.MaxReplicas
|
||||
out.Metrics = *(*[]v2beta1.MetricSpec)(unsafe.Pointer(&in.Metrics))
|
||||
if in.Metrics != nil {
|
||||
in, out := &in.Metrics, &out.Metrics
|
||||
*out = make([]v2beta1.MetricSpec, len(*in))
|
||||
for i := range *in {
|
||||
if err := Convert_autoscaling_MetricSpec_To_v2beta1_MetricSpec(&(*in)[i], &(*out)[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
out.Metrics = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -393,10 +408,20 @@ func Convert_autoscaling_HorizontalPodAutoscalerSpec_To_v2beta1_HorizontalPodAut
|
||||
|
||||
func autoConvert_v2beta1_HorizontalPodAutoscalerStatus_To_autoscaling_HorizontalPodAutoscalerStatus(in *v2beta1.HorizontalPodAutoscalerStatus, out *autoscaling.HorizontalPodAutoscalerStatus, s conversion.Scope) error {
|
||||
out.ObservedGeneration = (*int64)(unsafe.Pointer(in.ObservedGeneration))
|
||||
out.LastScaleTime = (*v1.Time)(unsafe.Pointer(in.LastScaleTime))
|
||||
out.LastScaleTime = (*meta_v1.Time)(unsafe.Pointer(in.LastScaleTime))
|
||||
out.CurrentReplicas = in.CurrentReplicas
|
||||
out.DesiredReplicas = in.DesiredReplicas
|
||||
out.CurrentMetrics = *(*[]autoscaling.MetricStatus)(unsafe.Pointer(&in.CurrentMetrics))
|
||||
if in.CurrentMetrics != nil {
|
||||
in, out := &in.CurrentMetrics, &out.CurrentMetrics
|
||||
*out = make([]autoscaling.MetricStatus, len(*in))
|
||||
for i := range *in {
|
||||
if err := Convert_v2beta1_MetricStatus_To_autoscaling_MetricStatus(&(*in)[i], &(*out)[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
out.CurrentMetrics = nil
|
||||
}
|
||||
out.Conditions = *(*[]autoscaling.HorizontalPodAutoscalerCondition)(unsafe.Pointer(&in.Conditions))
|
||||
return nil
|
||||
}
|
||||
@@ -408,10 +433,20 @@ func Convert_v2beta1_HorizontalPodAutoscalerStatus_To_autoscaling_HorizontalPodA
|
||||
|
||||
func autoConvert_autoscaling_HorizontalPodAutoscalerStatus_To_v2beta1_HorizontalPodAutoscalerStatus(in *autoscaling.HorizontalPodAutoscalerStatus, out *v2beta1.HorizontalPodAutoscalerStatus, s conversion.Scope) error {
|
||||
out.ObservedGeneration = (*int64)(unsafe.Pointer(in.ObservedGeneration))
|
||||
out.LastScaleTime = (*v1.Time)(unsafe.Pointer(in.LastScaleTime))
|
||||
out.LastScaleTime = (*meta_v1.Time)(unsafe.Pointer(in.LastScaleTime))
|
||||
out.CurrentReplicas = in.CurrentReplicas
|
||||
out.DesiredReplicas = in.DesiredReplicas
|
||||
out.CurrentMetrics = *(*[]v2beta1.MetricStatus)(unsafe.Pointer(&in.CurrentMetrics))
|
||||
if in.CurrentMetrics != nil {
|
||||
in, out := &in.CurrentMetrics, &out.CurrentMetrics
|
||||
*out = make([]v2beta1.MetricStatus, len(*in))
|
||||
for i := range *in {
|
||||
if err := Convert_autoscaling_MetricStatus_To_v2beta1_MetricStatus(&(*in)[i], &(*out)[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
out.CurrentMetrics = nil
|
||||
}
|
||||
out.Conditions = *(*[]v2beta1.HorizontalPodAutoscalerCondition)(unsafe.Pointer(&in.Conditions))
|
||||
return nil
|
||||
}
|
||||
@@ -423,10 +458,42 @@ func Convert_autoscaling_HorizontalPodAutoscalerStatus_To_v2beta1_HorizontalPodA
|
||||
|
||||
func autoConvert_v2beta1_MetricSpec_To_autoscaling_MetricSpec(in *v2beta1.MetricSpec, out *autoscaling.MetricSpec, s conversion.Scope) error {
|
||||
out.Type = autoscaling.MetricSourceType(in.Type)
|
||||
out.Object = (*autoscaling.ObjectMetricSource)(unsafe.Pointer(in.Object))
|
||||
out.Pods = (*autoscaling.PodsMetricSource)(unsafe.Pointer(in.Pods))
|
||||
out.Resource = (*autoscaling.ResourceMetricSource)(unsafe.Pointer(in.Resource))
|
||||
out.External = (*autoscaling.ExternalMetricSource)(unsafe.Pointer(in.External))
|
||||
if in.Object != nil {
|
||||
in, out := &in.Object, &out.Object
|
||||
*out = new(autoscaling.ObjectMetricSource)
|
||||
if err := Convert_v2beta1_ObjectMetricSource_To_autoscaling_ObjectMetricSource(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Object = nil
|
||||
}
|
||||
if in.Pods != nil {
|
||||
in, out := &in.Pods, &out.Pods
|
||||
*out = new(autoscaling.PodsMetricSource)
|
||||
if err := Convert_v2beta1_PodsMetricSource_To_autoscaling_PodsMetricSource(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Pods = nil
|
||||
}
|
||||
if in.Resource != nil {
|
||||
in, out := &in.Resource, &out.Resource
|
||||
*out = new(autoscaling.ResourceMetricSource)
|
||||
if err := Convert_v2beta1_ResourceMetricSource_To_autoscaling_ResourceMetricSource(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Resource = nil
|
||||
}
|
||||
if in.External != nil {
|
||||
in, out := &in.External, &out.External
|
||||
*out = new(autoscaling.ExternalMetricSource)
|
||||
if err := Convert_v2beta1_ExternalMetricSource_To_autoscaling_ExternalMetricSource(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.External = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -437,10 +504,42 @@ func Convert_v2beta1_MetricSpec_To_autoscaling_MetricSpec(in *v2beta1.MetricSpec
|
||||
|
||||
func autoConvert_autoscaling_MetricSpec_To_v2beta1_MetricSpec(in *autoscaling.MetricSpec, out *v2beta1.MetricSpec, s conversion.Scope) error {
|
||||
out.Type = v2beta1.MetricSourceType(in.Type)
|
||||
out.Object = (*v2beta1.ObjectMetricSource)(unsafe.Pointer(in.Object))
|
||||
out.Pods = (*v2beta1.PodsMetricSource)(unsafe.Pointer(in.Pods))
|
||||
out.Resource = (*v2beta1.ResourceMetricSource)(unsafe.Pointer(in.Resource))
|
||||
out.External = (*v2beta1.ExternalMetricSource)(unsafe.Pointer(in.External))
|
||||
if in.Object != nil {
|
||||
in, out := &in.Object, &out.Object
|
||||
*out = new(v2beta1.ObjectMetricSource)
|
||||
if err := Convert_autoscaling_ObjectMetricSource_To_v2beta1_ObjectMetricSource(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Object = nil
|
||||
}
|
||||
if in.Pods != nil {
|
||||
in, out := &in.Pods, &out.Pods
|
||||
*out = new(v2beta1.PodsMetricSource)
|
||||
if err := Convert_autoscaling_PodsMetricSource_To_v2beta1_PodsMetricSource(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Pods = nil
|
||||
}
|
||||
if in.Resource != nil {
|
||||
in, out := &in.Resource, &out.Resource
|
||||
*out = new(v2beta1.ResourceMetricSource)
|
||||
if err := Convert_autoscaling_ResourceMetricSource_To_v2beta1_ResourceMetricSource(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Resource = nil
|
||||
}
|
||||
if in.External != nil {
|
||||
in, out := &in.External, &out.External
|
||||
*out = new(v2beta1.ExternalMetricSource)
|
||||
if err := Convert_autoscaling_ExternalMetricSource_To_v2beta1_ExternalMetricSource(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.External = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -451,10 +550,42 @@ func Convert_autoscaling_MetricSpec_To_v2beta1_MetricSpec(in *autoscaling.Metric
|
||||
|
||||
func autoConvert_v2beta1_MetricStatus_To_autoscaling_MetricStatus(in *v2beta1.MetricStatus, out *autoscaling.MetricStatus, s conversion.Scope) error {
|
||||
out.Type = autoscaling.MetricSourceType(in.Type)
|
||||
out.Object = (*autoscaling.ObjectMetricStatus)(unsafe.Pointer(in.Object))
|
||||
out.Pods = (*autoscaling.PodsMetricStatus)(unsafe.Pointer(in.Pods))
|
||||
out.Resource = (*autoscaling.ResourceMetricStatus)(unsafe.Pointer(in.Resource))
|
||||
out.External = (*autoscaling.ExternalMetricStatus)(unsafe.Pointer(in.External))
|
||||
if in.Object != nil {
|
||||
in, out := &in.Object, &out.Object
|
||||
*out = new(autoscaling.ObjectMetricStatus)
|
||||
if err := Convert_v2beta1_ObjectMetricStatus_To_autoscaling_ObjectMetricStatus(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Object = nil
|
||||
}
|
||||
if in.Pods != nil {
|
||||
in, out := &in.Pods, &out.Pods
|
||||
*out = new(autoscaling.PodsMetricStatus)
|
||||
if err := Convert_v2beta1_PodsMetricStatus_To_autoscaling_PodsMetricStatus(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Pods = nil
|
||||
}
|
||||
if in.Resource != nil {
|
||||
in, out := &in.Resource, &out.Resource
|
||||
*out = new(autoscaling.ResourceMetricStatus)
|
||||
if err := Convert_v2beta1_ResourceMetricStatus_To_autoscaling_ResourceMetricStatus(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Resource = nil
|
||||
}
|
||||
if in.External != nil {
|
||||
in, out := &in.External, &out.External
|
||||
*out = new(autoscaling.ExternalMetricStatus)
|
||||
if err := Convert_v2beta1_ExternalMetricStatus_To_autoscaling_ExternalMetricStatus(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.External = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -465,10 +596,42 @@ func Convert_v2beta1_MetricStatus_To_autoscaling_MetricStatus(in *v2beta1.Metric
|
||||
|
||||
func autoConvert_autoscaling_MetricStatus_To_v2beta1_MetricStatus(in *autoscaling.MetricStatus, out *v2beta1.MetricStatus, s conversion.Scope) error {
|
||||
out.Type = v2beta1.MetricSourceType(in.Type)
|
||||
out.Object = (*v2beta1.ObjectMetricStatus)(unsafe.Pointer(in.Object))
|
||||
out.Pods = (*v2beta1.PodsMetricStatus)(unsafe.Pointer(in.Pods))
|
||||
out.Resource = (*v2beta1.ResourceMetricStatus)(unsafe.Pointer(in.Resource))
|
||||
out.External = (*v2beta1.ExternalMetricStatus)(unsafe.Pointer(in.External))
|
||||
if in.Object != nil {
|
||||
in, out := &in.Object, &out.Object
|
||||
*out = new(v2beta1.ObjectMetricStatus)
|
||||
if err := Convert_autoscaling_ObjectMetricStatus_To_v2beta1_ObjectMetricStatus(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Object = nil
|
||||
}
|
||||
if in.Pods != nil {
|
||||
in, out := &in.Pods, &out.Pods
|
||||
*out = new(v2beta1.PodsMetricStatus)
|
||||
if err := Convert_autoscaling_PodsMetricStatus_To_v2beta1_PodsMetricStatus(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Pods = nil
|
||||
}
|
||||
if in.Resource != nil {
|
||||
in, out := &in.Resource, &out.Resource
|
||||
*out = new(v2beta1.ResourceMetricStatus)
|
||||
if err := Convert_autoscaling_ResourceMetricStatus_To_v2beta1_ResourceMetricStatus(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Resource = nil
|
||||
}
|
||||
if in.External != nil {
|
||||
in, out := &in.External, &out.External
|
||||
*out = new(v2beta1.ExternalMetricStatus)
|
||||
if err := Convert_autoscaling_ExternalMetricStatus_To_v2beta1_ExternalMetricStatus(*in, *out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.External = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -478,149 +641,103 @@ func Convert_autoscaling_MetricStatus_To_v2beta1_MetricStatus(in *autoscaling.Me
|
||||
}
|
||||
|
||||
func autoConvert_v2beta1_ObjectMetricSource_To_autoscaling_ObjectMetricSource(in *v2beta1.ObjectMetricSource, out *autoscaling.ObjectMetricSource, s conversion.Scope) error {
|
||||
if err := Convert_v2beta1_CrossVersionObjectReference_To_autoscaling_CrossVersionObjectReference(&in.Target, &out.Target, s); err != nil {
|
||||
if err := Convert_v2beta1_CrossVersionObjectReference_To_autoscaling_MetricTarget(&in.Target, &out.Target, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.MetricName = in.MetricName
|
||||
out.TargetValue = in.TargetValue
|
||||
// WARNING: in.MetricName requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.TargetValue requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.Selector requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.AverageValue requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v2beta1_ObjectMetricSource_To_autoscaling_ObjectMetricSource is an autogenerated conversion function.
|
||||
func Convert_v2beta1_ObjectMetricSource_To_autoscaling_ObjectMetricSource(in *v2beta1.ObjectMetricSource, out *autoscaling.ObjectMetricSource, s conversion.Scope) error {
|
||||
return autoConvert_v2beta1_ObjectMetricSource_To_autoscaling_ObjectMetricSource(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_autoscaling_ObjectMetricSource_To_v2beta1_ObjectMetricSource(in *autoscaling.ObjectMetricSource, out *v2beta1.ObjectMetricSource, s conversion.Scope) error {
|
||||
if err := Convert_autoscaling_CrossVersionObjectReference_To_v2beta1_CrossVersionObjectReference(&in.Target, &out.Target, s); err != nil {
|
||||
// WARNING: in.DescribedObject requires manual conversion: does not exist in peer-type
|
||||
if err := Convert_autoscaling_MetricTarget_To_v2beta1_CrossVersionObjectReference(&in.Target, &out.Target, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.MetricName = in.MetricName
|
||||
out.TargetValue = in.TargetValue
|
||||
// WARNING: in.Metric requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_autoscaling_ObjectMetricSource_To_v2beta1_ObjectMetricSource is an autogenerated conversion function.
|
||||
func Convert_autoscaling_ObjectMetricSource_To_v2beta1_ObjectMetricSource(in *autoscaling.ObjectMetricSource, out *v2beta1.ObjectMetricSource, s conversion.Scope) error {
|
||||
return autoConvert_autoscaling_ObjectMetricSource_To_v2beta1_ObjectMetricSource(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v2beta1_ObjectMetricStatus_To_autoscaling_ObjectMetricStatus(in *v2beta1.ObjectMetricStatus, out *autoscaling.ObjectMetricStatus, s conversion.Scope) error {
|
||||
if err := Convert_v2beta1_CrossVersionObjectReference_To_autoscaling_CrossVersionObjectReference(&in.Target, &out.Target, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.MetricName = in.MetricName
|
||||
out.CurrentValue = in.CurrentValue
|
||||
// WARNING: in.Target requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.MetricName requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.CurrentValue requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.Selector requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.AverageValue requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v2beta1_ObjectMetricStatus_To_autoscaling_ObjectMetricStatus is an autogenerated conversion function.
|
||||
func Convert_v2beta1_ObjectMetricStatus_To_autoscaling_ObjectMetricStatus(in *v2beta1.ObjectMetricStatus, out *autoscaling.ObjectMetricStatus, s conversion.Scope) error {
|
||||
return autoConvert_v2beta1_ObjectMetricStatus_To_autoscaling_ObjectMetricStatus(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_autoscaling_ObjectMetricStatus_To_v2beta1_ObjectMetricStatus(in *autoscaling.ObjectMetricStatus, out *v2beta1.ObjectMetricStatus, s conversion.Scope) error {
|
||||
if err := Convert_autoscaling_CrossVersionObjectReference_To_v2beta1_CrossVersionObjectReference(&in.Target, &out.Target, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.MetricName = in.MetricName
|
||||
out.CurrentValue = in.CurrentValue
|
||||
// WARNING: in.Metric requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.Current requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.DescribedObject requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_autoscaling_ObjectMetricStatus_To_v2beta1_ObjectMetricStatus is an autogenerated conversion function.
|
||||
func Convert_autoscaling_ObjectMetricStatus_To_v2beta1_ObjectMetricStatus(in *autoscaling.ObjectMetricStatus, out *v2beta1.ObjectMetricStatus, s conversion.Scope) error {
|
||||
return autoConvert_autoscaling_ObjectMetricStatus_To_v2beta1_ObjectMetricStatus(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v2beta1_PodsMetricSource_To_autoscaling_PodsMetricSource(in *v2beta1.PodsMetricSource, out *autoscaling.PodsMetricSource, s conversion.Scope) error {
|
||||
out.MetricName = in.MetricName
|
||||
out.TargetAverageValue = in.TargetAverageValue
|
||||
// WARNING: in.MetricName requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.TargetAverageValue requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.Selector requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.Value requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v2beta1_PodsMetricSource_To_autoscaling_PodsMetricSource is an autogenerated conversion function.
|
||||
func Convert_v2beta1_PodsMetricSource_To_autoscaling_PodsMetricSource(in *v2beta1.PodsMetricSource, out *autoscaling.PodsMetricSource, s conversion.Scope) error {
|
||||
return autoConvert_v2beta1_PodsMetricSource_To_autoscaling_PodsMetricSource(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_autoscaling_PodsMetricSource_To_v2beta1_PodsMetricSource(in *autoscaling.PodsMetricSource, out *v2beta1.PodsMetricSource, s conversion.Scope) error {
|
||||
out.MetricName = in.MetricName
|
||||
out.TargetAverageValue = in.TargetAverageValue
|
||||
// WARNING: in.Metric requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.Target requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_autoscaling_PodsMetricSource_To_v2beta1_PodsMetricSource is an autogenerated conversion function.
|
||||
func Convert_autoscaling_PodsMetricSource_To_v2beta1_PodsMetricSource(in *autoscaling.PodsMetricSource, out *v2beta1.PodsMetricSource, s conversion.Scope) error {
|
||||
return autoConvert_autoscaling_PodsMetricSource_To_v2beta1_PodsMetricSource(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v2beta1_PodsMetricStatus_To_autoscaling_PodsMetricStatus(in *v2beta1.PodsMetricStatus, out *autoscaling.PodsMetricStatus, s conversion.Scope) error {
|
||||
out.MetricName = in.MetricName
|
||||
out.CurrentAverageValue = in.CurrentAverageValue
|
||||
// WARNING: in.MetricName requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.CurrentAverageValue requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.Selector requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.Value requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v2beta1_PodsMetricStatus_To_autoscaling_PodsMetricStatus is an autogenerated conversion function.
|
||||
func Convert_v2beta1_PodsMetricStatus_To_autoscaling_PodsMetricStatus(in *v2beta1.PodsMetricStatus, out *autoscaling.PodsMetricStatus, s conversion.Scope) error {
|
||||
return autoConvert_v2beta1_PodsMetricStatus_To_autoscaling_PodsMetricStatus(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_autoscaling_PodsMetricStatus_To_v2beta1_PodsMetricStatus(in *autoscaling.PodsMetricStatus, out *v2beta1.PodsMetricStatus, s conversion.Scope) error {
|
||||
out.MetricName = in.MetricName
|
||||
out.CurrentAverageValue = in.CurrentAverageValue
|
||||
// WARNING: in.Metric requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.Current requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_autoscaling_PodsMetricStatus_To_v2beta1_PodsMetricStatus is an autogenerated conversion function.
|
||||
func Convert_autoscaling_PodsMetricStatus_To_v2beta1_PodsMetricStatus(in *autoscaling.PodsMetricStatus, out *v2beta1.PodsMetricStatus, s conversion.Scope) error {
|
||||
return autoConvert_autoscaling_PodsMetricStatus_To_v2beta1_PodsMetricStatus(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v2beta1_ResourceMetricSource_To_autoscaling_ResourceMetricSource(in *v2beta1.ResourceMetricSource, out *autoscaling.ResourceMetricSource, s conversion.Scope) error {
|
||||
out.Name = core.ResourceName(in.Name)
|
||||
out.TargetAverageUtilization = (*int32)(unsafe.Pointer(in.TargetAverageUtilization))
|
||||
out.TargetAverageValue = (*resource.Quantity)(unsafe.Pointer(in.TargetAverageValue))
|
||||
// WARNING: in.TargetAverageUtilization requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.TargetAverageValue requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v2beta1_ResourceMetricSource_To_autoscaling_ResourceMetricSource is an autogenerated conversion function.
|
||||
func Convert_v2beta1_ResourceMetricSource_To_autoscaling_ResourceMetricSource(in *v2beta1.ResourceMetricSource, out *autoscaling.ResourceMetricSource, s conversion.Scope) error {
|
||||
return autoConvert_v2beta1_ResourceMetricSource_To_autoscaling_ResourceMetricSource(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_autoscaling_ResourceMetricSource_To_v2beta1_ResourceMetricSource(in *autoscaling.ResourceMetricSource, out *v2beta1.ResourceMetricSource, s conversion.Scope) error {
|
||||
<<<<<<< HEAD
|
||||
out.Name = corev1.ResourceName(in.Name)
|
||||
out.TargetAverageUtilization = (*int32)(unsafe.Pointer(in.TargetAverageUtilization))
|
||||
out.TargetAverageValue = (*resource.Quantity)(unsafe.Pointer(in.TargetAverageValue))
|
||||
=======
|
||||
out.Name = v1.ResourceName(in.Name)
|
||||
// WARNING: in.Target requires manual conversion: does not exist in peer-type
|
||||
>>>>>>> Update autoscaling conversion and validation for v2beta2 inclusion
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_autoscaling_ResourceMetricSource_To_v2beta1_ResourceMetricSource is an autogenerated conversion function.
|
||||
func Convert_autoscaling_ResourceMetricSource_To_v2beta1_ResourceMetricSource(in *autoscaling.ResourceMetricSource, out *v2beta1.ResourceMetricSource, s conversion.Scope) error {
|
||||
return autoConvert_autoscaling_ResourceMetricSource_To_v2beta1_ResourceMetricSource(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v2beta1_ResourceMetricStatus_To_autoscaling_ResourceMetricStatus(in *v2beta1.ResourceMetricStatus, out *autoscaling.ResourceMetricStatus, s conversion.Scope) error {
|
||||
out.Name = core.ResourceName(in.Name)
|
||||
out.CurrentAverageUtilization = (*int32)(unsafe.Pointer(in.CurrentAverageUtilization))
|
||||
out.CurrentAverageValue = in.CurrentAverageValue
|
||||
// WARNING: in.CurrentAverageUtilization requires manual conversion: does not exist in peer-type
|
||||
// WARNING: in.CurrentAverageValue requires manual conversion: does not exist in peer-type
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v2beta1_ResourceMetricStatus_To_autoscaling_ResourceMetricStatus is an autogenerated conversion function.
|
||||
func Convert_v2beta1_ResourceMetricStatus_To_autoscaling_ResourceMetricStatus(in *v2beta1.ResourceMetricStatus, out *autoscaling.ResourceMetricStatus, s conversion.Scope) error {
|
||||
return autoConvert_v2beta1_ResourceMetricStatus_To_autoscaling_ResourceMetricStatus(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_autoscaling_ResourceMetricStatus_To_v2beta1_ResourceMetricStatus(in *autoscaling.ResourceMetricStatus, out *v2beta1.ResourceMetricStatus, s conversion.Scope) error {
|
||||
<<<<<<< HEAD
|
||||
out.Name = corev1.ResourceName(in.Name)
|
||||
out.CurrentAverageUtilization = (*int32)(unsafe.Pointer(in.CurrentAverageUtilization))
|
||||
out.CurrentAverageValue = in.CurrentAverageValue
|
||||
=======
|
||||
out.Name = v1.ResourceName(in.Name)
|
||||
// WARNING: in.Current requires manual conversion: does not exist in peer-type
|
||||
>>>>>>> Update autoscaling conversion and validation for v2beta2 inclusion
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_autoscaling_ResourceMetricStatus_To_v2beta1_ResourceMetricStatus is an autogenerated conversion function.
|
||||
func Convert_autoscaling_ResourceMetricStatus_To_v2beta1_ResourceMetricStatus(in *autoscaling.ResourceMetricStatus, out *v2beta1.ResourceMetricStatus, s conversion.Scope) error {
|
||||
return autoConvert_autoscaling_ResourceMetricStatus_To_v2beta1_ResourceMetricStatus(in, out, s)
|
||||
}
|
||||
|
@@ -178,14 +178,16 @@ func validateMetricSpec(spec autoscaling.MetricSpec, fldPath *field.Path) field.
|
||||
func validateObjectSource(src *autoscaling.ObjectMetricSource, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
|
||||
allErrs = append(allErrs, ValidateCrossVersionObjectReference(src.Target, fldPath.Child("target"))...)
|
||||
|
||||
if len(src.MetricName) == 0 {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("metricName"), "must specify a metric name"))
|
||||
allErrs = append(allErrs, ValidateCrossVersionObjectReference(src.DescribedObject, fldPath.Child("describedObject"))...)
|
||||
allErrs = append(allErrs, validateMetricIdentifier(src.Metric, fldPath.Child("metric"))...)
|
||||
if &src.Target == nil {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("target"), "must specify a metric target"))
|
||||
} else {
|
||||
allErrs = append(allErrs, validateMetricTarget(src.Target, fldPath.Child("target"))...)
|
||||
}
|
||||
|
||||
if src.TargetValue.Sign() != 1 {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("targetValue"), "must specify a positive target value"))
|
||||
if src.Target.Value == nil && src.Target.AverageValue == nil {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("target").Child("averageValue"), "must set either a target value or averageValue"))
|
||||
}
|
||||
|
||||
return allErrs
|
||||
@@ -194,28 +196,19 @@ func validateObjectSource(src *autoscaling.ObjectMetricSource, fldPath *field.Pa
|
||||
func validateExternalSource(src *autoscaling.ExternalMetricSource, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
|
||||
if len(src.MetricName) == 0 {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("metricName"), "must specify a metric name"))
|
||||
allErrs = append(allErrs, validateMetricIdentifier(src.Metric, fldPath.Child("metric"))...)
|
||||
if &src.Target == nil {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("target"), "must specify a metric target"))
|
||||
} else {
|
||||
for _, msg := range pathvalidation.IsValidPathSegmentName(src.MetricName) {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("metricName"), src.MetricName, msg))
|
||||
}
|
||||
allErrs = append(allErrs, validateMetricTarget(src.Target, fldPath.Child("target"))...)
|
||||
}
|
||||
|
||||
if src.TargetValue == nil && src.TargetAverageValue == nil {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("targetValue"), "must set either a target value for metric or a per-pod target"))
|
||||
if src.Target.Value == nil && src.Target.AverageValue == nil {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("target").Child("averageValue"), "must set either a target value for metric or a per-pod target"))
|
||||
}
|
||||
|
||||
if src.TargetValue != nil && src.TargetAverageValue != nil {
|
||||
allErrs = append(allErrs, field.Forbidden(fldPath.Child("targetValue"), "may not set both a target value for metric and a per-pod target"))
|
||||
}
|
||||
|
||||
if src.TargetAverageValue != nil && src.TargetAverageValue.Sign() != 1 {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("targetAverageValue"), src.TargetAverageValue, "must be positive"))
|
||||
}
|
||||
|
||||
if src.TargetValue != nil && src.TargetValue.Sign() != 1 {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("targetValue"), src.TargetValue, "must be positive"))
|
||||
if src.Target.Value != nil && src.Target.AverageValue != nil {
|
||||
allErrs = append(allErrs, field.Forbidden(fldPath.Child("target").Child("value"), "may not set both a target value for metric and a per-pod target"))
|
||||
}
|
||||
|
||||
return allErrs
|
||||
@@ -224,12 +217,15 @@ func validateExternalSource(src *autoscaling.ExternalMetricSource, fldPath *fiel
|
||||
func validatePodsSource(src *autoscaling.PodsMetricSource, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
|
||||
if len(src.MetricName) == 0 {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("metricName"), "must specify a metric name"))
|
||||
allErrs = append(allErrs, validateMetricIdentifier(src.Metric, fldPath.Child("metric"))...)
|
||||
if &src.Target == nil {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("target"), "must specify a metric target"))
|
||||
} else {
|
||||
allErrs = append(allErrs, validateMetricTarget(src.Target, fldPath.Child("target"))...)
|
||||
}
|
||||
|
||||
if src.TargetAverageValue.Sign() != 1 {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("targetAverageValue"), "must specify a positive target value"))
|
||||
if src.Target.AverageValue == nil {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("target").Child("averageValue"), "must specify a positive target averageValue"))
|
||||
}
|
||||
|
||||
return allErrs
|
||||
@@ -241,22 +237,60 @@ func validateResourceSource(src *autoscaling.ResourceMetricSource, fldPath *fiel
|
||||
if len(src.Name) == 0 {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("name"), "must specify a resource name"))
|
||||
}
|
||||
|
||||
if src.TargetAverageUtilization == nil && src.TargetAverageValue == nil {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("targetAverageUtilization"), "must set either a target raw value or a target utilization"))
|
||||
if &src.Target == nil {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("target"), "must specify a metric target"))
|
||||
} else {
|
||||
allErrs = append(allErrs, validateMetricTarget(src.Target, fldPath.Child("target"))...)
|
||||
}
|
||||
|
||||
if src.TargetAverageUtilization != nil && *src.TargetAverageUtilization < 1 {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("targetAverageUtilization"), src.TargetAverageUtilization, "must be greater than 0"))
|
||||
if src.Target.AverageUtilization == nil && src.Target.AverageValue == nil {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("target").Child("averageUtilization"), "must set either a target raw value or a target utilization"))
|
||||
}
|
||||
|
||||
if src.TargetAverageUtilization != nil && src.TargetAverageValue != nil {
|
||||
allErrs = append(allErrs, field.Forbidden(fldPath.Child("targetAverageValue"), "may not set both a target raw value and a target utilization"))
|
||||
}
|
||||
|
||||
if src.TargetAverageValue != nil && src.TargetAverageValue.Sign() != 1 {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("targetAverageValue"), src.TargetAverageValue, "must be positive"))
|
||||
if src.Target.AverageUtilization != nil && src.Target.AverageValue != nil {
|
||||
allErrs = append(allErrs, field.Forbidden(fldPath.Child("target").Child("averageValue"), "may not set both a target raw value and a target utilization"))
|
||||
}
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func validateMetricTarget(mt autoscaling.MetricTarget, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
|
||||
if len(mt.Type) == 0 {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("type"), "must specify a metric target type"))
|
||||
}
|
||||
|
||||
if mt.Type != autoscaling.UtilizationMetricType &&
|
||||
mt.Type != autoscaling.ValueMetricType &&
|
||||
mt.Type != autoscaling.AverageValueMetricType {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("type"), mt.Type, "must be either Utilization, Value, or AverageValue"))
|
||||
}
|
||||
|
||||
if mt.Value != nil && mt.Value.Sign() != 1 {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("value"), mt.Value, "must be positive"))
|
||||
}
|
||||
|
||||
if mt.AverageValue != nil && mt.AverageValue.Sign() != 1 {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("averageValue"), mt.AverageValue, "must be positive"))
|
||||
}
|
||||
|
||||
if mt.AverageUtilization != nil && *mt.AverageUtilization < 1 {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("averageUtilization"), mt.AverageUtilization, "must be greater than 0"))
|
||||
}
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func validateMetricIdentifier(id autoscaling.MetricIdentifier, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
|
||||
if len(id.Name) == 0 {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("name"), "must specify a metric name"))
|
||||
} else {
|
||||
for _, msg := range pathvalidation.IsValidPathSegmentName(id.Name) {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("name"), id.Name, msg))
|
||||
}
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
@@ -92,6 +92,10 @@ func TestValidateScale(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
metricLabelSelector, err := metav1.ParseToLabelSelector("label=value")
|
||||
if err != nil {
|
||||
t.Errorf("unable to parse label selector: %v", err)
|
||||
}
|
||||
successCases := []autoscaling.HorizontalPodAutoscaler{
|
||||
{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
@@ -110,7 +114,10 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
Type: autoscaling.ResourceMetricSourceType,
|
||||
Resource: &autoscaling.ResourceMetricSource{
|
||||
Name: api.ResourceCPU,
|
||||
TargetAverageUtilization: utilpointer.Int32Ptr(70),
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.UtilizationMetricType,
|
||||
AverageUtilization: utilpointer.Int32Ptr(70),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -146,8 +153,11 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
{
|
||||
Type: autoscaling.ResourceMetricSourceType,
|
||||
Resource: &autoscaling.ResourceMetricSource{
|
||||
Name: api.ResourceCPU,
|
||||
TargetAverageValue: resource.NewMilliQuantity(300, resource.DecimalSI),
|
||||
Name: api.ResourceCPU,
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.AverageValueMetricType,
|
||||
AverageValue: resource.NewMilliQuantity(300, resource.DecimalSI),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -169,8 +179,13 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
{
|
||||
Type: autoscaling.PodsMetricSourceType,
|
||||
Pods: &autoscaling.PodsMetricSource{
|
||||
MetricName: "somemetric",
|
||||
TargetAverageValue: *resource.NewMilliQuantity(300, resource.DecimalSI),
|
||||
Metric: autoscaling.MetricIdentifier{
|
||||
Name: "somemetric",
|
||||
},
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.AverageValueMetricType,
|
||||
AverageValue: resource.NewMilliQuantity(300, resource.DecimalSI),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -192,12 +207,17 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
{
|
||||
Type: autoscaling.ObjectMetricSourceType,
|
||||
Object: &autoscaling.ObjectMetricSource{
|
||||
Target: autoscaling.CrossVersionObjectReference{
|
||||
DescribedObject: autoscaling.CrossVersionObjectReference{
|
||||
Kind: "ReplicationController",
|
||||
Name: "myrc",
|
||||
},
|
||||
MetricName: "somemetric",
|
||||
TargetValue: *resource.NewMilliQuantity(300, resource.DecimalSI),
|
||||
Metric: autoscaling.MetricIdentifier{
|
||||
Name: "somemetric",
|
||||
},
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.ValueMetricType,
|
||||
Value: resource.NewMilliQuantity(300, resource.DecimalSI),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -219,13 +239,14 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
{
|
||||
Type: autoscaling.ExternalMetricSourceType,
|
||||
External: &autoscaling.ExternalMetricSource{
|
||||
MetricName: "somemetric",
|
||||
MetricSelector: &metav1.LabelSelector{
|
||||
MatchLabels: map[string]string{
|
||||
"label": "value",
|
||||
},
|
||||
Metric: autoscaling.MetricIdentifier{
|
||||
Name: "somemetric",
|
||||
Selector: metricLabelSelector,
|
||||
},
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.ValueMetricType,
|
||||
Value: resource.NewMilliQuantity(300, resource.DecimalSI),
|
||||
},
|
||||
TargetValue: resource.NewMilliQuantity(300, resource.DecimalSI),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -247,13 +268,14 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
{
|
||||
Type: autoscaling.ExternalMetricSourceType,
|
||||
External: &autoscaling.ExternalMetricSource{
|
||||
MetricName: "somemetric",
|
||||
MetricSelector: &metav1.LabelSelector{
|
||||
MatchLabels: map[string]string{
|
||||
"label": "value",
|
||||
},
|
||||
Metric: autoscaling.MetricIdentifier{
|
||||
Name: "somemetric",
|
||||
Selector: metricLabelSelector,
|
||||
},
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.AverageValueMetricType,
|
||||
AverageValue: resource.NewMilliQuantity(300, resource.DecimalSI),
|
||||
},
|
||||
TargetAverageValue: resource.NewMilliQuantity(300, resource.DecimalSI),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -282,7 +304,10 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
Type: autoscaling.ResourceMetricSourceType,
|
||||
Resource: &autoscaling.ResourceMetricSource{
|
||||
Name: api.ResourceCPU,
|
||||
TargetAverageUtilization: utilpointer.Int32Ptr(70),
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.UtilizationMetricType,
|
||||
AverageUtilization: utilpointer.Int32Ptr(70),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -302,7 +327,10 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
Type: autoscaling.ResourceMetricSourceType,
|
||||
Resource: &autoscaling.ResourceMetricSource{
|
||||
Name: api.ResourceCPU,
|
||||
TargetAverageUtilization: utilpointer.Int32Ptr(70),
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.UtilizationMetricType,
|
||||
AverageUtilization: utilpointer.Int32Ptr(70),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -322,7 +350,10 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
Type: autoscaling.ResourceMetricSourceType,
|
||||
Resource: &autoscaling.ResourceMetricSource{
|
||||
Name: api.ResourceCPU,
|
||||
TargetAverageUtilization: utilpointer.Int32Ptr(70),
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.UtilizationMetricType,
|
||||
AverageUtilization: utilpointer.Int32Ptr(70),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -342,7 +373,10 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
Type: autoscaling.ResourceMetricSourceType,
|
||||
Resource: &autoscaling.ResourceMetricSource{
|
||||
Name: api.ResourceCPU,
|
||||
TargetAverageUtilization: utilpointer.Int32Ptr(70),
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.UtilizationMetricType,
|
||||
AverageUtilization: utilpointer.Int32Ptr(70),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -393,8 +427,11 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
Type: autoscaling.ResourceMetricSourceType,
|
||||
Resource: &autoscaling.ResourceMetricSource{
|
||||
Name: api.ResourceCPU,
|
||||
TargetAverageUtilization: utilpointer.Int32Ptr(70),
|
||||
TargetAverageValue: resource.NewMilliQuantity(300, resource.DecimalSI),
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.UtilizationMetricType,
|
||||
AverageUtilization: utilpointer.Int32Ptr(70),
|
||||
AverageValue: resource.NewMilliQuantity(300, resource.DecimalSI),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -413,7 +450,10 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
{
|
||||
Type: autoscaling.ResourceMetricSourceType,
|
||||
Resource: &autoscaling.ResourceMetricSource{
|
||||
TargetAverageUtilization: utilpointer.Int32Ptr(70),
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.UtilizationMetricType,
|
||||
AverageUtilization: utilpointer.Int32Ptr(70),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -433,7 +473,10 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
Type: autoscaling.ResourceMetricSourceType,
|
||||
Resource: &autoscaling.ResourceMetricSource{
|
||||
Name: api.ResourceCPU,
|
||||
TargetAverageUtilization: utilpointer.Int32Ptr(-10),
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.UtilizationMetricType,
|
||||
AverageUtilization: utilpointer.Int32Ptr(-10),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -453,6 +496,9 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
Type: autoscaling.ResourceMetricSourceType,
|
||||
Resource: &autoscaling.ResourceMetricSource{
|
||||
Name: api.ResourceCPU,
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.ValueMetricType,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -471,7 +517,11 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
{
|
||||
Type: autoscaling.PodsMetricSourceType,
|
||||
Pods: &autoscaling.PodsMetricSource{
|
||||
TargetAverageValue: *resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||
Metric: autoscaling.MetricIdentifier{},
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.ValueMetricType,
|
||||
AverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -490,36 +540,18 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
{
|
||||
Type: autoscaling.PodsMetricSourceType,
|
||||
Pods: &autoscaling.PodsMetricSource{
|
||||
MetricName: "somemetric",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
msg: "must specify a positive target value",
|
||||
},
|
||||
{
|
||||
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
|
||||
Spec: autoscaling.HorizontalPodAutoscalerSpec{
|
||||
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
|
||||
MinReplicas: utilpointer.Int32Ptr(1),
|
||||
MaxReplicas: 5,
|
||||
Metrics: []autoscaling.MetricSpec{
|
||||
{
|
||||
Type: autoscaling.ObjectMetricSourceType,
|
||||
Object: &autoscaling.ObjectMetricSource{
|
||||
Target: autoscaling.CrossVersionObjectReference{
|
||||
Name: "myrc",
|
||||
Metric: autoscaling.MetricIdentifier{
|
||||
Name: "somemetric",
|
||||
},
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.ValueMetricType,
|
||||
},
|
||||
MetricName: "somemetric",
|
||||
TargetValue: *resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
msg: "target.kind: Required",
|
||||
msg: "must specify a positive target averageValue",
|
||||
},
|
||||
{
|
||||
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
|
||||
@@ -532,11 +564,70 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
{
|
||||
Type: autoscaling.ObjectMetricSourceType,
|
||||
Object: &autoscaling.ObjectMetricSource{
|
||||
Target: autoscaling.CrossVersionObjectReference{
|
||||
DescribedObject: autoscaling.CrossVersionObjectReference{
|
||||
Kind: "ReplicationController",
|
||||
Name: "myrc",
|
||||
},
|
||||
TargetValue: *resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||
Metric: autoscaling.MetricIdentifier{
|
||||
Name: "somemetric",
|
||||
},
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.ValueMetricType,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
msg: "must set either a target value or averageValue",
|
||||
},
|
||||
{
|
||||
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
|
||||
Spec: autoscaling.HorizontalPodAutoscalerSpec{
|
||||
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
|
||||
MinReplicas: utilpointer.Int32Ptr(1),
|
||||
MaxReplicas: 5,
|
||||
Metrics: []autoscaling.MetricSpec{
|
||||
{
|
||||
Type: autoscaling.ObjectMetricSourceType,
|
||||
Object: &autoscaling.ObjectMetricSource{
|
||||
DescribedObject: autoscaling.CrossVersionObjectReference{
|
||||
Name: "myrc",
|
||||
},
|
||||
Metric: autoscaling.MetricIdentifier{
|
||||
Name: "somemetric",
|
||||
},
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.ValueMetricType,
|
||||
Value: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
msg: "object.describedObject.kind: Required",
|
||||
},
|
||||
{
|
||||
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
|
||||
Spec: autoscaling.HorizontalPodAutoscalerSpec{
|
||||
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
|
||||
MinReplicas: utilpointer.Int32Ptr(1),
|
||||
MaxReplicas: 5,
|
||||
Metrics: []autoscaling.MetricSpec{
|
||||
{
|
||||
Type: autoscaling.ObjectMetricSourceType,
|
||||
Object: &autoscaling.ObjectMetricSource{
|
||||
DescribedObject: autoscaling.CrossVersionObjectReference{
|
||||
Kind: "ReplicationController",
|
||||
Name: "myrc",
|
||||
},
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.ValueMetricType,
|
||||
Value: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -555,12 +646,13 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
{
|
||||
Type: autoscaling.ExternalMetricSourceType,
|
||||
External: &autoscaling.ExternalMetricSource{
|
||||
MetricSelector: &metav1.LabelSelector{
|
||||
MatchLabels: map[string]string{
|
||||
"label": "value",
|
||||
},
|
||||
Metric: autoscaling.MetricIdentifier{
|
||||
Selector: metricLabelSelector,
|
||||
},
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.ValueMetricType,
|
||||
Value: resource.NewMilliQuantity(300, resource.DecimalSI),
|
||||
},
|
||||
TargetValue: resource.NewMilliQuantity(300, resource.DecimalSI),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -579,13 +671,14 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
{
|
||||
Type: autoscaling.ExternalMetricSourceType,
|
||||
External: &autoscaling.ExternalMetricSource{
|
||||
MetricName: "foo/../",
|
||||
MetricSelector: &metav1.LabelSelector{
|
||||
MatchLabels: map[string]string{
|
||||
"label": "value",
|
||||
},
|
||||
Metric: autoscaling.MetricIdentifier{
|
||||
Name: "foo/../",
|
||||
Selector: metricLabelSelector,
|
||||
},
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.ValueMetricType,
|
||||
Value: resource.NewMilliQuantity(300, resource.DecimalSI),
|
||||
},
|
||||
TargetValue: resource.NewMilliQuantity(300, resource.DecimalSI),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -605,11 +698,12 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
{
|
||||
Type: autoscaling.ExternalMetricSourceType,
|
||||
External: &autoscaling.ExternalMetricSource{
|
||||
MetricName: "somemetric",
|
||||
MetricSelector: &metav1.LabelSelector{
|
||||
MatchLabels: map[string]string{
|
||||
"label": "value",
|
||||
},
|
||||
Metric: autoscaling.MetricIdentifier{
|
||||
Name: "somemetric",
|
||||
Selector: metricLabelSelector,
|
||||
},
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.ValueMetricType,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -629,13 +723,14 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
{
|
||||
Type: autoscaling.ExternalMetricSourceType,
|
||||
External: &autoscaling.ExternalMetricSource{
|
||||
MetricName: "somemetric",
|
||||
MetricSelector: &metav1.LabelSelector{
|
||||
MatchLabels: map[string]string{
|
||||
"label": "value",
|
||||
},
|
||||
Metric: autoscaling.MetricIdentifier{
|
||||
Name: "somemetric",
|
||||
Selector: metricLabelSelector,
|
||||
},
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.ValueMetricType,
|
||||
Value: resource.NewMilliQuantity(-300, resource.DecimalSI),
|
||||
},
|
||||
TargetValue: resource.NewMilliQuantity(-300, resource.DecimalSI),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -654,13 +749,14 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
{
|
||||
Type: autoscaling.ExternalMetricSourceType,
|
||||
External: &autoscaling.ExternalMetricSource{
|
||||
MetricName: "somemetric",
|
||||
MetricSelector: &metav1.LabelSelector{
|
||||
MatchLabels: map[string]string{
|
||||
"label": "value",
|
||||
},
|
||||
Metric: autoscaling.MetricIdentifier{
|
||||
Name: "somemetric",
|
||||
Selector: metricLabelSelector,
|
||||
},
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.ValueMetricType,
|
||||
AverageValue: resource.NewMilliQuantity(-300, resource.DecimalSI),
|
||||
},
|
||||
TargetAverageValue: resource.NewMilliQuantity(-300, resource.DecimalSI),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -679,14 +775,15 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
{
|
||||
Type: autoscaling.ExternalMetricSourceType,
|
||||
External: &autoscaling.ExternalMetricSource{
|
||||
MetricName: "somemetric",
|
||||
MetricSelector: &metav1.LabelSelector{
|
||||
MatchLabels: map[string]string{
|
||||
"label": "value",
|
||||
},
|
||||
Metric: autoscaling.MetricIdentifier{
|
||||
Name: "somemetric",
|
||||
Selector: metricLabelSelector,
|
||||
},
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.ValueMetricType,
|
||||
Value: resource.NewMilliQuantity(300, resource.DecimalSI),
|
||||
AverageValue: resource.NewMilliQuantity(300, resource.DecimalSI),
|
||||
},
|
||||
TargetValue: resource.NewMilliQuantity(300, resource.DecimalSI),
|
||||
TargetAverageValue: resource.NewMilliQuantity(300, resource.DecimalSI),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -694,6 +791,79 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
},
|
||||
msg: "may not set both a target value for metric and a per-pod target",
|
||||
},
|
||||
{
|
||||
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
|
||||
Spec: autoscaling.HorizontalPodAutoscalerSpec{
|
||||
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
|
||||
MinReplicas: utilpointer.Int32Ptr(1),
|
||||
MaxReplicas: 5,
|
||||
Metrics: []autoscaling.MetricSpec{
|
||||
{
|
||||
Type: autoscaling.ExternalMetricSourceType,
|
||||
External: &autoscaling.ExternalMetricSource{
|
||||
Metric: autoscaling.MetricIdentifier{
|
||||
Name: "somemetric",
|
||||
Selector: metricLabelSelector,
|
||||
},
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: "boogity",
|
||||
Value: resource.NewMilliQuantity(300, resource.DecimalSI),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
msg: "must be either Utilization, Value, or AverageValue",
|
||||
},
|
||||
{
|
||||
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
|
||||
Spec: autoscaling.HorizontalPodAutoscalerSpec{
|
||||
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
|
||||
MinReplicas: utilpointer.Int32Ptr(1),
|
||||
MaxReplicas: 5,
|
||||
Metrics: []autoscaling.MetricSpec{
|
||||
{
|
||||
Type: autoscaling.ExternalMetricSourceType,
|
||||
External: &autoscaling.ExternalMetricSource{
|
||||
Metric: autoscaling.MetricIdentifier{
|
||||
Name: "somemetric",
|
||||
Selector: metricLabelSelector,
|
||||
},
|
||||
Target: autoscaling.MetricTarget{
|
||||
Value: resource.NewMilliQuantity(300, resource.DecimalSI),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
msg: "must specify a metric target type",
|
||||
},
|
||||
{
|
||||
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
|
||||
Spec: autoscaling.HorizontalPodAutoscalerSpec{
|
||||
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
|
||||
MinReplicas: utilpointer.Int32Ptr(1),
|
||||
MaxReplicas: 5,
|
||||
Metrics: []autoscaling.MetricSpec{
|
||||
{
|
||||
Type: autoscaling.ExternalMetricSourceType,
|
||||
External: &autoscaling.ExternalMetricSource{
|
||||
Metric: autoscaling.MetricIdentifier{
|
||||
Name: "somemetric",
|
||||
Selector: metricLabelSelector,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
msg: "must specify a metric target",
|
||||
},
|
||||
{
|
||||
horizontalPodAutoscaler: autoscaling.HorizontalPodAutoscaler{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
|
||||
@@ -735,12 +905,20 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
{
|
||||
Type: autoscaling.ResourceMetricSourceType,
|
||||
Resource: &autoscaling.ResourceMetricSource{
|
||||
Name: api.ResourceCPU,
|
||||
TargetAverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||
Name: api.ResourceCPU,
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.AverageValueMetricType,
|
||||
AverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||
},
|
||||
},
|
||||
Pods: &autoscaling.PodsMetricSource{
|
||||
MetricName: "somemetric",
|
||||
TargetAverageValue: *resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||
Metric: autoscaling.MetricIdentifier{
|
||||
Name: "somemetric",
|
||||
},
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.AverageValueMetricType,
|
||||
AverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -762,24 +940,37 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
sourceTypes := map[autoscaling.MetricSourceType]autoscaling.MetricSpec{
|
||||
autoscaling.ResourceMetricSourceType: {
|
||||
Resource: &autoscaling.ResourceMetricSource{
|
||||
Name: api.ResourceCPU,
|
||||
TargetAverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||
Name: api.ResourceCPU,
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.AverageValueMetricType,
|
||||
AverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||
},
|
||||
},
|
||||
},
|
||||
autoscaling.PodsMetricSourceType: {
|
||||
Pods: &autoscaling.PodsMetricSource{
|
||||
MetricName: "somemetric",
|
||||
TargetAverageValue: *resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||
Metric: autoscaling.MetricIdentifier{
|
||||
Name: "somemetric",
|
||||
},
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.AverageValueMetricType,
|
||||
AverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||
},
|
||||
},
|
||||
},
|
||||
autoscaling.ObjectMetricSourceType: {
|
||||
Object: &autoscaling.ObjectMetricSource{
|
||||
Target: autoscaling.CrossVersionObjectReference{
|
||||
DescribedObject: autoscaling.CrossVersionObjectReference{
|
||||
Kind: "ReplicationController",
|
||||
Name: "myrc",
|
||||
},
|
||||
MetricName: "somemetric",
|
||||
TargetValue: *resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||
Metric: autoscaling.MetricIdentifier{
|
||||
Name: "somemetric",
|
||||
},
|
||||
Target: autoscaling.MetricTarget{
|
||||
Type: autoscaling.ValueMetricType,
|
||||
Value: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
143
pkg/apis/autoscaling/zz_generated.deepcopy.go
generated
143
pkg/apis/autoscaling/zz_generated.deepcopy.go
generated
@@ -21,7 +21,6 @@ limitations under the License.
|
||||
package autoscaling
|
||||
|
||||
import (
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
@@ -44,21 +43,8 @@ func (in *CrossVersionObjectReference) DeepCopy() *CrossVersionObjectReference {
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ExternalMetricSource) DeepCopyInto(out *ExternalMetricSource) {
|
||||
*out = *in
|
||||
if in.MetricSelector != nil {
|
||||
in, out := &in.MetricSelector, &out.MetricSelector
|
||||
*out = new(v1.LabelSelector)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.TargetValue != nil {
|
||||
in, out := &in.TargetValue, &out.TargetValue
|
||||
x := (*in).DeepCopy()
|
||||
*out = &x
|
||||
}
|
||||
if in.TargetAverageValue != nil {
|
||||
in, out := &in.TargetAverageValue, &out.TargetAverageValue
|
||||
x := (*in).DeepCopy()
|
||||
*out = &x
|
||||
}
|
||||
out.Metric = in.Metric
|
||||
in.Target.DeepCopyInto(&out.Target)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -75,17 +61,8 @@ func (in *ExternalMetricSource) DeepCopy() *ExternalMetricSource {
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ExternalMetricStatus) DeepCopyInto(out *ExternalMetricStatus) {
|
||||
*out = *in
|
||||
if in.MetricSelector != nil {
|
||||
in, out := &in.MetricSelector, &out.MetricSelector
|
||||
*out = new(v1.LabelSelector)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
out.CurrentValue = in.CurrentValue.DeepCopy()
|
||||
if in.CurrentAverageValue != nil {
|
||||
in, out := &in.CurrentAverageValue, &out.CurrentAverageValue
|
||||
x := (*in).DeepCopy()
|
||||
*out = &x
|
||||
}
|
||||
out.Metric = in.Metric
|
||||
in.Current.DeepCopyInto(&out.Current)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -245,6 +222,22 @@ func (in *HorizontalPodAutoscalerStatus) DeepCopy() *HorizontalPodAutoscalerStat
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *MetricIdent) DeepCopyInto(out *MetricIdent) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricIdent.
|
||||
func (in *MetricIdent) DeepCopy() *MetricIdent {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(MetricIdent)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *MetricSpec) DeepCopyInto(out *MetricSpec) {
|
||||
*out = *in
|
||||
@@ -317,11 +310,74 @@ func (in *MetricStatus) DeepCopy() *MetricStatus {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *MetricTarget) DeepCopyInto(out *MetricTarget) {
|
||||
*out = *in
|
||||
if in.Value != nil {
|
||||
in, out := &in.Value, &out.Value
|
||||
x := (*in).DeepCopy()
|
||||
*out = &x
|
||||
}
|
||||
if in.AverageValue != nil {
|
||||
in, out := &in.AverageValue, &out.AverageValue
|
||||
x := (*in).DeepCopy()
|
||||
*out = &x
|
||||
}
|
||||
if in.AverageUtilization != nil {
|
||||
in, out := &in.AverageUtilization, &out.AverageUtilization
|
||||
*out = new(int32)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricTarget.
|
||||
func (in *MetricTarget) DeepCopy() *MetricTarget {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(MetricTarget)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *MetricValueStatus) DeepCopyInto(out *MetricValueStatus) {
|
||||
*out = *in
|
||||
if in.Value != nil {
|
||||
in, out := &in.Value, &out.Value
|
||||
x := (*in).DeepCopy()
|
||||
*out = &x
|
||||
}
|
||||
if in.AverageValue != nil {
|
||||
in, out := &in.AverageValue, &out.AverageValue
|
||||
x := (*in).DeepCopy()
|
||||
*out = &x
|
||||
}
|
||||
if in.AverageUtilization != nil {
|
||||
in, out := &in.AverageUtilization, &out.AverageUtilization
|
||||
*out = new(int32)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricValueStatus.
|
||||
func (in *MetricValueStatus) DeepCopy() *MetricValueStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(MetricValueStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ObjectMetricSource) DeepCopyInto(out *ObjectMetricSource) {
|
||||
*out = *in
|
||||
out.Target = in.Target
|
||||
out.TargetValue = in.TargetValue.DeepCopy()
|
||||
out.DescribedObject = in.DescribedObject
|
||||
in.Target.DeepCopyInto(&out.Target)
|
||||
out.Metric = in.Metric
|
||||
return
|
||||
}
|
||||
|
||||
@@ -338,8 +394,9 @@ func (in *ObjectMetricSource) DeepCopy() *ObjectMetricSource {
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ObjectMetricStatus) DeepCopyInto(out *ObjectMetricStatus) {
|
||||
*out = *in
|
||||
out.Target = in.Target
|
||||
out.CurrentValue = in.CurrentValue.DeepCopy()
|
||||
out.Metric = in.Metric
|
||||
in.Current.DeepCopyInto(&out.Current)
|
||||
out.DescribedObject = in.DescribedObject
|
||||
return
|
||||
}
|
||||
|
||||
@@ -356,7 +413,8 @@ func (in *ObjectMetricStatus) DeepCopy() *ObjectMetricStatus {
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *PodsMetricSource) DeepCopyInto(out *PodsMetricSource) {
|
||||
*out = *in
|
||||
out.TargetAverageValue = in.TargetAverageValue.DeepCopy()
|
||||
out.Metric = in.Metric
|
||||
in.Target.DeepCopyInto(&out.Target)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -373,7 +431,8 @@ func (in *PodsMetricSource) DeepCopy() *PodsMetricSource {
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *PodsMetricStatus) DeepCopyInto(out *PodsMetricStatus) {
|
||||
*out = *in
|
||||
out.CurrentAverageValue = in.CurrentAverageValue.DeepCopy()
|
||||
out.Metric = in.Metric
|
||||
in.Current.DeepCopyInto(&out.Current)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -390,16 +449,7 @@ func (in *PodsMetricStatus) DeepCopy() *PodsMetricStatus {
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ResourceMetricSource) DeepCopyInto(out *ResourceMetricSource) {
|
||||
*out = *in
|
||||
if in.TargetAverageUtilization != nil {
|
||||
in, out := &in.TargetAverageUtilization, &out.TargetAverageUtilization
|
||||
*out = new(int32)
|
||||
**out = **in
|
||||
}
|
||||
if in.TargetAverageValue != nil {
|
||||
in, out := &in.TargetAverageValue, &out.TargetAverageValue
|
||||
x := (*in).DeepCopy()
|
||||
*out = &x
|
||||
}
|
||||
in.Target.DeepCopyInto(&out.Target)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -416,12 +466,7 @@ func (in *ResourceMetricSource) DeepCopy() *ResourceMetricSource {
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ResourceMetricStatus) DeepCopyInto(out *ResourceMetricStatus) {
|
||||
*out = *in
|
||||
if in.CurrentAverageUtilization != nil {
|
||||
in, out := &in.CurrentAverageUtilization, &out.CurrentAverageUtilization
|
||||
*out = new(int32)
|
||||
**out = **in
|
||||
}
|
||||
out.CurrentAverageValue = in.CurrentAverageValue.DeepCopy()
|
||||
in.Current.DeepCopyInto(&out.Current)
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user