Merge pull request #75486 from misterikkit/metrics-client

Fix fake clientsets in metrics.k8s.io.
This commit is contained in:
Kubernetes Prow Robot 2019-03-25 12:10:46 -07:00 committed by GitHub
commit 0fd410c4fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 78 additions and 10 deletions

View File

@ -13,6 +13,7 @@ filegroup(
"//staging/src/k8s.io/metrics/pkg/apis/external_metrics:all-srcs", "//staging/src/k8s.io/metrics/pkg/apis/external_metrics:all-srcs",
"//staging/src/k8s.io/metrics/pkg/apis/metrics:all-srcs", "//staging/src/k8s.io/metrics/pkg/apis/metrics:all-srcs",
"//staging/src/k8s.io/metrics/pkg/client/clientset/versioned:all-srcs", "//staging/src/k8s.io/metrics/pkg/client/clientset/versioned:all-srcs",
"//staging/src/k8s.io/metrics/pkg/client/clientset_test:all-srcs",
"//staging/src/k8s.io/metrics/pkg/client/custom_metrics:all-srcs", "//staging/src/k8s.io/metrics/pkg/client/custom_metrics:all-srcs",
"//staging/src/k8s.io/metrics/pkg/client/external_metrics:all-srcs", "//staging/src/k8s.io/metrics/pkg/client/external_metrics:all-srcs",
], ],

View File

@ -18,5 +18,6 @@ limitations under the License.
// +k8s:protobuf-gen=package // +k8s:protobuf-gen=package
// +k8s:conversion-gen=k8s.io/metrics/pkg/apis/metrics // +k8s:conversion-gen=k8s.io/metrics/pkg/apis/metrics
// +k8s:openapi-gen=true // +k8s:openapi-gen=true
// +groupName=metrics.k8s.io
package v1alpha1 package v1alpha1

View File

@ -18,5 +18,6 @@ limitations under the License.
// +k8s:protobuf-gen=package // +k8s:protobuf-gen=package
// +k8s:conversion-gen=k8s.io/metrics/pkg/apis/metrics // +k8s:conversion-gen=k8s.io/metrics/pkg/apis/metrics
// +k8s:openapi-gen=true // +k8s:openapi-gen=true
// +groupName=metrics.k8s.io
package v1beta1 package v1beta1

View File

@ -32,9 +32,9 @@ type FakeNodeMetricses struct {
Fake *FakeMetricsV1alpha1 Fake *FakeMetricsV1alpha1
} }
var nodemetricsesResource = schema.GroupVersionResource{Group: "metrics", Version: "v1alpha1", Resource: "nodes"} var nodemetricsesResource = schema.GroupVersionResource{Group: "metrics.k8s.io", Version: "v1alpha1", Resource: "nodes"}
var nodemetricsesKind = schema.GroupVersionKind{Group: "metrics", Version: "v1alpha1", Kind: "NodeMetrics"} var nodemetricsesKind = schema.GroupVersionKind{Group: "metrics.k8s.io", Version: "v1alpha1", Kind: "NodeMetrics"}
// Get takes name of the nodeMetrics, and returns the corresponding nodeMetrics object, and an error if there is any. // Get takes name of the nodeMetrics, and returns the corresponding nodeMetrics object, and an error if there is any.
func (c *FakeNodeMetricses) Get(name string, options v1.GetOptions) (result *v1alpha1.NodeMetrics, err error) { func (c *FakeNodeMetricses) Get(name string, options v1.GetOptions) (result *v1alpha1.NodeMetrics, err error) {

View File

@ -33,9 +33,9 @@ type FakePodMetricses struct {
ns string ns string
} }
var podmetricsesResource = schema.GroupVersionResource{Group: "metrics", Version: "v1alpha1", Resource: "pods"} var podmetricsesResource = schema.GroupVersionResource{Group: "metrics.k8s.io", Version: "v1alpha1", Resource: "pods"}
var podmetricsesKind = schema.GroupVersionKind{Group: "metrics", Version: "v1alpha1", Kind: "PodMetrics"} var podmetricsesKind = schema.GroupVersionKind{Group: "metrics.k8s.io", Version: "v1alpha1", Kind: "PodMetrics"}
// Get takes name of the podMetrics, and returns the corresponding podMetrics object, and an error if there is any. // Get takes name of the podMetrics, and returns the corresponding podMetrics object, and an error if there is any.
func (c *FakePodMetricses) Get(name string, options v1.GetOptions) (result *v1alpha1.PodMetrics, err error) { func (c *FakePodMetricses) Get(name string, options v1.GetOptions) (result *v1alpha1.PodMetrics, err error) {

View File

@ -31,7 +31,7 @@ type MetricsV1alpha1Interface interface {
PodMetricsesGetter PodMetricsesGetter
} }
// MetricsV1alpha1Client is used to interact with features provided by the metrics group. // MetricsV1alpha1Client is used to interact with features provided by the metrics.k8s.io group.
type MetricsV1alpha1Client struct { type MetricsV1alpha1Client struct {
restClient rest.Interface restClient rest.Interface
} }

View File

@ -32,9 +32,9 @@ type FakeNodeMetricses struct {
Fake *FakeMetricsV1beta1 Fake *FakeMetricsV1beta1
} }
var nodemetricsesResource = schema.GroupVersionResource{Group: "metrics", Version: "v1beta1", Resource: "nodes"} var nodemetricsesResource = schema.GroupVersionResource{Group: "metrics.k8s.io", Version: "v1beta1", Resource: "nodes"}
var nodemetricsesKind = schema.GroupVersionKind{Group: "metrics", Version: "v1beta1", Kind: "NodeMetrics"} var nodemetricsesKind = schema.GroupVersionKind{Group: "metrics.k8s.io", Version: "v1beta1", Kind: "NodeMetrics"}
// Get takes name of the nodeMetrics, and returns the corresponding nodeMetrics object, and an error if there is any. // Get takes name of the nodeMetrics, and returns the corresponding nodeMetrics object, and an error if there is any.
func (c *FakeNodeMetricses) Get(name string, options v1.GetOptions) (result *v1beta1.NodeMetrics, err error) { func (c *FakeNodeMetricses) Get(name string, options v1.GetOptions) (result *v1beta1.NodeMetrics, err error) {

View File

@ -33,9 +33,9 @@ type FakePodMetricses struct {
ns string ns string
} }
var podmetricsesResource = schema.GroupVersionResource{Group: "metrics", Version: "v1beta1", Resource: "pods"} var podmetricsesResource = schema.GroupVersionResource{Group: "metrics.k8s.io", Version: "v1beta1", Resource: "pods"}
var podmetricsesKind = schema.GroupVersionKind{Group: "metrics", Version: "v1beta1", Kind: "PodMetrics"} var podmetricsesKind = schema.GroupVersionKind{Group: "metrics.k8s.io", Version: "v1beta1", Kind: "PodMetrics"}
// Get takes name of the podMetrics, and returns the corresponding podMetrics object, and an error if there is any. // Get takes name of the podMetrics, and returns the corresponding podMetrics object, and an error if there is any.
func (c *FakePodMetricses) Get(name string, options v1.GetOptions) (result *v1beta1.PodMetrics, err error) { func (c *FakePodMetricses) Get(name string, options v1.GetOptions) (result *v1beta1.PodMetrics, err error) {

View File

@ -31,7 +31,7 @@ type MetricsV1beta1Interface interface {
PodMetricsesGetter PodMetricsesGetter
} }
// MetricsV1beta1Client is used to interact with features provided by the metrics group. // MetricsV1beta1Client is used to interact with features provided by the metrics.k8s.io group.
type MetricsV1beta1Client struct { type MetricsV1beta1Client struct {
restClient rest.Interface restClient rest.Interface
} }

View File

@ -0,0 +1,24 @@
load("@io_bazel_rules_go//go:def.bzl", "go_test")
go_test(
name = "go_default_test",
srcs = ["clientset_test.go"],
deps = [
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/metrics/pkg/client/clientset/versioned/fake: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"],
)

View File

@ -0,0 +1,41 @@
/*
Copyright 2019 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 clientset_test
import (
"testing"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/metrics/pkg/client/clientset/versioned/fake"
)
// TestFakeList is a basic sanity check that makes sure the fake Clientset is working properly.
func TestFakeList(t *testing.T) {
client := fake.NewSimpleClientset()
if _, err := client.MetricsV1alpha1().PodMetricses("").List(metav1.ListOptions{}); err != nil {
t.Errorf("Unexpected error: %v", err)
}
if _, err := client.MetricsV1alpha1().NodeMetricses().List(metav1.ListOptions{}); err != nil {
t.Errorf("Unexpected error: %v", err)
}
if _, err := client.MetricsV1beta1().PodMetricses("").List(metav1.ListOptions{}); err != nil {
t.Errorf("Unexpected error: %v", err)
}
if _, err := client.MetricsV1beta1().NodeMetricses().List(metav1.ListOptions{}); err != nil {
t.Errorf("Unexpected error: %v", err)
}
}