From 70eef5b3e1c20da3e619ae69767a1234392f0dd3 Mon Sep 17 00:00:00 2001 From: Mikhail Mazurskiy Date: Wed, 8 Feb 2017 21:54:40 +1100 Subject: [PATCH 1/2] Remove global variables --- staging/src/k8s.io/client-go/examples/out-of-cluster/main.go | 5 +---- .../k8s.io/client-go/examples/third-party-resources/main.go | 4 ---- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/staging/src/k8s.io/client-go/examples/out-of-cluster/main.go b/staging/src/k8s.io/client-go/examples/out-of-cluster/main.go index a8a4fb50a61..33bb6a5e1cd 100644 --- a/staging/src/k8s.io/client-go/examples/out-of-cluster/main.go +++ b/staging/src/k8s.io/client-go/examples/out-of-cluster/main.go @@ -26,11 +26,8 @@ import ( "k8s.io/client-go/tools/clientcmd" ) -var ( - kubeconfig = flag.String("kubeconfig", "./config", "absolute path to the kubeconfig file") -) - func main() { + kubeconfig := flag.String("kubeconfig", "./config", "absolute path to the kubeconfig file") flag.Parse() // uses the current context in kubeconfig config, err := clientcmd.BuildConfigFromFlags("", *kubeconfig) diff --git a/staging/src/k8s.io/client-go/examples/third-party-resources/main.go b/staging/src/k8s.io/client-go/examples/third-party-resources/main.go index 5218a80a9b9..0cd9c8f1955 100644 --- a/staging/src/k8s.io/client-go/examples/third-party-resources/main.go +++ b/staging/src/k8s.io/client-go/examples/third-party-resources/main.go @@ -35,10 +35,6 @@ import ( _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" ) -var ( - config *rest.Config -) - func main() { kubeconfig := flag.String("kubeconfig", "", "Path to a kube config. Only required if out-of-cluster.") flag.Parse() From 8af6cea1eb283f851d8001a7b11f756513a39990 Mon Sep 17 00:00:00 2001 From: Mikhail Mazurskiy Date: Fri, 17 Feb 2017 08:42:46 +1100 Subject: [PATCH 2/2] Test for types --- .../third-party-resources/types_test.go | 28 +++++++++++++++++++ vendor/BUILD | 11 ++++++++ 2 files changed, 39 insertions(+) create mode 100644 staging/src/k8s.io/client-go/examples/third-party-resources/types_test.go diff --git a/staging/src/k8s.io/client-go/examples/third-party-resources/types_test.go b/staging/src/k8s.io/client-go/examples/third-party-resources/types_test.go new file mode 100644 index 00000000000..f3f7bb1e660 --- /dev/null +++ b/staging/src/k8s.io/client-go/examples/third-party-resources/types_test.go @@ -0,0 +1,28 @@ +/* +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. +*/ + +package main + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +var _ runtime.Object = &Example{} +var _ metav1.ObjectMetaAccessor = &Example{} + +var _ runtime.Object = &ExampleList{} +var _ metav1.ListMetaAccessor = &ExampleList{} diff --git a/vendor/BUILD b/vendor/BUILD index 2209d074523..a5541a9beca 100644 --- a/vendor/BUILD +++ b/vendor/BUILD @@ -16905,3 +16905,14 @@ go_test( library = ":k8s.io/apimachinery/pkg/api/testing", tags = ["automanaged"], ) + +go_test( + name = "k8s.io/client-go/examples/third-party-resources_test", + srcs = ["k8s.io/client-go/examples/third-party-resources/types_test.go"], + library = ":k8s.io/client-go/examples/third-party-resources", + tags = ["automanaged"], + deps = [ + "//vendor:k8s.io/apimachinery/pkg/apis/meta/v1", + "//vendor:k8s.io/apimachinery/pkg/runtime", + ], +)