cmd/kubeapiserver: Clean code, avoid unnecessary condition, avoid non-nil but zero-length slice

Signed-off-by: TommyStarK <thomasmilox@gmail.com>
This commit is contained in:
TommyStarK 2023-01-05 20:56:39 +01:00
parent c549b59983
commit 527b905aaa

View File

@ -218,12 +218,7 @@ func CreateServerChain(completedOptions completedServerRunOptions) (*aggregatora
// CreateKubeAPIServer creates and wires a workable kube-apiserver
func CreateKubeAPIServer(kubeAPIServerConfig *controlplane.Config, delegateAPIServer genericapiserver.DelegationTarget) (*controlplane.Instance, error) {
kubeAPIServer, err := kubeAPIServerConfig.Complete().New(delegateAPIServer)
if err != nil {
return nil, err
}
return kubeAPIServer, nil
return kubeAPIServerConfig.Complete().New(delegateAPIServer)
}
// CreateProxyTransport creates the dialer infrastructure to connect to the nodes.
@ -546,11 +541,11 @@ func Complete(s *options.ServerRunOptions) (completedServerRunOptions, error) {
if len(s.GenericServerRunOptions.AdvertiseAddress) > 0 {
s.GenericServerRunOptions.ExternalHost = s.GenericServerRunOptions.AdvertiseAddress.String()
} else {
if hostname, err := os.Hostname(); err == nil {
s.GenericServerRunOptions.ExternalHost = hostname
} else {
hostname, err := os.Hostname()
if err != nil {
return options, fmt.Errorf("error finding host name: %v", err)
}
s.GenericServerRunOptions.ExternalHost = hostname
}
klog.Infof("external host was not specified, using %v", s.GenericServerRunOptions.ExternalHost)
}