mw/kubernetes: revert if-else for health
Do the return early and dedent the rest of the function.
@@ -154,7 +154,15 @@ func (k *Kubernetes) getClientConfig() (*rest.Config, error) {
overrides := &clientcmd.ConfigOverrides{}
clusterinfo := clientcmdapi.Cluster{}
authinfo := clientcmdapi.AuthInfo{}
- if len(k.APIServerList) > 0 {
+
+ if len(k.APIServerList) == 0 {
+ cc, err := rest.InClusterConfig()
+ if err != nil {
+ return nil, err
+ }
+ return cc, err
+ }
+
endpoint := k.APIServerList[0]
if len(k.APIServerList) > 1 {
// Use a random port for api proxy, will get the value later through listener.Addr()
@@ -210,13 +218,7 @@ func (k *Kubernetes) getClientConfig() (*rest.Config, error) {
endpoint = fmt.Sprintf("http://%s", listener.Addr())
}
clusterinfo.Server = endpoint
- } else {
- cc, err := rest.InClusterConfig()
- if err != nil {
- return nil, err
- }
- return cc, err
- }
+
if len(k.APICertAuth) > 0 {
clusterinfo.CertificateAuthority = k.APICertAuth
}
