mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-30 17:53:21 -04:00 
			
		
		
		
	mw/kubernetes: revert if-else for health (#970)
Do the return early and dedent the rest of the function.
This commit is contained in:
		| @@ -154,7 +154,15 @@ func (k *Kubernetes) getClientConfig() (*rest.Config, error) { | |||||||
| 	overrides := &clientcmd.ConfigOverrides{} | 	overrides := &clientcmd.ConfigOverrides{} | ||||||
| 	clusterinfo := clientcmdapi.Cluster{} | 	clusterinfo := clientcmdapi.Cluster{} | ||||||
| 	authinfo := clientcmdapi.AuthInfo{} | 	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] | 	endpoint := k.APIServerList[0] | ||||||
| 	if len(k.APIServerList) > 1 { | 	if len(k.APIServerList) > 1 { | ||||||
| 		// Use a random port for api proxy, will get the value later through listener.Addr() | 		// 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()) | 		endpoint = fmt.Sprintf("http://%s", listener.Addr()) | ||||||
| 	} | 	} | ||||||
| 	clusterinfo.Server = endpoint | 	clusterinfo.Server = endpoint | ||||||
| 	} else { |  | ||||||
| 		cc, err := rest.InClusterConfig() |  | ||||||
| 		if err != nil { |  | ||||||
| 			return nil, err |  | ||||||
| 		} |  | ||||||
| 		return cc, err |  | ||||||
| 	} |  | ||||||
| 	if len(k.APICertAuth) > 0 { | 	if len(k.APICertAuth) > 0 { | ||||||
| 		clusterinfo.CertificateAuthority = k.APICertAuth | 		clusterinfo.CertificateAuthority = k.APICertAuth | ||||||
| 	} | 	} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user