From b052092297eeee8705f631ad542a5b342c270f7e Mon Sep 17 00:00:00 2001 From: aimuz Date: Fri, 28 Apr 2023 10:43:30 +0800 Subject: [PATCH] refactor(util): remove duplicate lg check lg always has a value Signed-off-by: aimuz --- server/etcdmain/util.go | 50 +++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/server/etcdmain/util.go b/server/etcdmain/util.go index 0bd23e9e5..f133b5759 100644 --- a/server/etcdmain/util.go +++ b/server/etcdmain/util.go @@ -35,13 +35,11 @@ func discoverEndpoints(lg *zap.Logger, dns string, ca string, insecure bool, ser } endpoints := srvs.Endpoints - if lg != nil { - lg.Info( - "discovered cluster from SRV", - zap.String("srv-server", dns), - zap.Strings("endpoints", endpoints), - ) - } + lg.Info( + "discovered cluster from SRV", + zap.String("srv-server", dns), + zap.Strings("endpoints", endpoints), + ) if insecure { return *srvs @@ -52,32 +50,26 @@ func discoverEndpoints(lg *zap.Logger, dns string, ca string, insecure bool, ser ServerName: dns, } - if lg != nil { - lg.Info( - "validating discovered SRV endpoints", - zap.String("srv-server", dns), - zap.Strings("endpoints", endpoints), - ) - } + lg.Info( + "validating discovered SRV endpoints", + zap.String("srv-server", dns), + zap.Strings("endpoints", endpoints), + ) endpoints, err = transport.ValidateSecureEndpoints(tlsInfo, endpoints) if err != nil { - if lg != nil { - lg.Warn( - "failed to validate discovered endpoints", - zap.String("srv-server", dns), - zap.Strings("endpoints", endpoints), - zap.Error(err), - ) - } + lg.Warn( + "failed to validate discovered endpoints", + zap.String("srv-server", dns), + zap.Strings("endpoints", endpoints), + zap.Error(err), + ) } else { - if lg != nil { - lg.Info( - "using validated discovered SRV endpoints", - zap.String("srv-server", dns), - zap.Strings("endpoints", endpoints), - ) - } + lg.Info( + "using validated discovered SRV endpoints", + zap.String("srv-server", dns), + zap.Strings("endpoints", endpoints), + ) } // map endpoints back to SRVClients struct with SRV data