mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
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:
parent
c549b59983
commit
527b905aaa
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user