Merge pull request #53308 from LiliC/remove-func

Automatic merge from submit-queue (batch tested with PRs 50447, 53308). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

apiextensions/examples: remove unnecessary function

**What this PR does / why we need it**:

The `BuildConfigFromFlags` function already calls the `InClusterConfig` function.

**Special notes for your reviewer**:

If this function was added to bypass [the warning](https://github.com/kubernetes/client-go/blob/master/tools/clientcmd/client_config.go#L529), then maybe we should instead add a comment.

/cc @sttts @nikhita
This commit is contained in:
Kubernetes Submit Queue 2017-10-09 00:32:13 -07:00 committed by GitHub
commit 5d8046e482
2 changed files with 3 additions and 11 deletions

View File

@ -17,7 +17,6 @@ go_library(
"//vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/client-go/rest:go_default_library",
"//vendor/k8s.io/client-go/tools/clientcmd:go_default_library",
],
)

View File

@ -26,7 +26,6 @@ import (
apiextensionsclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
// Uncomment the following line to load the gcp plugin (only required to authenticate against GKE clusters).
@ -38,11 +37,12 @@ import (
)
func main() {
masterURL := flag.String("master", "", "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.")
kubeconfig := flag.String("kubeconfig", "", "Path to a kube config. Only required if out-of-cluster.")
flag.Parse()
// Create the client config. Use kubeconfig if given, otherwise assume in-cluster.
config, err := buildConfig(*kubeconfig)
// Create the client config. Use masterURL and kubeconfig if given, otherwise assume in-cluster.
config, err := clientcmd.BuildConfigFromFlags(*masterURL, *kubeconfig)
if err != nil {
panic(err)
}
@ -121,10 +121,3 @@ func main() {
}
fmt.Printf("LIST: %#v\n", exampleList)
}
func buildConfig(kubeconfig string) (*rest.Config, error) {
if kubeconfig != "" {
return clientcmd.BuildConfigFromFlags("", kubeconfig)
}
return rest.InClusterConfig()
}