Merge pull request #68795 from damemi/custom-metrics-conversion-fix

Update custom metrics conversion functions
pull/8/head
k8s-ci-robot 2018-09-19 11:35:02 -07:00 committed by GitHub
commit cdadc117e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 0 deletions

View File

@ -17,6 +17,7 @@ limitations under the License.
package v1beta1
import (
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/metrics/pkg/apis/custom_metrics"
@ -36,12 +37,38 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
}
func Convert_v1beta1_MetricValue_To_custom_metrics_MetricValue(in *MetricValue, out *custom_metrics.MetricValue, s conversion.Scope) error {
out.TypeMeta = in.TypeMeta
out.DescribedObject = custom_metrics.ObjectReference{
Kind: in.DescribedObject.Kind,
Namespace: in.DescribedObject.Namespace,
Name: in.DescribedObject.Name,
UID: in.DescribedObject.UID,
APIVersion: in.DescribedObject.APIVersion,
ResourceVersion: in.DescribedObject.ResourceVersion,
FieldPath: in.DescribedObject.FieldPath,
}
out.Timestamp = in.Timestamp
out.WindowSeconds = in.WindowSeconds
out.Value = in.Value
out.Metric.Name = in.MetricName
out.Metric.Selector = in.Selector
return nil
}
func Convert_custom_metrics_MetricValue_To_v1beta1_MetricValue(in *custom_metrics.MetricValue, out *MetricValue, s conversion.Scope) error {
out.TypeMeta = in.TypeMeta
out.DescribedObject = v1.ObjectReference{
Kind: in.DescribedObject.Kind,
Namespace: in.DescribedObject.Namespace,
Name: in.DescribedObject.Name,
UID: in.DescribedObject.UID,
APIVersion: in.DescribedObject.APIVersion,
ResourceVersion: in.DescribedObject.ResourceVersion,
FieldPath: in.DescribedObject.FieldPath,
}
out.Timestamp = in.Timestamp
out.WindowSeconds = in.WindowSeconds
out.Value = in.Value
out.MetricName = in.Metric.Name
out.Selector = in.Metric.Selector
return nil