mw/kubernetes: revert if-else for health (#970)
Do the return early and dedent the rest of the function.
This commit is contained in:
parent
4b105c761e
commit
10b7221067
1 changed files with 58 additions and 56 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue