chore: update linter
This commit is contained in:
parent
25027d6df8
commit
adf82d72ae
23 changed files with 74 additions and 67 deletions
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
func init() {
|
||||
// FIXME Goroutines2 -> Goroutines
|
||||
// TODO Goroutines2 -> Goroutines
|
||||
expvar.Publish("Goroutines2", expvar.Func(goroutines))
|
||||
}
|
||||
|
||||
|
|
|
@ -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"`
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue