From 72322d0c6db809e33a95c4e9c651723a25fda84a Mon Sep 17 00:00:00 2001 From: David Eads Date: Thu, 12 Apr 2018 09:42:25 -0400 Subject: [PATCH 1/2] stop defaulting kubeconfig to http://localhost:8080 Kubernetes-commit: b19ad9e7a78fea0ecdffe7aa53bbe309d9d346ee --- tools/clientcmd/client_config.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/tools/clientcmd/client_config.go b/tools/clientcmd/client_config.go index a9806384a..5096f51d2 100644 --- a/tools/clientcmd/client_config.go +++ b/tools/clientcmd/client_config.go @@ -35,7 +35,7 @@ import ( var ( // ClusterDefaults has the same behavior as the old EnvVar and DefaultCluster fields // DEPRECATED will be replaced - ClusterDefaults = clientcmdapi.Cluster{Server: getDefaultServer()} + ClusterDefaults = clientcmdapi.Cluster{Server: os.Getenv("KUBERNETES_MASTER")} // DefaultClientConfig represents the legacy behavior of this package for defaulting // DEPRECATED will be replace DefaultClientConfig = DirectClientConfig{*clientcmdapi.NewConfig(), "", &ConfigOverrides{ @@ -43,15 +43,6 @@ var ( }, nil, NewDefaultClientConfigLoadingRules(), promptedCredentials{}} ) -// getDefaultServer returns a default setting for DefaultClientConfig -// DEPRECATED -func getDefaultServer() string { - if server := os.Getenv("KUBERNETES_MASTER"); len(server) > 0 { - return server - } - return "http://localhost:8080" -} - // ClientConfig is used to make it easy to get an api server client type ClientConfig interface { // RawConfig returns the merged result of all overrides From 3eda474fcebb4801872a0a6404530afa2b80c80e Mon Sep 17 00:00:00 2001 From: Maciej Szulik Date: Tue, 3 Mar 2020 18:42:19 +0100 Subject: [PATCH 2/2] Provide more verbose empty config error based on the context Kubernetes-commit: 07dc17ffd9aadd9918511334e13b02dc817828a5 --- tools/clientcmd/validation.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/clientcmd/validation.go b/tools/clientcmd/validation.go index 2f927072b..02dd1130f 100644 --- a/tools/clientcmd/validation.go +++ b/tools/clientcmd/validation.go @@ -30,7 +30,7 @@ import ( var ( ErrNoContext = errors.New("no context chosen") - ErrEmptyConfig = errors.New("no configuration has been provided") + ErrEmptyConfig = errors.New("no configuration has been provided, try setting KUBERNETES_MASTER environment variable") // message is for consistency with old behavior ErrEmptyCluster = errors.New("cluster has no server defined") )