Move custom metrics APIs to v1beta1

This commit moves the custom metrics APIs and clients from v1alpha1
to v1beta1.
This commit is contained in:
Solly Ross 2017-08-17 14:42:49 -04:00
parent 44c5182187
commit 98b1a08d7e
18 changed files with 153 additions and 153 deletions

View File

@ -57,7 +57,7 @@ openapi_library(
"k8s.io/client-go/pkg/version", "k8s.io/client-go/pkg/version",
"k8s.io/code-generator/test/apis/testgroup/v1", "k8s.io/code-generator/test/apis/testgroup/v1",
"k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1", "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1",
"k8s.io/metrics/pkg/apis/custom_metrics/v1alpha1", "k8s.io/metrics/pkg/apis/custom_metrics/v1beta1",
"k8s.io/metrics/pkg/apis/metrics/v1alpha1", "k8s.io/metrics/pkg/apis/metrics/v1alpha1",
], ],
) )

View File

@ -35,7 +35,7 @@ filegroup(
srcs = [ srcs = [
":package-srcs", ":package-srcs",
"//staging/src/k8s.io/metrics/pkg/apis/custom_metrics/install:all-srcs", "//staging/src/k8s.io/metrics/pkg/apis/custom_metrics/install:all-srcs",
"//staging/src/k8s.io/metrics/pkg/apis/custom_metrics/v1alpha1:all-srcs", "//staging/src/k8s.io/metrics/pkg/apis/custom_metrics/v1beta1:all-srcs",
], ],
tags = ["automanaged"], tags = ["automanaged"],
) )

View File

@ -13,7 +13,7 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/apimachinery/registered:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apimachinery/registered:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/metrics/pkg/apis/custom_metrics:go_default_library", "//vendor/k8s.io/metrics/pkg/apis/custom_metrics:go_default_library",
"//vendor/k8s.io/metrics/pkg/apis/custom_metrics/v1alpha1:go_default_library", "//vendor/k8s.io/metrics/pkg/apis/custom_metrics/v1beta1:go_default_library",
], ],
) )

View File

@ -23,7 +23,7 @@ import (
"k8s.io/apimachinery/pkg/apimachinery/registered" "k8s.io/apimachinery/pkg/apimachinery/registered"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/metrics/pkg/apis/custom_metrics" "k8s.io/metrics/pkg/apis/custom_metrics"
"k8s.io/metrics/pkg/apis/custom_metrics/v1alpha1" "k8s.io/metrics/pkg/apis/custom_metrics/v1beta1"
) )
// Install registers the API group and adds types to a scheme // Install registers the API group and adds types to a scheme
@ -31,11 +31,11 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r
if err := announced.NewGroupMetaFactory( if err := announced.NewGroupMetaFactory(
&announced.GroupMetaFactoryArgs{ &announced.GroupMetaFactoryArgs{
GroupName: custom_metrics.GroupName, GroupName: custom_metrics.GroupName,
VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version}, VersionPreferenceOrder: []string{v1beta1.SchemeGroupVersion.Version},
AddInternalObjectsToScheme: custom_metrics.AddToScheme, AddInternalObjectsToScheme: custom_metrics.AddToScheme,
}, },
announced.VersionToSchemeFunc{ announced.VersionToSchemeFunc{
v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme, v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme,
}, },
).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil {
panic(err) panic(err)

View File

@ -1,99 +0,0 @@
// +build !ignore_autogenerated
/*
Copyright 2017 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.
*/
// This file was autogenerated by conversion-gen. Do not edit it manually!
package v1alpha1
import (
conversion "k8s.io/apimachinery/pkg/conversion"
runtime "k8s.io/apimachinery/pkg/runtime"
custom_metrics "k8s.io/metrics/pkg/apis/custom_metrics"
unsafe "unsafe"
)
func init() {
localSchemeBuilder.Register(RegisterConversions)
}
// RegisterConversions adds conversion functions to the given scheme.
// Public to allow building arbitrary schemes.
func RegisterConversions(scheme *runtime.Scheme) error {
return scheme.AddGeneratedConversionFuncs(
Convert_v1alpha1_MetricValue_To_custom_metrics_MetricValue,
Convert_custom_metrics_MetricValue_To_v1alpha1_MetricValue,
Convert_v1alpha1_MetricValueList_To_custom_metrics_MetricValueList,
Convert_custom_metrics_MetricValueList_To_v1alpha1_MetricValueList,
)
}
func autoConvert_v1alpha1_MetricValue_To_custom_metrics_MetricValue(in *MetricValue, out *custom_metrics.MetricValue, s conversion.Scope) error {
// TODO: Inefficient conversion - can we improve it?
if err := s.Convert(&in.DescribedObject, &out.DescribedObject, 0); err != nil {
return err
}
out.MetricName = in.MetricName
out.Timestamp = in.Timestamp
out.WindowSeconds = (*int64)(unsafe.Pointer(in.WindowSeconds))
out.Value = in.Value
return nil
}
// Convert_v1alpha1_MetricValue_To_custom_metrics_MetricValue is an autogenerated conversion function.
func Convert_v1alpha1_MetricValue_To_custom_metrics_MetricValue(in *MetricValue, out *custom_metrics.MetricValue, s conversion.Scope) error {
return autoConvert_v1alpha1_MetricValue_To_custom_metrics_MetricValue(in, out, s)
}
func autoConvert_custom_metrics_MetricValue_To_v1alpha1_MetricValue(in *custom_metrics.MetricValue, out *MetricValue, s conversion.Scope) error {
// TODO: Inefficient conversion - can we improve it?
if err := s.Convert(&in.DescribedObject, &out.DescribedObject, 0); err != nil {
return err
}
out.MetricName = in.MetricName
out.Timestamp = in.Timestamp
out.WindowSeconds = (*int64)(unsafe.Pointer(in.WindowSeconds))
out.Value = in.Value
return nil
}
// Convert_custom_metrics_MetricValue_To_v1alpha1_MetricValue is an autogenerated conversion function.
func Convert_custom_metrics_MetricValue_To_v1alpha1_MetricValue(in *custom_metrics.MetricValue, out *MetricValue, s conversion.Scope) error {
return autoConvert_custom_metrics_MetricValue_To_v1alpha1_MetricValue(in, out, s)
}
func autoConvert_v1alpha1_MetricValueList_To_custom_metrics_MetricValueList(in *MetricValueList, out *custom_metrics.MetricValueList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
out.Items = *(*[]custom_metrics.MetricValue)(unsafe.Pointer(&in.Items))
return nil
}
// Convert_v1alpha1_MetricValueList_To_custom_metrics_MetricValueList is an autogenerated conversion function.
func Convert_v1alpha1_MetricValueList_To_custom_metrics_MetricValueList(in *MetricValueList, out *custom_metrics.MetricValueList, s conversion.Scope) error {
return autoConvert_v1alpha1_MetricValueList_To_custom_metrics_MetricValueList(in, out, s)
}
func autoConvert_custom_metrics_MetricValueList_To_v1alpha1_MetricValueList(in *custom_metrics.MetricValueList, out *MetricValueList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
out.Items = *(*[]MetricValue)(unsafe.Pointer(&in.Items))
return nil
}
// Convert_custom_metrics_MetricValueList_To_v1alpha1_MetricValueList is an autogenerated conversion function.
func Convert_custom_metrics_MetricValueList_To_v1alpha1_MetricValueList(in *custom_metrics.MetricValueList, out *MetricValueList, s conversion.Scope) error {
return autoConvert_custom_metrics_MetricValueList_To_v1alpha1_MetricValueList(in, out, s)
}

View File

@ -18,4 +18,4 @@ limitations under the License.
// +k8s:conversion-gen=k8s.io/kubernetes/vendor/k8s.io/metrics/pkg/apis/custom_metrics // +k8s:conversion-gen=k8s.io/kubernetes/vendor/k8s.io/metrics/pkg/apis/custom_metrics
// +k8s:openapi-gen=true // +k8s:openapi-gen=true
package v1alpha1 package v1beta1

View File

@ -15,20 +15,20 @@ limitations under the License.
*/ */
// Code generated by protoc-gen-gogo. // Code generated by protoc-gen-gogo.
// source: k8s.io/kubernetes/vendor/k8s.io/metrics/pkg/apis/custom_metrics/v1alpha1/generated.proto // source: k8s.io/kubernetes/vendor/k8s.io/metrics/pkg/apis/custom_metrics/v1beta1/generated.proto
// DO NOT EDIT! // DO NOT EDIT!
/* /*
Package v1alpha1 is a generated protocol buffer package. Package v1beta1 is a generated protocol buffer package.
It is generated from these files: It is generated from these files:
k8s.io/kubernetes/vendor/k8s.io/metrics/pkg/apis/custom_metrics/v1alpha1/generated.proto k8s.io/kubernetes/vendor/k8s.io/metrics/pkg/apis/custom_metrics/v1beta1/generated.proto
It has these top-level messages: It has these top-level messages:
MetricValue MetricValue
MetricValueList MetricValueList
*/ */
package v1alpha1 package v1beta1
import proto "github.com/gogo/protobuf/proto" import proto "github.com/gogo/protobuf/proto"
import fmt "fmt" import fmt "fmt"
@ -59,8 +59,8 @@ func (*MetricValueList) ProtoMessage() {}
func (*MetricValueList) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{1} } func (*MetricValueList) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{1} }
func init() { func init() {
proto.RegisterType((*MetricValue)(nil), "k8s.io.metrics.pkg.apis.custom_metrics.v1alpha1.MetricValue") proto.RegisterType((*MetricValue)(nil), "k8s.io.metrics.pkg.apis.custom_metrics.v1beta1.MetricValue")
proto.RegisterType((*MetricValueList)(nil), "k8s.io.metrics.pkg.apis.custom_metrics.v1alpha1.MetricValueList") proto.RegisterType((*MetricValueList)(nil), "k8s.io.metrics.pkg.apis.custom_metrics.v1beta1.MetricValueList")
} }
func (m *MetricValue) Marshal() (dAtA []byte, err error) { func (m *MetricValue) Marshal() (dAtA []byte, err error) {
size := m.Size() size := m.Size()
@ -661,7 +661,7 @@ var (
) )
func init() { func init() {
proto.RegisterFile("k8s.io/kubernetes/vendor/k8s.io/metrics/pkg/apis/custom_metrics/v1alpha1/generated.proto", fileDescriptorGenerated) proto.RegisterFile("k8s.io/kubernetes/vendor/k8s.io/metrics/pkg/apis/custom_metrics/v1beta1/generated.proto", fileDescriptorGenerated)
} }
var fileDescriptorGenerated = []byte{ var fileDescriptorGenerated = []byte{

View File

@ -19,7 +19,7 @@ limitations under the License.
syntax = 'proto2'; syntax = 'proto2';
package k8s.io.metrics.pkg.apis.custom_metrics.v1alpha1; package k8s.io.metrics.pkg.apis.custom_metrics.v1beta1;
import "k8s.io/api/core/v1/generated.proto"; import "k8s.io/api/core/v1/generated.proto";
import "k8s.io/apimachinery/pkg/api/resource/generated.proto"; import "k8s.io/apimachinery/pkg/api/resource/generated.proto";
@ -29,7 +29,7 @@ import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto";
import "k8s.io/apimachinery/pkg/util/intstr/generated.proto"; import "k8s.io/apimachinery/pkg/util/intstr/generated.proto";
// Package-wide variables from generator "generated". // Package-wide variables from generator "generated".
option go_package = "v1alpha1"; option go_package = "v1beta1";
// a metric value for some object // a metric value for some object
message MetricValue { message MetricValue {

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package v1alpha1 package v1beta1
import ( import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -26,7 +26,7 @@ import (
const GroupName = "custom-metrics.metrics.k8s.io" const GroupName = "custom-metrics.metrics.k8s.io"
// SchemeGroupVersion is group version used to register these objects // SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"}
// Resource takes an unqualified resource and returns a Group qualified GroupResource // Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource { func Resource(resource string) schema.GroupResource {

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package v1alpha1 package v1beta1
import ( import (
"k8s.io/api/core/v1" "k8s.io/api/core/v1"

View File

@ -0,0 +1,99 @@
// +build !ignore_autogenerated
/*
Copyright 2017 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.
*/
// This file was autogenerated by conversion-gen. Do not edit it manually!
package v1beta1
import (
conversion "k8s.io/apimachinery/pkg/conversion"
runtime "k8s.io/apimachinery/pkg/runtime"
custom_metrics "k8s.io/metrics/pkg/apis/custom_metrics"
unsafe "unsafe"
)
func init() {
localSchemeBuilder.Register(RegisterConversions)
}
// RegisterConversions adds conversion functions to the given scheme.
// Public to allow building arbitrary schemes.
func RegisterConversions(scheme *runtime.Scheme) error {
return scheme.AddGeneratedConversionFuncs(
Convert_v1beta1_MetricValue_To_custom_metrics_MetricValue,
Convert_custom_metrics_MetricValue_To_v1beta1_MetricValue,
Convert_v1beta1_MetricValueList_To_custom_metrics_MetricValueList,
Convert_custom_metrics_MetricValueList_To_v1beta1_MetricValueList,
)
}
func autoConvert_v1beta1_MetricValue_To_custom_metrics_MetricValue(in *MetricValue, out *custom_metrics.MetricValue, s conversion.Scope) error {
// TODO: Inefficient conversion - can we improve it?
if err := s.Convert(&in.DescribedObject, &out.DescribedObject, 0); err != nil {
return err
}
out.MetricName = in.MetricName
out.Timestamp = in.Timestamp
out.WindowSeconds = (*int64)(unsafe.Pointer(in.WindowSeconds))
out.Value = in.Value
return nil
}
// Convert_v1beta1_MetricValue_To_custom_metrics_MetricValue is an autogenerated conversion function.
func Convert_v1beta1_MetricValue_To_custom_metrics_MetricValue(in *MetricValue, out *custom_metrics.MetricValue, s conversion.Scope) error {
return autoConvert_v1beta1_MetricValue_To_custom_metrics_MetricValue(in, out, s)
}
func autoConvert_custom_metrics_MetricValue_To_v1beta1_MetricValue(in *custom_metrics.MetricValue, out *MetricValue, s conversion.Scope) error {
// TODO: Inefficient conversion - can we improve it?
if err := s.Convert(&in.DescribedObject, &out.DescribedObject, 0); err != nil {
return err
}
out.MetricName = in.MetricName
out.Timestamp = in.Timestamp
out.WindowSeconds = (*int64)(unsafe.Pointer(in.WindowSeconds))
out.Value = in.Value
return nil
}
// Convert_custom_metrics_MetricValue_To_v1beta1_MetricValue is an autogenerated conversion function.
func Convert_custom_metrics_MetricValue_To_v1beta1_MetricValue(in *custom_metrics.MetricValue, out *MetricValue, s conversion.Scope) error {
return autoConvert_custom_metrics_MetricValue_To_v1beta1_MetricValue(in, out, s)
}
func autoConvert_v1beta1_MetricValueList_To_custom_metrics_MetricValueList(in *MetricValueList, out *custom_metrics.MetricValueList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
out.Items = *(*[]custom_metrics.MetricValue)(unsafe.Pointer(&in.Items))
return nil
}
// Convert_v1beta1_MetricValueList_To_custom_metrics_MetricValueList is an autogenerated conversion function.
func Convert_v1beta1_MetricValueList_To_custom_metrics_MetricValueList(in *MetricValueList, out *custom_metrics.MetricValueList, s conversion.Scope) error {
return autoConvert_v1beta1_MetricValueList_To_custom_metrics_MetricValueList(in, out, s)
}
func autoConvert_custom_metrics_MetricValueList_To_v1beta1_MetricValueList(in *custom_metrics.MetricValueList, out *MetricValueList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
out.Items = *(*[]MetricValue)(unsafe.Pointer(&in.Items))
return nil
}
// Convert_custom_metrics_MetricValueList_To_v1beta1_MetricValueList is an autogenerated conversion function.
func Convert_custom_metrics_MetricValueList_To_v1beta1_MetricValueList(in *custom_metrics.MetricValueList, out *MetricValueList, s conversion.Scope) error {
return autoConvert_custom_metrics_MetricValueList_To_v1beta1_MetricValueList(in, out, s)
}

View File

@ -18,7 +18,7 @@ limitations under the License.
// This file was autogenerated by deepcopy-gen. Do not edit it manually! // This file was autogenerated by deepcopy-gen. Do not edit it manually!
package v1alpha1 package v1beta1
import ( import (
conversion "k8s.io/apimachinery/pkg/conversion" conversion "k8s.io/apimachinery/pkg/conversion"

View File

@ -20,7 +20,7 @@ go_library(
"//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library", "//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library",
"//vendor/k8s.io/client-go/rest:go_default_library", "//vendor/k8s.io/client-go/rest:go_default_library",
"//vendor/k8s.io/client-go/util/flowcontrol:go_default_library", "//vendor/k8s.io/client-go/util/flowcontrol:go_default_library",
"//vendor/k8s.io/metrics/pkg/apis/custom_metrics/v1alpha1:go_default_library", "//vendor/k8s.io/metrics/pkg/apis/custom_metrics/v1beta1:go_default_library",
], ],
) )

View File

@ -27,7 +27,7 @@ import (
"k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest" "k8s.io/client-go/rest"
"k8s.io/client-go/util/flowcontrol" "k8s.io/client-go/util/flowcontrol"
"k8s.io/metrics/pkg/apis/custom_metrics/v1alpha1" "k8s.io/metrics/pkg/apis/custom_metrics/v1beta1"
) )
type customMetricsClient struct { type customMetricsClient struct {
@ -50,7 +50,7 @@ func NewForConfig(c *rest.Config) (CustomMetricsClient, error) {
if configShallowCopy.UserAgent == "" { if configShallowCopy.UserAgent == "" {
configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent() configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent()
} }
configShallowCopy.GroupVersion = &v1alpha1.SchemeGroupVersion configShallowCopy.GroupVersion = &v1beta1.SchemeGroupVersion
configShallowCopy.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} configShallowCopy.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs}
client, err := rest.RESTClientFor(&configShallowCopy) client, err := rest.RESTClientFor(&configShallowCopy)
@ -115,8 +115,8 @@ type rootScopedMetrics struct {
client *customMetricsClient client *customMetricsClient
} }
func (m *rootScopedMetrics) getForNamespace(namespace string, metricName string) (*v1alpha1.MetricValue, error) { func (m *rootScopedMetrics) getForNamespace(namespace string, metricName string) (*v1beta1.MetricValue, error) {
res := &v1alpha1.MetricValueList{} res := &v1beta1.MetricValueList{}
err := m.client.client.Get(). err := m.client.client.Get().
Resource("metrics"). Resource("metrics").
Namespace(namespace). Namespace(namespace).
@ -135,7 +135,7 @@ func (m *rootScopedMetrics) getForNamespace(namespace string, metricName string)
return &res.Items[0], nil return &res.Items[0], nil
} }
func (m *rootScopedMetrics) GetForObject(groupKind schema.GroupKind, name string, metricName string) (*v1alpha1.MetricValue, error) { func (m *rootScopedMetrics) GetForObject(groupKind schema.GroupKind, name string, metricName string) (*v1beta1.MetricValue, error) {
// handle namespace separately // handle namespace separately
if groupKind.Kind == "Namespace" && groupKind.Group == "" { if groupKind.Kind == "Namespace" && groupKind.Group == "" {
return m.getForNamespace(name, metricName) return m.getForNamespace(name, metricName)
@ -146,7 +146,7 @@ func (m *rootScopedMetrics) GetForObject(groupKind schema.GroupKind, name string
return nil, err return nil, err
} }
res := &v1alpha1.MetricValueList{} res := &v1beta1.MetricValueList{}
err = m.client.client.Get(). err = m.client.client.Get().
Resource(resourceName). Resource(resourceName).
Name(name). Name(name).
@ -165,7 +165,7 @@ func (m *rootScopedMetrics) GetForObject(groupKind schema.GroupKind, name string
return &res.Items[0], nil return &res.Items[0], nil
} }
func (m *rootScopedMetrics) GetForObjects(groupKind schema.GroupKind, selector labels.Selector, metricName string) (*v1alpha1.MetricValueList, error) { func (m *rootScopedMetrics) GetForObjects(groupKind schema.GroupKind, selector labels.Selector, metricName string) (*v1beta1.MetricValueList, error) {
// we can't wildcard-fetch for namespaces // we can't wildcard-fetch for namespaces
if groupKind.Kind == "Namespace" && groupKind.Group == "" { if groupKind.Kind == "Namespace" && groupKind.Group == "" {
return nil, fmt.Errorf("cannot fetch metrics for multiple namespaces at once") return nil, fmt.Errorf("cannot fetch metrics for multiple namespaces at once")
@ -176,10 +176,10 @@ func (m *rootScopedMetrics) GetForObjects(groupKind schema.GroupKind, selector l
return nil, err return nil, err
} }
res := &v1alpha1.MetricValueList{} res := &v1beta1.MetricValueList{}
err = m.client.client.Get(). err = m.client.client.Get().
Resource(resourceName). Resource(resourceName).
Name(v1alpha1.AllObjects). Name(v1beta1.AllObjects).
SubResource(metricName). SubResource(metricName).
VersionedParams(&metav1.ListOptions{ VersionedParams(&metav1.ListOptions{
LabelSelector: selector.String(), LabelSelector: selector.String(),
@ -199,13 +199,13 @@ type namespacedMetrics struct {
namespace string namespace string
} }
func (m *namespacedMetrics) GetForObject(groupKind schema.GroupKind, name string, metricName string) (*v1alpha1.MetricValue, error) { func (m *namespacedMetrics) GetForObject(groupKind schema.GroupKind, name string, metricName string) (*v1beta1.MetricValue, error) {
resourceName, err := m.client.qualResourceForKind(groupKind) resourceName, err := m.client.qualResourceForKind(groupKind)
if err != nil { if err != nil {
return nil, err return nil, err
} }
res := &v1alpha1.MetricValueList{} res := &v1beta1.MetricValueList{}
err = m.client.client.Get(). err = m.client.client.Get().
Resource(resourceName). Resource(resourceName).
Namespace(m.namespace). Namespace(m.namespace).
@ -225,17 +225,17 @@ func (m *namespacedMetrics) GetForObject(groupKind schema.GroupKind, name string
return &res.Items[0], nil return &res.Items[0], nil
} }
func (m *namespacedMetrics) GetForObjects(groupKind schema.GroupKind, selector labels.Selector, metricName string) (*v1alpha1.MetricValueList, error) { func (m *namespacedMetrics) GetForObjects(groupKind schema.GroupKind, selector labels.Selector, metricName string) (*v1beta1.MetricValueList, error) {
resourceName, err := m.client.qualResourceForKind(groupKind) resourceName, err := m.client.qualResourceForKind(groupKind)
if err != nil { if err != nil {
return nil, err return nil, err
} }
res := &v1alpha1.MetricValueList{} res := &v1beta1.MetricValueList{}
err = m.client.client.Get(). err = m.client.client.Get().
Resource(resourceName). Resource(resourceName).
Namespace(m.namespace). Namespace(m.namespace).
Name(v1alpha1.AllObjects). Name(v1beta1.AllObjects).
SubResource(metricName). SubResource(metricName).
VersionedParams(&metav1.ListOptions{ VersionedParams(&metav1.ListOptions{
LabelSelector: selector.String(), LabelSelector: selector.String(),

View File

@ -13,7 +13,7 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library", "//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/client-go/testing:go_default_library", "//vendor/k8s.io/client-go/testing:go_default_library",
"//vendor/k8s.io/metrics/pkg/apis/custom_metrics/v1alpha1:go_default_library", "//vendor/k8s.io/metrics/pkg/apis/custom_metrics/v1beta1:go_default_library",
"//vendor/k8s.io/metrics/pkg/client/custom_metrics:go_default_library", "//vendor/k8s.io/metrics/pkg/client/custom_metrics:go_default_library",
], ],
) )

View File

@ -23,7 +23,7 @@ import (
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/testing" "k8s.io/client-go/testing"
"k8s.io/metrics/pkg/apis/custom_metrics/v1alpha1" "k8s.io/metrics/pkg/apis/custom_metrics/v1beta1"
cmclient "k8s.io/metrics/pkg/client/custom_metrics" cmclient "k8s.io/metrics/pkg/client/custom_metrics"
) )
@ -60,7 +60,7 @@ func NewGetForAction(groupKind schema.GroupKind, namespace, name string, metricN
Resource: gvr.Resource, Resource: gvr.Resource,
} }
resource := schema.GroupResource{ resource := schema.GroupResource{
Group: v1alpha1.SchemeGroupVersion.Group, Group: v1beta1.SchemeGroupVersion.Group,
Resource: groupResourceForKind.String(), Resource: groupResourceForKind.String(),
} }
return GetForActionImpl{ return GetForActionImpl{
@ -79,7 +79,7 @@ func NewRootGetForAction(groupKind schema.GroupKind, name string, metricName str
Resource: gvr.Resource, Resource: gvr.Resource,
} }
resource := schema.GroupResource{ resource := schema.GroupResource{
Group: v1alpha1.SchemeGroupVersion.Group, Group: v1beta1.SchemeGroupVersion.Group,
Resource: groupResourceForKind.String(), Resource: groupResourceForKind.String(),
} }
return GetForActionImpl{ return GetForActionImpl{
@ -111,15 +111,15 @@ type fakeNamespacedMetrics struct {
ns string ns string
} }
func (m *fakeNamespacedMetrics) GetForObject(groupKind schema.GroupKind, name string, metricName string) (*v1alpha1.MetricValue, error) { func (m *fakeNamespacedMetrics) GetForObject(groupKind schema.GroupKind, name string, metricName string) (*v1beta1.MetricValue, error) {
obj, err := m.Fake. obj, err := m.Fake.
Invokes(NewGetForAction(groupKind, m.ns, name, metricName, nil), &v1alpha1.MetricValueList{}) Invokes(NewGetForAction(groupKind, m.ns, name, metricName, nil), &v1beta1.MetricValueList{})
if obj == nil { if obj == nil {
return nil, err return nil, err
} }
objList := obj.(*v1alpha1.MetricValueList) objList := obj.(*v1beta1.MetricValueList)
if len(objList.Items) != 1 { if len(objList.Items) != 1 {
return nil, fmt.Errorf("the custom metrics API server returned %v results when we asked for exactly one", len(objList.Items)) return nil, fmt.Errorf("the custom metrics API server returned %v results when we asked for exactly one", len(objList.Items))
} }
@ -127,30 +127,30 @@ func (m *fakeNamespacedMetrics) GetForObject(groupKind schema.GroupKind, name st
return &objList.Items[0], err return &objList.Items[0], err
} }
func (m *fakeNamespacedMetrics) GetForObjects(groupKind schema.GroupKind, selector labels.Selector, metricName string) (*v1alpha1.MetricValueList, error) { func (m *fakeNamespacedMetrics) GetForObjects(groupKind schema.GroupKind, selector labels.Selector, metricName string) (*v1beta1.MetricValueList, error) {
obj, err := m.Fake. obj, err := m.Fake.
Invokes(NewGetForAction(groupKind, m.ns, "*", metricName, selector), &v1alpha1.MetricValueList{}) Invokes(NewGetForAction(groupKind, m.ns, "*", metricName, selector), &v1beta1.MetricValueList{})
if obj == nil { if obj == nil {
return nil, err return nil, err
} }
return obj.(*v1alpha1.MetricValueList), err return obj.(*v1beta1.MetricValueList), err
} }
type fakeRootScopedMetrics struct { type fakeRootScopedMetrics struct {
Fake *FakeCustomMetricsClient Fake *FakeCustomMetricsClient
} }
func (m *fakeRootScopedMetrics) GetForObject(groupKind schema.GroupKind, name string, metricName string) (*v1alpha1.MetricValue, error) { func (m *fakeRootScopedMetrics) GetForObject(groupKind schema.GroupKind, name string, metricName string) (*v1beta1.MetricValue, error) {
obj, err := m.Fake. obj, err := m.Fake.
Invokes(NewRootGetForAction(groupKind, name, metricName, nil), &v1alpha1.MetricValueList{}) Invokes(NewRootGetForAction(groupKind, name, metricName, nil), &v1beta1.MetricValueList{})
if obj == nil { if obj == nil {
return nil, err return nil, err
} }
objList := obj.(*v1alpha1.MetricValueList) objList := obj.(*v1beta1.MetricValueList)
if len(objList.Items) != 1 { if len(objList.Items) != 1 {
return nil, fmt.Errorf("the custom metrics API server returned %v results when we asked for exactly one", len(objList.Items)) return nil, fmt.Errorf("the custom metrics API server returned %v results when we asked for exactly one", len(objList.Items))
} }
@ -158,13 +158,13 @@ func (m *fakeRootScopedMetrics) GetForObject(groupKind schema.GroupKind, name st
return &objList.Items[0], err return &objList.Items[0], err
} }
func (m *fakeRootScopedMetrics) GetForObjects(groupKind schema.GroupKind, selector labels.Selector, metricName string) (*v1alpha1.MetricValueList, error) { func (m *fakeRootScopedMetrics) GetForObjects(groupKind schema.GroupKind, selector labels.Selector, metricName string) (*v1beta1.MetricValueList, error) {
obj, err := m.Fake. obj, err := m.Fake.
Invokes(NewRootGetForAction(groupKind, "*", metricName, selector), &v1alpha1.MetricValueList{}) Invokes(NewRootGetForAction(groupKind, "*", metricName, selector), &v1beta1.MetricValueList{})
if obj == nil { if obj == nil {
return nil, err return nil, err
} }
return obj.(*v1alpha1.MetricValueList), err return obj.(*v1beta1.MetricValueList), err
} }

View File

@ -19,7 +19,7 @@ package custom_metrics
import ( import (
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/metrics/pkg/apis/custom_metrics/v1alpha1" "k8s.io/metrics/pkg/apis/custom_metrics/v1beta1"
) )
// CustomMetricsClient is a client for fetching metrics // CustomMetricsClient is a client for fetching metrics
@ -45,10 +45,10 @@ type NamespacedMetricsGetter interface {
// MetricsInterface provides access to metrics describing Kubernetes objects. // MetricsInterface provides access to metrics describing Kubernetes objects.
type MetricsInterface interface { type MetricsInterface interface {
// GetForObject fetchs the given metric describing the given object. // GetForObject fetchs the given metric describing the given object.
GetForObject(groupKind schema.GroupKind, name string, metricName string) (*v1alpha1.MetricValue, error) GetForObject(groupKind schema.GroupKind, name string, metricName string) (*v1beta1.MetricValue, error)
// GetForObjects fetches the given metric describing all objects of the given // GetForObjects fetches the given metric describing all objects of the given
// type matching the given label selector (or simply all objects of the given type // type matching the given label selector (or simply all objects of the given type
// if the selector is nil). // if the selector is nil).
GetForObjects(groupKind schema.GroupKind, selector labels.Selector, metricName string) (*v1alpha1.MetricValueList, error) GetForObjects(groupKind schema.GroupKind, selector labels.Selector, metricName string) (*v1beta1.MetricValueList, error)
} }