From adf82d72ae5fd9f661df0e307ce89ac887c40aff Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Wed, 31 Aug 2022 08:24:08 +0200 Subject: [PATCH] chore: update linter --- .github/workflows/validate.yaml | 2 +- .golangci.toml | 23 ++++++++++---- .semaphore/semaphore.yml | 2 +- build.Dockerfile | 2 +- cmd/healthcheck/healthcheck.go | 2 +- cmd/internal/gen/centrifuge.go | 16 ++++------ integration/consul_catalog_test.go | 4 +-- integration/docker_test.go | 10 +++---- integration/integration_test.go | 4 +-- internal/gendoc.go | 2 +- pkg/api/debug.go | 2 +- pkg/config/dynamic/http_config.go | 4 +-- pkg/metrics/metrics.go | 5 ++++ pkg/middlewares/metrics/metrics.go | 2 ++ pkg/middlewares/ratelimiter/rate_limiter.go | 4 +-- pkg/provider/acme/provider_test.go | 2 +- pkg/provider/consulcatalog/config.go | 33 ++++++++++----------- pkg/provider/kv/kv_mock_test.go | 2 +- pkg/server/middleware/middlewares.go | 2 +- pkg/server/router/tcp/router.go | 4 +-- pkg/server/router/udp/router.go | 10 ++----- pkg/server/service/service.go | 2 +- pkg/tls/certificate_store_test.go | 2 +- 23 files changed, 74 insertions(+), 67 deletions(-) diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index 5f2556973..68d56b505 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -7,7 +7,7 @@ on: env: GO_VERSION: 1.19 - GOLANGCI_LINT_VERSION: v1.48.0 + GOLANGCI_LINT_VERSION: v1.49.0 MISSSPELL_VERSION: v0.3.4 IN_DOCKER: "" diff --git a/.golangci.toml b/.golangci.toml index 9868d169d..318e5cace 100644 --- a/.golangci.toml +++ b/.golangci.toml @@ -119,7 +119,12 @@ "interfacer", # Deprecated "maligned", # Deprecated "golint", # Deprecated + "exhaustivestruct",# Deprecated "nosnakecase", # Deprecated + "ifshort", # Deprecated + "structcheck", # Deprecated + "varcheck", # Deprecated + "deadcode", # Deprecated "execinquery", # Not relevant (SQL) "sqlclosecheck", # Not relevant (SQL) "rowserrcheck", # Not relevant (SQL) @@ -130,7 +135,6 @@ "nestif", # Too many false-positive. "prealloc", # Too many false-positive. "makezero", # Not relevant - "ifshort", # Not relevant "dupl", # Too strict "gosec", # Too strict "gochecknoinits", @@ -143,14 +147,11 @@ "tparallel", # Not relevant "paralleltest", # Not relevant "exhaustive", # Not relevant - "exhaustivestruct", # Not relevant "exhaustruct", # duplicate of exhaustivestruct "goerr113", # Too strict "wrapcheck", # Too strict "noctx", # Too strict "bodyclose", # Too many false-positive and panics. - "unparam", # Too strict - "godox", # Too strict "forcetypeassert", # Too strict "tagliatelle", # Not compatible with current tags. "varnamelen", # not relevant @@ -160,7 +161,6 @@ "containedctx", # too many false-positive "maintidx", # kind of duplicate of gocyclo "nonamedreturns", # not relevant - "structcheck", # duplicate of unused ] [issues] @@ -182,6 +182,10 @@ [[issues.exclude-rules]] path = "(.+)_test.go" linters = ["goconst", "funlen", "godot", "nosnakecase"] + [[issues.exclude-rules]] + path = "(.+)_test.go" + text = " always receives " + linters = [ "unparam" ] [[issues.exclude-rules]] path = "integration/.+_test.go" text = "Error return value of `cmd\\.Process\\.Kill` is not checked" @@ -230,4 +234,13 @@ [[issues.exclude-rules]] path = "pkg/types/tls_test.go" text = "SA1019: tlsConfig.RootCAs.Subjects has been deprecated since Go 1.18" + [[issues.exclude-rules]] + path = "pkg/provider/kubernetes/(crd|gateway)/client.go" + linters = ["interfacebloat"] + [[issues.exclude-rules]] + path = "pkg/metrics/metrics.go" + linters = ["interfacebloat"] + [[issues.exclude-rules]] + path = "pkg/provider/acme/provider.go" + text = "\\(\\*Provider\\)\\.resolveCertificate - result 0 \\(\\*github.com/go-acme/lego/v4/certificate.Resource\\) is never used" diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 766773490..a1db57df9 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -25,7 +25,7 @@ global_job_config: - export "PATH=${GOPATH}/bin:${PATH}" - mkdir -vp "${SEMAPHORE_GIT_DIR}" "${GOPATH}/bin" - export GOPROXY=https://proxy.golang.org,direct - - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "${GOPATH}/bin" v1.48.0 + - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "${GOPATH}/bin" v1.49.0 - curl -sSfL https://gist.githubusercontent.com/traefiker/6d7ac019c11d011e4f131bb2cca8900e/raw/goreleaser.sh | bash -s -- -b "${GOPATH}/bin" - checkout - cache restore traefik-$(checksum go.sum) diff --git a/build.Dockerfile b/build.Dockerfile index 0c28e6c49..434cd31b3 100644 --- a/build.Dockerfile +++ b/build.Dockerfile @@ -13,7 +13,7 @@ RUN mkdir -p /usr/local/bin \ | tar -xzC /usr/local/bin --transform 's#^.+/##x' # Download golangci-lint binary to bin folder in $GOPATH -RUN curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- -b $GOPATH/bin v1.48.0 +RUN curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- -b $GOPATH/bin v1.49.0 # Download misspell binary to bin folder in $GOPATH RUN curl -sfL https://raw.githubusercontent.com/client9/misspell/master/install-misspell.sh | bash -s -- -b $GOPATH/bin v0.3.4 diff --git a/cmd/healthcheck/healthcheck.go b/cmd/healthcheck/healthcheck.go index c63ee6341..fbeaee566 100644 --- a/cmd/healthcheck/healthcheck.go +++ b/cmd/healthcheck/healthcheck.go @@ -64,7 +64,7 @@ func Do(staticConfiguration static.Configuration) (*http.Response, error) { client := &http.Client{Timeout: 5 * time.Second} protocol := "http" - // FIXME Handle TLS on ping etc... + // TODO Handle TLS on ping etc... // if pingEntryPoint.TLS != nil { // protocol = "https" // tr := &http.Transport{ diff --git a/cmd/internal/gen/centrifuge.go b/cmd/internal/gen/centrifuge.go index bb58f9c19..824f4fa3e 100644 --- a/cmd/internal/gen/centrifuge.go +++ b/cmd/internal/gen/centrifuge.go @@ -72,22 +72,16 @@ func NewCentrifuge(rootPkg string) (*Centrifuge, error) { // Run runs the code extraction and the code generation. func (c Centrifuge) Run(dest string, pkgName string) error { - files, err := c.run(c.pkg.Scope(), c.rootPkg, pkgName) - if err != nil { - return err - } + files := c.run(c.pkg.Scope(), c.rootPkg, pkgName) - err = fileWriter{baseDir: dest}.Write(files) + err := fileWriter{baseDir: dest}.Write(files) if err != nil { return err } for _, p := range c.pkg.Imports() { if contains(c.IncludedImports, p.Path()) { - fls, err := c.run(p.Scope(), p.Path(), p.Name()) - if err != nil { - return err - } + fls := c.run(p.Scope(), p.Path(), p.Name()) err = fileWriter{baseDir: filepath.Join(dest, p.Name())}.Write(fls) if err != nil { @@ -99,7 +93,7 @@ func (c Centrifuge) Run(dest string, pkgName string) error { return err } -func (c Centrifuge) run(sc *types.Scope, rootPkg string, pkgName string) (map[string]*File, error) { +func (c Centrifuge) run(sc *types.Scope, rootPkg string, pkgName string) map[string]*File { files := map[string]*File{} for _, name := range sc.Names() { @@ -158,7 +152,7 @@ func (c Centrifuge) run(sc *types.Scope, rootPkg string, pkgName string) (map[st } } - return files, nil + return files } func (c Centrifuge) writeStruct(name string, obj *types.Struct, rootPkg string, elt *File) string { diff --git a/integration/consul_catalog_test.go b/integration/consul_catalog_test.go index fa64d251c..bdefbd4cc 100644 --- a/integration/consul_catalog_test.go +++ b/integration/consul_catalog_test.go @@ -603,7 +603,7 @@ func (s *ConsulCatalogSuite) TestConsulServiceWithOneMissingLabels(c *check.C) { c.Assert(err, checker.IsNil) req.Host = "my.super.host" - // FIXME Need to wait than 500 milliseconds more (for swarm or traefik to boot up ?) + // TODO Need to wait than 500 milliseconds more (for swarm or traefik to boot up ?) // TODO validate : run on 80 // Expected a 404 as we did not configure anything err = try.Request(req, 1500*time.Millisecond, try.StatusCodeIs(http.StatusNotFound)) @@ -681,7 +681,7 @@ func (s *ConsulCatalogSuite) TestConsulServiceWithHealthCheck(c *check.C) { c.Assert(err, checker.IsNil) req.Host = "whoami" - // FIXME Need to wait for up to 10 seconds (for consul discovery or traefik to boot up ?) + // TODO Need to wait for up to 10 seconds (for consul discovery or traefik to boot up ?) err = try.Request(req, 10*time.Second, try.StatusCodeIs(200), try.BodyContainsOr("Hostname: whoami2")) c.Assert(err, checker.IsNil) diff --git a/integration/docker_test.go b/integration/docker_test.go index 1dea98ba8..fe7051f7f 100644 --- a/integration/docker_test.go +++ b/integration/docker_test.go @@ -78,7 +78,7 @@ func (s *DockerSuite) TestDefaultDockerContainers(c *check.C) { c.Assert(err, checker.IsNil) req.Host = fmt.Sprintf("simple-%s.docker.localhost", s.composeProject.Name) - // FIXME Need to wait than 500 milliseconds more (for swarm or traefik to boot up ?) + // TODO Need to wait than 500 milliseconds more (for swarm or traefik to boot up ?) resp, err := try.ResponseUntilStatusCode(req, 1500*time.Millisecond, http.StatusOK) c.Assert(err, checker.IsNil) @@ -147,7 +147,7 @@ func (s *DockerSuite) TestDockerContainersWithLabels(c *check.C) { c.Assert(err, checker.IsNil) req.Host = "my-super.host" - // FIXME Need to wait than 500 milliseconds more (for swarm or traefik to boot up ?) + // TODO Need to wait than 500 milliseconds more (for swarm or traefik to boot up ?) _, err = try.ResponseUntilStatusCode(req, 1500*time.Millisecond, http.StatusOK) c.Assert(err, checker.IsNil) @@ -155,7 +155,7 @@ func (s *DockerSuite) TestDockerContainersWithLabels(c *check.C) { c.Assert(err, checker.IsNil) req.Host = "my.super.host" - // FIXME Need to wait than 500 milliseconds more (for swarm or traefik to boot up ?) + // TODO Need to wait than 500 milliseconds more (for swarm or traefik to boot up ?) resp, err := try.ResponseUntilStatusCode(req, 1500*time.Millisecond, http.StatusOK) c.Assert(err, checker.IsNil) @@ -194,7 +194,7 @@ func (s *DockerSuite) TestDockerContainersWithOneMissingLabels(c *check.C) { c.Assert(err, checker.IsNil) req.Host = "my.super.host" - // FIXME Need to wait than 500 milliseconds more (for swarm or traefik to boot up ?) + // TODO Need to wait than 500 milliseconds more (for swarm or traefik to boot up ?) // TODO validate : run on 80 // Expected a 404 as we did not configure anything err = try.Request(req, 1500*time.Millisecond, try.StatusCodeIs(http.StatusNotFound)) @@ -227,7 +227,7 @@ func (s *DockerSuite) TestRestartDockerContainers(c *check.C) { c.Assert(err, checker.IsNil) req.Host = "my.super.host" - // FIXME Need to wait than 500 milliseconds more (for swarm or traefik to boot up ?) + // TODO Need to wait than 500 milliseconds more (for swarm or traefik to boot up ?) resp, err := try.ResponseUntilStatusCode(req, 1500*time.Millisecond, http.StatusOK) c.Assert(err, checker.IsNil) diff --git a/integration/integration_test.go b/integration/integration_test.go index c2a593f58..af3d35ca1 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -209,14 +209,14 @@ func (s *BaseSuite) traefikCmd(args ...string) (*exec.Cmd, func(*check.C)) { cmd, out := s.cmdTraefik(args...) return cmd, func(c *check.C) { if c.Failed() || *showLog { - s.displayLogK3S(c) + s.displayLogK3S() s.displayLogCompose(c) s.displayTraefikLog(c, out) } } } -func (s *BaseSuite) displayLogK3S(c *check.C) { +func (s *BaseSuite) displayLogK3S() { filePath := "./fixtures/k8s/config.skip/k3s.log" if _, err := os.Stat(filePath); err == nil { content, errR := os.ReadFile(filePath) diff --git a/internal/gendoc.go b/internal/gendoc.go index c8d739445..b761debc8 100644 --- a/internal/gendoc.go +++ b/internal/gendoc.go @@ -135,7 +135,7 @@ type storeWriter struct { data map[string]string } -func (f storeWriter) Put(key string, value []byte, options []string) error { +func (f storeWriter) Put(key string, value []byte, _ []string) error { f.data[key] = string(value) return nil } diff --git a/pkg/api/debug.go b/pkg/api/debug.go index 448b7c7ee..b207043ef 100644 --- a/pkg/api/debug.go +++ b/pkg/api/debug.go @@ -11,7 +11,7 @@ import ( ) func init() { - // FIXME Goroutines2 -> Goroutines + // TODO Goroutines2 -> Goroutines expvar.Publish("Goroutines2", expvar.Func(goroutines)) } diff --git a/pkg/config/dynamic/http_config.go b/pkg/config/dynamic/http_config.go index 7cf4f64ff..d256575b7 100644 --- a/pkg/config/dynamic/http_config.go +++ b/pkg/config/dynamic/http_config.go @@ -215,9 +215,9 @@ type ServerHealthCheck struct { Scheme string `json:"scheme,omitempty" toml:"scheme,omitempty" yaml:"scheme,omitempty" export:"true"` Path string `json:"path,omitempty" toml:"path,omitempty" yaml:"path,omitempty" export:"true"` Port int `json:"port,omitempty" toml:"port,omitempty,omitzero" yaml:"port,omitempty" export:"true"` - // FIXME change string to ptypes.Duration + // TODO change string to ptypes.Duration Interval string `json:"interval,omitempty" toml:"interval,omitempty" yaml:"interval,omitempty" export:"true"` - // FIXME change string to ptypes.Duration + // TODO change string to ptypes.Duration Timeout string `json:"timeout,omitempty" toml:"timeout,omitempty" yaml:"timeout,omitempty" export:"true"` Hostname string `json:"hostname,omitempty" toml:"hostname,omitempty" yaml:"hostname,omitempty"` FollowRedirects *bool `json:"followRedirects" toml:"followRedirects" yaml:"followRedirects" export:"true"` diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index 9be5249a4..2698df768 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -20,27 +20,32 @@ type Registry interface { IsSvcEnabled() bool // server metrics + ConfigReloadsCounter() metrics.Counter ConfigReloadsFailureCounter() metrics.Counter LastConfigReloadSuccessGauge() metrics.Gauge LastConfigReloadFailureGauge() metrics.Gauge // TLS + TLSCertsNotAfterTimestampGauge() metrics.Gauge // entry point metrics + EntryPointReqsCounter() metrics.Counter EntryPointReqsTLSCounter() metrics.Counter EntryPointReqDurationHistogram() ScalableHistogram EntryPointOpenConnsGauge() metrics.Gauge // router metrics + RouterReqsCounter() metrics.Counter RouterReqsTLSCounter() metrics.Counter RouterReqDurationHistogram() ScalableHistogram RouterOpenConnsGauge() metrics.Gauge // service metrics + ServiceReqsCounter() metrics.Counter ServiceReqsTLSCounter() metrics.Counter ServiceReqDurationHistogram() ScalableHistogram diff --git a/pkg/middlewares/metrics/metrics.go b/pkg/middlewares/metrics/metrics.go index 327e61e18..21392d472 100644 --- a/pkg/middlewares/metrics/metrics.go +++ b/pkg/middlewares/metrics/metrics.go @@ -166,6 +166,8 @@ func containsHeader(req *http.Request, name, value string) bool { // values that are not part of the set of HTTP verbs are replaced with EXTENSION_METHOD. // See https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods // https://datatracker.ietf.org/doc/html/rfc2616/#section-5.1.1. +// +//nolint:usestdlibvars func getMethod(r *http.Request) string { if !utf8.ValidString(r.Method) { log.WithoutContext().Warnf("Invalid HTTP method encoding: %s", r.Method) diff --git a/pkg/middlewares/ratelimiter/rate_limiter.go b/pkg/middlewares/ratelimiter/rate_limiter.go index 93ab92ec7..403c97199 100644 --- a/pkg/middlewares/ratelimiter/rate_limiter.go +++ b/pkg/middlewares/ratelimiter/rate_limiter.go @@ -166,7 +166,7 @@ func (rl *rateLimiter) ServeHTTP(w http.ResponseWriter, r *http.Request) { delay := res.Delay() if delay > rl.maxDelay { res.Cancel() - rl.serveDelayError(ctx, w, r, delay) + rl.serveDelayError(ctx, w, delay) return } @@ -174,7 +174,7 @@ func (rl *rateLimiter) ServeHTTP(w http.ResponseWriter, r *http.Request) { rl.next.ServeHTTP(w, r) } -func (rl *rateLimiter) serveDelayError(ctx context.Context, w http.ResponseWriter, r *http.Request, delay time.Duration) { +func (rl *rateLimiter) serveDelayError(ctx context.Context, w http.ResponseWriter, delay time.Duration) { w.Header().Set("Retry-After", fmt.Sprintf("%.0f", math.Ceil(delay.Seconds()))) w.Header().Set("X-Retry-In", delay.String()) w.WriteHeader(http.StatusTooManyRequests) diff --git a/pkg/provider/acme/provider_test.go b/pkg/provider/acme/provider_test.go index 103eff59e..799ab6b11 100644 --- a/pkg/provider/acme/provider_test.go +++ b/pkg/provider/acme/provider_test.go @@ -26,7 +26,7 @@ func TestGetUncheckedCertificates(t *testing.T) { domainSafe := &safe.Safe{} domainSafe.Set(domainMap) - // FIXME Add a test for DefaultCertificate + // TODO Add a test for DefaultCertificate testCases := []struct { desc string dynamicCerts *safe.Safe diff --git a/pkg/provider/consulcatalog/config.go b/pkg/provider/consulcatalog/config.go index 19fe33084..9a81a9c63 100644 --- a/pkg/provider/consulcatalog/config.go +++ b/pkg/provider/consulcatalog/config.go @@ -37,7 +37,7 @@ func (p *Provider) buildConfiguration(ctx context.Context, items []itemData, cer if len(confFromLabel.TCP.Routers) > 0 || len(confFromLabel.TCP.Services) > 0 { tcpOrUDP = true - err := p.buildTCPServiceConfiguration(ctxSvc, item, confFromLabel.TCP) + err := p.buildTCPServiceConfiguration(item, confFromLabel.TCP) if err != nil { logger.Error(err) continue @@ -49,7 +49,7 @@ func (p *Provider) buildConfiguration(ctx context.Context, items []itemData, cer if len(confFromLabel.UDP.Routers) > 0 || len(confFromLabel.UDP.Services) > 0 { tcpOrUDP = true - err := p.buildUDPServiceConfiguration(ctxSvc, item, confFromLabel.UDP) + err := p.buildUDPServiceConfiguration(item, confFromLabel.UDP) if err != nil { logger.Error(err) continue @@ -75,7 +75,7 @@ func (p *Provider) buildConfiguration(ctx context.Context, items []itemData, cer } } - err = p.buildServiceConfiguration(ctxSvc, item, confFromLabel.HTTP) + err = p.buildServiceConfiguration(item, confFromLabel.HTTP) if err != nil { logger.Error(err) continue @@ -128,7 +128,7 @@ func (p *Provider) keepContainer(ctx context.Context, item itemData) bool { return true } -func (p *Provider) buildTCPServiceConfiguration(ctx context.Context, item itemData, configuration *dynamic.TCPConfiguration) error { +func (p *Provider) buildTCPServiceConfiguration(item itemData, configuration *dynamic.TCPConfiguration) error { if len(configuration.Services) == 0 { configuration.Services = make(map[string]*dynamic.TCPService) @@ -141,17 +141,16 @@ func (p *Provider) buildTCPServiceConfiguration(ctx context.Context, item itemDa } for name, service := range configuration.Services { - ctxSvc := log.With(ctx, log.Str(log.ServiceName, name)) - err := p.addServerTCP(ctxSvc, item, service.LoadBalancer) + err := p.addServerTCP(item, service.LoadBalancer) if err != nil { - return err + return fmt.Errorf("%s: %w", name, err) } } return nil } -func (p *Provider) buildUDPServiceConfiguration(ctx context.Context, item itemData, configuration *dynamic.UDPConfiguration) error { +func (p *Provider) buildUDPServiceConfiguration(item itemData, configuration *dynamic.UDPConfiguration) error { if len(configuration.Services) == 0 { configuration.Services = make(map[string]*dynamic.UDPService) @@ -163,17 +162,16 @@ func (p *Provider) buildUDPServiceConfiguration(ctx context.Context, item itemDa } for name, service := range configuration.Services { - ctxSvc := log.With(ctx, log.Str(log.ServiceName, name)) - err := p.addServerUDP(ctxSvc, item, service.LoadBalancer) + err := p.addServerUDP(item, service.LoadBalancer) if err != nil { - return err + return fmt.Errorf("%s: %w", name, err) } } return nil } -func (p *Provider) buildServiceConfiguration(ctx context.Context, item itemData, configuration *dynamic.HTTPConfiguration) error { +func (p *Provider) buildServiceConfiguration(item itemData, configuration *dynamic.HTTPConfiguration) error { if len(configuration.Services) == 0 { configuration.Services = make(map[string]*dynamic.Service) @@ -186,17 +184,16 @@ func (p *Provider) buildServiceConfiguration(ctx context.Context, item itemData, } for name, service := range configuration.Services { - ctxSvc := log.With(ctx, log.Str(log.ServiceName, name)) - err := p.addServer(ctxSvc, item, service.LoadBalancer) + err := p.addServer(item, service.LoadBalancer) if err != nil { - return err + return fmt.Errorf("%s: %w", name, err) } } return nil } -func (p *Provider) addServerTCP(ctx context.Context, item itemData, loadBalancer *dynamic.TCPServersLoadBalancer) error { +func (p *Provider) addServerTCP(item itemData, loadBalancer *dynamic.TCPServersLoadBalancer) error { if loadBalancer == nil { return errors.New("load-balancer is not defined") } @@ -227,7 +224,7 @@ func (p *Provider) addServerTCP(ctx context.Context, item itemData, loadBalancer return nil } -func (p *Provider) addServerUDP(ctx context.Context, item itemData, loadBalancer *dynamic.UDPServersLoadBalancer) error { +func (p *Provider) addServerUDP(item itemData, loadBalancer *dynamic.UDPServersLoadBalancer) error { if loadBalancer == nil { return errors.New("load-balancer is not defined") } @@ -254,7 +251,7 @@ func (p *Provider) addServerUDP(ctx context.Context, item itemData, loadBalancer return nil } -func (p *Provider) addServer(ctx context.Context, item itemData, loadBalancer *dynamic.ServersLoadBalancer) error { +func (p *Provider) addServer(item itemData, loadBalancer *dynamic.ServersLoadBalancer) error { if loadBalancer == nil { return errors.New("load-balancer is not defined") } diff --git a/pkg/provider/kv/kv_mock_test.go b/pkg/provider/kv/kv_mock_test.go index 14c45a6c8..635f95ac3 100644 --- a/pkg/provider/kv/kv_mock_test.go +++ b/pkg/provider/kv/kv_mock_test.go @@ -97,7 +97,7 @@ func (s *Mock) List(ctx context.Context, prefix string, options *store.ReadOptio } var kv []*store.KVPair for _, kvPair := range s.KVPairs { - if strings.HasPrefix(kvPair.Key, prefix) { // FIXME && !strings.ContainsAny(strings.TrimPrefix(kvPair.Key, prefix), "/") { + if strings.HasPrefix(kvPair.Key, prefix) { kv = append(kv, kvPair) } } diff --git a/pkg/server/middleware/middlewares.go b/pkg/server/middleware/middlewares.go index 547e04248..2695db107 100644 --- a/pkg/server/middleware/middlewares.go +++ b/pkg/server/middleware/middlewares.go @@ -314,7 +314,7 @@ func (b *Builder) buildConstructor(ctx context.Context, middlewareName string) ( return nil, badConf } middleware = func(next http.Handler) (http.Handler, error) { - // FIXME missing metrics / accessLog + // TODO missing metrics / accessLog return retry.New(ctx, next, *config.Retry, retry.Listeners{}, middlewareName) } } diff --git a/pkg/server/router/tcp/router.go b/pkg/server/router/tcp/router.go index 3bcdbcacc..26f8131fe 100644 --- a/pkg/server/router/tcp/router.go +++ b/pkg/server/router/tcp/router.go @@ -106,7 +106,7 @@ func (r *Router) ServeTCP(conn tcp.WriteCloser) { // we still need to reply with a 404. } - // FIXME -- Check if ProxyProtocol changes the first bytes of the request + // TODO -- Check if ProxyProtocol changes the first bytes of the request br := bufio.NewReader(conn) serverName, tls, peeked, err := clientHelloServerName(br) if err != nil { @@ -218,7 +218,7 @@ func (r *Router) AddHTTPTLSConfig(sniHost string, config *tls.Config) { // GetConn creates a connection proxy with a peeked string. func (r *Router) GetConn(conn tcp.WriteCloser, peeked string) tcp.WriteCloser { - // FIXME should it really be on Router ? + // TODO should it really be on Router ? conn = &Conn{ Peeked: []byte(peeked), WriteCloser: conn, diff --git a/pkg/server/router/udp/router.go b/pkg/server/router/udp/router.go index 8fb607c8d..75bea883a 100644 --- a/pkg/server/router/udp/router.go +++ b/pkg/server/router/udp/router.go @@ -52,11 +52,7 @@ func (m *Manager) BuildHandlers(rootCtx context.Context, entryPoints []string) m log.FromContext(ctx).Warn("Config has more than one udp router for a given entrypoint.") } - handlers, err := m.buildEntryPointHandlers(ctx, routers) - if err != nil { - log.FromContext(ctx).Error(err) - continue - } + handlers := m.buildEntryPointHandlers(ctx, routers) if len(handlers) > 0 { // As UDP support only one router per entrypoint, we only take the first one. @@ -66,7 +62,7 @@ func (m *Manager) BuildHandlers(rootCtx context.Context, entryPoints []string) m return entryPointHandlers } -func (m *Manager) buildEntryPointHandlers(ctx context.Context, configs map[string]*runtime.UDPRouterInfo) ([]udp.Handler, error) { +func (m *Manager) buildEntryPointHandlers(ctx context.Context, configs map[string]*runtime.UDPRouterInfo) []udp.Handler { var rtNames []string for routerName := range configs { rtNames = append(rtNames, routerName) @@ -101,5 +97,5 @@ func (m *Manager) buildEntryPointHandlers(ctx context.Context, configs map[strin handlers = append(handlers, handler) } - return handlers, nil + return handlers } diff --git a/pkg/server/service/service.go b/pkg/server/service/service.go index 375e9f64e..e6701392e 100644 --- a/pkg/server/service/service.go +++ b/pkg/server/service/service.go @@ -425,7 +425,7 @@ func (m *Manager) upsertServers(ctx context.Context, lb healthcheck.BalancerHand return fmt.Errorf("error adding server %s to load balancer: %w", srv.URL, err) } - // FIXME Handle Metrics + // TODO Handle Metrics } return nil } diff --git a/pkg/tls/certificate_store_test.go b/pkg/tls/certificate_store_test.go index 307d520a6..a80516142 100644 --- a/pkg/tls/certificate_store_test.go +++ b/pkg/tls/certificate_store_test.go @@ -14,7 +14,7 @@ import ( ) func TestGetBestCertificate(t *testing.T) { - // FIXME Add tests for defaultCert + // TODO Add tests for defaultCert testCases := []struct { desc string domainToCheck string