mirror of
https://github.com/coredns/coredns.git
synced 2025-11-18 09:52:17 -05:00
add golangci-lint linter (#5499)
This commit is contained in:
@@ -49,7 +49,6 @@ func newOverlapZone() *zoneOverlap {
|
||||
// registerAndCheck adds a new zoneAddr for validation, it returns information about existing or overlapping with already registered
|
||||
// we consider that an unbound address is overlapping all bound addresses for same zone, same port
|
||||
func (zo *zoneOverlap) registerAndCheck(z zoneAddr) (existingZone *zoneAddr, overlappingZone *zoneAddr) {
|
||||
|
||||
if exist, ok := zo.registeredAddr[z]; ok {
|
||||
// exact same zone already registered
|
||||
return &exist, nil
|
||||
|
||||
@@ -43,7 +43,6 @@ func TestSplitProtocolHostPort(t *testing.T) {
|
||||
if port != test.port {
|
||||
t.Errorf("Test %d: (address = %s) expected port with value %s but got %s", i, test.input, test.port, port)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +91,6 @@ func TestOverlapAddressChecker(t *testing.T) {
|
||||
},
|
||||
},
|
||||
} {
|
||||
|
||||
checker := newOverlapZone()
|
||||
for _, call := range test.sequence {
|
||||
same, overlap := checker.registerAndCheck(call.zone)
|
||||
@@ -108,10 +106,8 @@ func TestOverlapAddressChecker(t *testing.T) {
|
||||
if overlap.String() != call.overlapKey {
|
||||
t.Errorf("Test %d: error, for zone %s, 'overlap Key' (%v) has not the expected value (%v)", i, sZone, overlap.String(), call.overlapKey)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
)
|
||||
|
||||
func TestRegex1035PrefSyntax(t *testing.T) {
|
||||
|
||||
testCases := []struct {
|
||||
zone string
|
||||
expected bool
|
||||
|
||||
@@ -138,7 +138,6 @@ func (h *dnsContext) InspectServerBlocks(sourceFile string, serverBlocks []caddy
|
||||
|
||||
// MakeServers uses the newly-created siteConfigs to create and return a list of server instances.
|
||||
func (h *dnsContext) MakeServers() ([]caddy.Server, error) {
|
||||
|
||||
// Now that all Keys and Directives are parsed and initialized
|
||||
// lets verify that there is no overlap on the zones and addresses to listen for
|
||||
errValid := h.validateZonesAndListeningAddresses()
|
||||
@@ -197,7 +196,6 @@ func (h *dnsContext) MakeServers() ([]caddy.Server, error) {
|
||||
}
|
||||
servers = append(servers, s)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return servers, nil
|
||||
@@ -262,11 +260,9 @@ func (h *dnsContext) validateZonesAndListeningAddresses() error {
|
||||
if overlapZone != nil {
|
||||
return fmt.Errorf("cannot serve %s - zone overlap listener capacity with %v", akey.String(), overlapZone.String())
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
// groupSiteConfigsByListenAddr groups site configs by their listen
|
||||
|
||||
@@ -114,7 +114,6 @@ func TestGroupingServers(t *testing.T) {
|
||||
for _, v := range test.expectedGroups {
|
||||
if _, ok := groups[v]; !ok {
|
||||
t.Errorf("Test %d : expected value %v to be in the group, was not", i, v)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ type Server struct {
|
||||
// NewServer returns a new CoreDNS server and compiles all plugins in to it. By default CH class
|
||||
// queries are blocked unless queries from enableChaos are loaded.
|
||||
func NewServer(addr string, group []*Config) (*Server, error) {
|
||||
|
||||
s := &Server{
|
||||
Addr: addr,
|
||||
zones: make(map[string]*Config),
|
||||
@@ -174,7 +173,6 @@ func (s *Server) ListenPacket() (net.PacketConn, error) {
|
||||
// immediately.
|
||||
// This implements Caddy.Stopper interface.
|
||||
func (s *Server) Stop() (err error) {
|
||||
|
||||
if runtime.GOOS != "windows" {
|
||||
// force connections to close after timeout
|
||||
done := make(chan struct{})
|
||||
|
||||
@@ -82,7 +82,6 @@ func (s *ServergRPC) ServePacket(p net.PacketConn) error { return nil }
|
||||
|
||||
// Listen implements caddy.TCPServer interface.
|
||||
func (s *ServergRPC) Listen() (net.Listener, error) {
|
||||
|
||||
l, err := reuseport.Listen("tcp", s.Addr[len(transport.GRPC+"://"):])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -104,7 +104,6 @@ func (s *ServerHTTPS) ServePacket(p net.PacketConn) error { return nil }
|
||||
|
||||
// Listen implements caddy.TCPServer interface.
|
||||
func (s *ServerHTTPS) Listen() (net.Listener, error) {
|
||||
|
||||
l, err := reuseport.Listen("tcp", s.Addr[len(transport.HTTPS+"://"):])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -141,7 +140,6 @@ func (s *ServerHTTPS) Stop() error {
|
||||
// ServeHTTP is the handler that gets the HTTP request and converts to the dns format, calls the plugin
|
||||
// chain, converts it back and write it to the client.
|
||||
func (s *ServerHTTPS) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if !s.validRequest(r) {
|
||||
http.Error(w, "", http.StatusNotFound)
|
||||
s.countResponse(http.StatusNotFound)
|
||||
|
||||
Reference in New Issue
Block a user