fix: update linter.

This commit is contained in:
Ludovic Fernandez 2019-09-26 11:00:06 +02:00 committed by Traefiker Bot
parent 027d313df5
commit 29efac3e5e
52 changed files with 17 additions and 89 deletions

View file

@ -40,7 +40,9 @@
"scopelint", "scopelint",
"gochecknoinits", "gochecknoinits",
"gochecknoglobals", "gochecknoglobals",
# "godox", # manage TODO FIXME ## wait for https://github.com/golangci/golangci-lint/issues/337
"bodyclose", # Too many false-positive and panics. "bodyclose", # Too many false-positive and panics.
# "stylecheck", # skip because report issues related to some generated files. ## wait for https://github.com/golangci/golangci-lint/issues/337
] ]
[issues] [issues]

View file

@ -119,7 +119,6 @@ func runCmd(staticConfiguration *static.Configuration) error {
return fmt.Errorf("error while building entryPoint %s: %v", entryPointName, err) return fmt.Errorf("error while building entryPoint %s: %v", entryPointName, err)
} }
serverEntryPointsTCP[entryPointName].RouteAppenderFactory = router.NewRouteAppenderFactory(*staticConfiguration, entryPointName, acmeProviders) serverEntryPointsTCP[entryPointName].RouteAppenderFactory = router.NewRouteAppenderFactory(*staticConfiguration, entryPointName, acmeProviders)
} }
svr := server.NewServer(*staticConfiguration, providerAggregator, serverEntryPointsTCP, tlsManager) svr := server.NewServer(*staticConfiguration, providerAggregator, serverEntryPointsTCP, tlsManager)

View file

@ -47,7 +47,6 @@ func (s *ErrorPagesSuite) TestSimpleConfiguration(c *check.C) {
} }
func (s *ErrorPagesSuite) TestErrorPage(c *check.C) { func (s *ErrorPagesSuite) TestErrorPage(c *check.C) {
// error.toml contains a mis-configuration of the backend host // error.toml contains a mis-configuration of the backend host
file := s.adaptFile(c, "fixtures/error_pages/error.toml", struct { file := s.adaptFile(c, "fixtures/error_pages/error.toml", struct {
Server1 string Server1 string

View file

@ -90,7 +90,6 @@ func getHelloClientGRPC() (helloworld.GreeterClient, func() error, error) {
return nil, func() error { return nil }, err return nil, func() error { return nil }, err
} }
return helloworld.NewGreeterClient(conn), conn.Close, nil return helloworld.NewGreeterClient(conn), conn.Close, nil
} }
func getHelloClientGRPCh2c() (helloworld.GreeterClient, func() error, error) { func getHelloClientGRPCh2c() (helloworld.GreeterClient, func() error, error) {
@ -99,7 +98,6 @@ func getHelloClientGRPCh2c() (helloworld.GreeterClient, func() error, error) {
return nil, func() error { return nil }, err return nil, func() error { return nil }, err
} }
return helloworld.NewGreeterClient(conn), conn.Close, nil return helloworld.NewGreeterClient(conn), conn.Close, nil
} }
func callHelloClientGRPC(name string, secure bool) (string, error) { func callHelloClientGRPC(name string, secure bool) (string, error) {

View file

@ -27,7 +27,6 @@ func (s *HealthCheckSuite) SetUpSuite(c *check.C) {
} }
func (s *HealthCheckSuite) TestSimpleConfiguration(c *check.C) { func (s *HealthCheckSuite) TestSimpleConfiguration(c *check.C) {
file := s.adaptFile(c, "fixtures/healthcheck/simple.toml", struct { file := s.adaptFile(c, "fixtures/healthcheck/simple.toml", struct {
Server1 string Server1 string
Server2 string Server2 string
@ -166,7 +165,6 @@ func (s *HealthCheckSuite) TestMultipleEntrypoints(c *check.C) {
} }
func (s *HealthCheckSuite) TestPortOverload(c *check.C) { func (s *HealthCheckSuite) TestPortOverload(c *check.C) {
// Set one whoami health to 200 // Set one whoami health to 200
client := &http.Client{} client := &http.Client{}
statusInternalServerErrorReq, err := http.NewRequest(http.MethodPost, "http://"+s.whoami1IP+"/health", bytes.NewBuffer([]byte("200"))) statusInternalServerErrorReq, err := http.NewRequest(http.MethodPost, "http://"+s.whoami1IP+"/health", bytes.NewBuffer([]byte("200")))
@ -206,5 +204,4 @@ func (s *HealthCheckSuite) TestPortOverload(c *check.C) {
// Verify no backend service is available due to failing health checks // Verify no backend service is available due to failing health checks
err = try.Request(frontendHealthReq, 3*time.Second, try.StatusCodeIs(http.StatusServiceUnavailable)) err = try.Request(frontendHealthReq, 3*time.Second, try.StatusCodeIs(http.StatusServiceUnavailable))
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
} }

View file

@ -193,7 +193,6 @@ func (s *SimpleSuite) TestStatsWithMultipleEntryPoint(c *check.C) {
err = try.GetRequest("http://127.0.0.1:8080/health", 1*time.Second, try.BodyContains(`"total_status_code_count":{"200":2}`)) err = try.GetRequest("http://127.0.0.1:8080/health", 1*time.Second, try.BodyContains(`"total_status_code_count":{"200":2}`))
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
} }
func (s *SimpleSuite) TestNoAuthOnPing(c *check.C) { func (s *SimpleSuite) TestNoAuthOnPing(c *check.C) {
@ -301,7 +300,6 @@ func (s *SimpleSuite) TestMultipleProviderSameBackendName(c *check.C) {
err = try.GetRequest("http://127.0.0.1:8000/file", 1*time.Second, try.BodyContains(ipWhoami02)) err = try.GetRequest("http://127.0.0.1:8000/file", 1*time.Second, try.BodyContains(ipWhoami02))
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
} }
func (s *SimpleSuite) TestIPStrategyWhitelist(c *check.C) { func (s *SimpleSuite) TestIPStrategyWhitelist(c *check.C) {
@ -449,7 +447,6 @@ func (s *SimpleSuite) TestMultiProvider(c *check.C) {
err = try.GetRequest("http://127.0.0.1:8000/", 1*time.Second, try.StatusCodeIs(http.StatusOK), try.BodyContains("CustomValue")) err = try.GetRequest("http://127.0.0.1:8000/", 1*time.Second, try.StatusCodeIs(http.StatusOK), try.BodyContains("CustomValue"))
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
} }
func (s *SimpleSuite) TestSimpleConfigurationHostRequestTrailingPeriod(c *check.C) { func (s *SimpleSuite) TestSimpleConfigurationHostRequestTrailingPeriod(c *check.C) {
@ -625,8 +622,8 @@ func (s *SimpleSuite) TestWRRSticky(c *check.C) {
repartition := map[string]int{} repartition := map[string]int{}
req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8000/whoami", nil) req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8000/whoami", nil)
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
for i := 0; i < 4; i++ {
for i := 0; i < 4; i++ {
response, err := http.DefaultClient.Do(req) response, err := http.DefaultClient.Do(req)
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
c.Assert(response.StatusCode, checker.Equals, http.StatusOK) c.Assert(response.StatusCode, checker.Equals, http.StatusOK)

View file

@ -230,7 +230,6 @@ func guessWhoTLSMaxVersion(addr, serverName string, tlsCall bool, tlsMaxVersion
var err error var err error
if tlsCall { if tlsCall {
conn, err = tls.Dial("tcp", addr, &tls.Config{ conn, err = tls.Dial("tcp", addr, &tls.Config{
ServerName: serverName, ServerName: serverName,
InsecureSkipVerify: true, InsecureSkipVerify: true,

View file

@ -88,7 +88,6 @@ func (s *TracingSuite) TestZipkinRateLimit(c *check.C) {
err = try.GetRequest("http://"+s.IP+":9411/api/v2/spans?serviceName=tracing", 20*time.Second, try.BodyContains("forward service1/router1@file", "ratelimit-1@file")) err = try.GetRequest("http://"+s.IP+":9411/api/v2/spans?serviceName=tracing", 20*time.Second, try.BodyContains("forward service1/router1@file", "ratelimit-1@file"))
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
} }
func (s *TracingSuite) TestZipkinRetry(c *check.C) { func (s *TracingSuite) TestZipkinRetry(c *check.C) {

View file

@ -177,7 +177,6 @@ func (s *WebsocketSuite) TestOrigin(c *check.C) {
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
c.Assert(n, checker.Equals, 2) c.Assert(n, checker.Equals, 2)
c.Assert(string(msg), checker.Equals, "OK") c.Assert(string(msg), checker.Equals, "OK")
} }
func (s *WebsocketSuite) TestWrongOriginIgnoredByServer(c *check.C) { func (s *WebsocketSuite) TestWrongOriginIgnoredByServer(c *check.C) {
@ -238,7 +237,6 @@ func (s *WebsocketSuite) TestWrongOriginIgnoredByServer(c *check.C) {
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
c.Assert(n, checker.Equals, 2) c.Assert(n, checker.Equals, 2)
c.Assert(string(msg), checker.Equals, "OK") c.Assert(string(msg), checker.Equals, "OK")
} }
func (s *WebsocketSuite) TestSSLTermination(c *check.C) { func (s *WebsocketSuite) TestSSLTermination(c *check.C) {
@ -389,7 +387,6 @@ func (s *WebsocketSuite) TestSpecificResponseFromBackend(c *check.C) {
_, resp, err := gorillawebsocket.DefaultDialer.Dial("ws://127.0.0.1:8000/ws", nil) _, resp, err := gorillawebsocket.DefaultDialer.Dial("ws://127.0.0.1:8000/ws", nil)
c.Assert(err, checker.NotNil) c.Assert(err, checker.NotNil)
c.Assert(resp.StatusCode, check.Equals, http.StatusUnauthorized) c.Assert(resp.StatusCode, check.Equals, http.StatusUnauthorized)
} }
func (s *WebsocketSuite) TestURLWithURLEncodedChar(c *check.C) { func (s *WebsocketSuite) TestURLWithURLEncodedChar(c *check.C) {

View file

@ -82,7 +82,6 @@ func Test_execute(t *testing.T) {
return nil return nil
}, },
} }
}, },
expected: expected{result: "root"}, expected: expected{result: "root"},
}, },
@ -99,7 +98,6 @@ func Test_execute(t *testing.T) {
return nil return nil
}, },
} }
}, },
expected: expected{error: true}, expected: expected{error: true},
}, },

View file

@ -85,7 +85,6 @@ func TestFinder_Find(t *testing.T) {
for _, test := range testCases { for _, test := range testCases {
t.Run(test.desc, func(t *testing.T) { t.Run(test.desc, func(t *testing.T) {
finder := Finder{ finder := Finder{
BasePaths: test.basePaths, BasePaths: test.basePaths,
Extensions: []string{"toml", "yaml", "yml"}, Extensions: []string{"toml", "yaml", "yml"},

View file

@ -460,7 +460,6 @@ func (c *ClientTLS) CreateTLSConfig() (*tls.Config, error) {
cert, err = tls.X509KeyPair([]byte(c.Cert), []byte(c.Key)) cert, err = tls.X509KeyPair([]byte(c.Cert), []byte(c.Key))
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to load TLS keypair: %v", err) return nil, fmt.Errorf("failed to load TLS keypair: %v", err)
} }
} else { } else {
return nil, fmt.Errorf("TLS key is a file, but tls cert is not") return nil, fmt.Errorf("TLS key is a file, but tls cert is not")

View file

@ -130,7 +130,6 @@ func findTypedField(rType reflect.Type, node *Node) (reflect.StructField, error)
return cField, nil return cField, nil
} }
} }
} }
return reflect.StructField{}, fmt.Errorf("field not found, node: %s", node.Name) return reflect.StructField{}, fmt.Errorf("field not found, node: %s", node.Name)

View file

@ -687,5 +687,4 @@ func TestPopulateUsedBy(t *testing.T) {
} }
}) })
} }
} }

View file

@ -32,8 +32,8 @@ type EntryPoints map[string]*EntryPoint
// EntryPointsTransport configures communication between clients and Traefik. // EntryPointsTransport configures communication between clients and Traefik.
type EntryPointsTransport struct { type EntryPointsTransport struct {
LifeCycle *LifeCycle `description:"Timeouts influencing the server life cycle." json:"lifeCycle,omitempty" toml:"lifeCycle,omitempty" yaml:"lifeCycle,omitempty" export:"true" export:"true"` LifeCycle *LifeCycle `description:"Timeouts influencing the server life cycle." json:"lifeCycle,omitempty" toml:"lifeCycle,omitempty" yaml:"lifeCycle,omitempty" export:"true"`
RespondingTimeouts *RespondingTimeouts `description:"Timeouts for incoming requests to the Traefik instance." json:"respondingTimeouts,omitempty" toml:"respondingTimeouts,omitempty" yaml:"respondingTimeouts,omitempty" export:"true" export:"true"` RespondingTimeouts *RespondingTimeouts `description:"Timeouts for incoming requests to the Traefik instance." json:"respondingTimeouts,omitempty" toml:"respondingTimeouts,omitempty" yaml:"respondingTimeouts,omitempty" export:"true"`
} }
// SetDefaults sets the default values. // SetDefaults sets the default values.

View file

@ -40,7 +40,6 @@ func TestLog(t *testing.T) {
for _, test := range testCases { for _, test := range testCases {
test := test test := test
t.Run(test.desc, func(t *testing.T) { t.Run(test.desc, func(t *testing.T) {
var buffer bytes.Buffer var buffer bytes.Buffer
SetOutput(&buffer) SetOutput(&buffer)

View file

@ -60,7 +60,6 @@ func TestInfluxDB(t *testing.T) {
influxDBRegistry.EntryPointReqsCounter().With("entrypoint", "test").Add(1) influxDBRegistry.EntryPointReqsCounter().With("entrypoint", "test").Add(1)
influxDBRegistry.EntryPointReqDurationHistogram().With("entrypoint", "test").Observe(10000) influxDBRegistry.EntryPointReqDurationHistogram().With("entrypoint", "test").Observe(10000)
influxDBRegistry.EntryPointOpenConnsGauge().With("entrypoint", "test").Set(1) influxDBRegistry.EntryPointOpenConnsGauge().With("entrypoint", "test").Set(1)
}) })
assertMessage(t, msgEntrypoint, expectedEntrypoint) assertMessage(t, msgEntrypoint, expectedEntrypoint)

View file

@ -269,7 +269,6 @@ func TestPrometheus(t *testing.T) {
} }
test.assert(family) test.assert(family)
}) })
} }
} }

View file

@ -45,7 +45,6 @@ func AddServiceFields(rw http.ResponseWriter, req *http.Request, next http.Handl
data.Core[ServiceAddr] = req.URL.Host data.Core[ServiceAddr] = req.URL.Host
next.ServeHTTP(rw, req) next.ServeHTTP(rw, req)
} }
// AddOriginFields add origin fields // AddOriginFields add origin fields

View file

@ -69,8 +69,8 @@ func toLog(fields logrus.Fields, key string, defaultValue string, quoted bool) i
return v return v
} }
} }
return defaultValue
return defaultValue
} }
func toLogEntry(s string, defaultValue string, quote bool) string { func toLogEntry(s string, defaultValue string, quote bool) string {

View file

@ -99,11 +99,9 @@ func TestCommonLogFormatter_Format(t *testing.T) {
assert.Equal(t, test.expectedLog, string(raw)) assert.Equal(t, test.expectedLog, string(raw))
}) })
} }
} }
func Test_toLog(t *testing.T) { func Test_toLog(t *testing.T) {
testCases := []struct { testCases := []struct {
desc string desc string
fields logrus.Fields fields logrus.Fields

View file

@ -527,7 +527,6 @@ func TestNewLogHandlerOutputStdout(t *testing.T) {
for _, test := range testCases { for _, test := range testCases {
test := test test := test
t.Run(test.desc, func(t *testing.T) { t.Run(test.desc, func(t *testing.T) {
// NOTE: It is not possible to run these cases in parallel because we capture Stdout // NOTE: It is not possible to run these cases in parallel because we capture Stdout
file, restoreStdout := captureStdout(t) file, restoreStdout := captureStdout(t)
@ -543,7 +542,6 @@ func TestNewLogHandlerOutputStdout(t *testing.T) {
} }
func assertValidLogData(t *testing.T, expected string, logData []byte) { func assertValidLogData(t *testing.T, expected string, logData []byte) {
if len(expected) == 0 { if len(expected) == 0 {
assert.Zero(t, len(logData)) assert.Zero(t, len(logData))
t.Log(string(logData)) t.Log(string(logData))

View file

@ -367,7 +367,6 @@ func Test_writeHeader(t *testing.T) {
for _, test := range testCases { for _, test := range testCases {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
req := testhelpers.MustNewRequest(http.MethodGet, "http://foo.bar/path?q=1", nil) req := testhelpers.MustNewRequest(http.MethodGet, "http://foo.bar/path?q=1", nil)
for key, value := range test.headers { for key, value := range test.headers {
req.Header.Set(key, value) req.Header.Set(key, value)

View file

@ -327,7 +327,6 @@ func TestGetTracingInformation(t *testing.T) {
assert.Equal(t, "testing", name) assert.Equal(t, "testing", name)
assert.Equal(t, tracing.SpanKindNoneEnum, trace) assert.Equal(t, tracing.SpanKindNoneEnum, trace)
} }
func TestCORSResponses(t *testing.T) { func TestCORSResponses(t *testing.T) {

View file

@ -360,7 +360,6 @@ WqeUSNGYV//RunTeuRDAf5OxehERb1srzBXhRZ3cZdzXbgR/`),
require.Equal(t, test.expected, sanitize(test.toSanitize), "The sanitized certificates should be equal") require.Equal(t, test.expected, sanitize(test.toSanitize), "The sanitized certificates should be equal")
}) })
} }
} }
func TestTLSClientHeadersWithPEM(t *testing.T) { func TestTLSClientHeadersWithPEM(t *testing.T) {
@ -429,7 +428,6 @@ func TestTLSClientHeadersWithPEM(t *testing.T) {
require.Empty(t, res.Header().Get(xForwardedTLSClientCert), "The response header should be always empty") require.Empty(t, res.Header().Get(xForwardedTLSClientCert), "The response header should be always empty")
}) })
} }
} }
func TestGetSans(t *testing.T) { func TestGetSans(t *testing.T) {
@ -478,7 +476,6 @@ func TestGetSans(t *testing.T) {
} }
}) })
} }
} }
func TestTLSClientHeadersWithCertInfo(t *testing.T) { func TestTLSClientHeadersWithCertInfo(t *testing.T) {
@ -659,5 +656,4 @@ func TestTLSClientHeadersWithCertInfo(t *testing.T) {
require.Empty(t, res.Header().Get(xForwardedTLSClientCertInfo), "The response header should be always empty") require.Empty(t, res.Header().Get(xForwardedTLSClientCertInfo), "The response header should be always empty")
}) })
} }
} }

View file

@ -35,7 +35,6 @@ func (p *pipelining) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
} else { } else {
p.next.ServeHTTP(&writerWithoutCloseNotify{rw}, r) p.next.ServeHTTP(&writerWithoutCloseNotify{rw}, r)
} }
} }
// writerWithoutCloseNotify helps to disable closeNotify // writerWithoutCloseNotify helps to disable closeNotify

View file

@ -142,7 +142,6 @@ func TestRateLimit(t *testing.T) {
for _, test := range testCases { for _, test := range testCases {
test := test test := test
t.Run(test.desc, func(t *testing.T) { t.Run(test.desc, func(t *testing.T) {
t.Parallel() t.Parallel()
reqCount := 0 reqCount := 0

View file

@ -179,16 +179,13 @@ func TestRedirectRegexHandler(t *testing.T) {
handler.ServeHTTP(recorder, r) handler.ServeHTTP(recorder, r)
assert.Equal(t, test.expectedStatus, recorder.Code) assert.Equal(t, test.expectedStatus, recorder.Code)
if test.expectedStatus == http.StatusMovedPermanently || switch test.expectedStatus {
test.expectedStatus == http.StatusFound || case http.StatusMovedPermanently, http.StatusFound, http.StatusTemporaryRedirect, http.StatusPermanentRedirect:
test.expectedStatus == http.StatusTemporaryRedirect ||
test.expectedStatus == http.StatusPermanentRedirect {
location, err := recorder.Result().Location() location, err := recorder.Result().Location()
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, test.expectedURL, location.String()) assert.Equal(t, test.expectedURL, location.String())
} else { default:
location, err := recorder.Result().Location() location, err := recorder.Result().Location()
require.Errorf(t, err, "Location %v", location) require.Errorf(t, err, "Location %v", location)
} }

View file

@ -206,16 +206,14 @@ func TestRedirectSchemeHandler(t *testing.T) {
handler.ServeHTTP(recorder, r) handler.ServeHTTP(recorder, r)
assert.Equal(t, test.expectedStatus, recorder.Code) assert.Equal(t, test.expectedStatus, recorder.Code)
if test.expectedStatus == http.StatusMovedPermanently ||
test.expectedStatus == http.StatusFound ||
test.expectedStatus == http.StatusTemporaryRedirect ||
test.expectedStatus == http.StatusPermanentRedirect {
switch test.expectedStatus {
case http.StatusMovedPermanently, http.StatusFound, http.StatusTemporaryRedirect, http.StatusPermanentRedirect:
location, err := recorder.Result().Location() location, err := recorder.Result().Location()
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, test.expectedURL, location.String()) assert.Equal(t, test.expectedURL, location.String())
} else { default:
location, err := recorder.Result().Location() location, err := recorder.Result().Location()
require.Errorf(t, err, "Location %v", location) require.Errorf(t, err, "Location %v", location)
} }
@ -234,7 +232,6 @@ func TestRedirectSchemeHandler(t *testing.T) {
test.expectedStatus == http.StatusFound || test.expectedStatus == http.StatusFound ||
test.expectedStatus == http.StatusTemporaryRedirect || test.expectedStatus == http.StatusTemporaryRedirect ||
test.expectedStatus == http.StatusPermanentRedirect { test.expectedStatus == http.StatusPermanentRedirect {
location, err := recorder.Result().Location() location, err := recorder.Result().Location()
require.NoError(t, err) require.NoError(t, err)

View file

@ -23,7 +23,6 @@ func TestReplacePath(t *testing.T) {
for _, path := range paths { for _, path := range paths {
t.Run(path, func(t *testing.T) { t.Run(path, func(t *testing.T) {
var expectedPath, actualHeader, requestURI string var expectedPath, actualHeader, requestURI string
next := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { next := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
expectedPath = r.URL.Path expectedPath = r.URL.Path

View file

@ -74,7 +74,6 @@ func TestReplacePathRegex(t *testing.T) {
for _, test := range testCases { for _, test := range testCases {
t.Run(test.desc, func(t *testing.T) { t.Run(test.desc, func(t *testing.T) {
var actualPath, actualHeader, requestURI string var actualPath, actualHeader, requestURI string
next := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { next := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
actualPath = r.URL.Path actualPath = r.URL.Path

View file

@ -65,7 +65,6 @@ func TestEntryPointMiddleware(t *testing.T) {
for _, test := range testCases { for _, test := range testCases {
t.Run(test.desc, func(t *testing.T) { t.Run(test.desc, func(t *testing.T) {
newTracing, err := tracing.NewTracing("", test.spanNameLimit, test.tracing) newTracing, err := tracing.NewTracing("", test.spanNameLimit, test.tracing)
require.NoError(t, err) require.NoError(t, err)

View file

@ -109,7 +109,6 @@ func TestNewForwarder(t *testing.T) {
for _, test := range testCases { for _, test := range testCases {
t.Run(test.desc, func(t *testing.T) { t.Run(test.desc, func(t *testing.T) {
newTracing, err := tracing.NewTracing("", test.spanNameLimit, test.tracing) newTracing, err := tracing.NewTracing("", test.spanNameLimit, test.tracing)
require.NoError(t, err) require.NoError(t, err)

View file

@ -171,7 +171,6 @@ func NewLocalChallengeStore() *LocalChallengeStore {
TLSChallenges: make(map[string]*Certificate), TLSChallenges: make(map[string]*Certificate),
}, },
} }
} }
// GetHTTPChallengeToken Get the http challenge token from the store // GetHTTPChallengeToken Get the http challenge token from the store

View file

@ -414,7 +414,6 @@ func (p *Provider) watchNewDomains(ctx context.Context) {
} }
p.resolveDomains(ctxRouter, domains, tlsStore) p.resolveDomains(ctxRouter, domains, tlsStore)
} }
} }
case <-stop: case <-stop:
return return

View file

@ -193,10 +193,11 @@ func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.
if p.Watch { if p.Watch {
if p.SwarmMode { if p.SwarmMode {
errChan := make(chan error) errChan := make(chan error)
// TODO: This need to be change. Linked to Swarm events docker/docker#23827 // TODO: This need to be change. Linked to Swarm events docker/docker#23827
ticker := time.NewTicker(time.Duration(p.SwarmModeRefreshSeconds)) ticker := time.NewTicker(time.Duration(p.SwarmModeRefreshSeconds))
pool.GoCtx(func(ctx context.Context) {
pool.GoCtx(func(ctx context.Context) {
ctx = log.With(ctx, log.Str(log.ProviderName, "docker")) ctx = log.With(ctx, log.Str(log.ProviderName, "docker"))
logger := log.FromContext(ctx) logger := log.FromContext(ctx)
@ -229,7 +230,6 @@ func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.
return err return err
} }
// channel closed // channel closed
} else { } else {
f := filters.NewArgs() f := filters.NewArgs()
f.Add("type", "container") f.Add("type", "container")
@ -256,7 +256,6 @@ func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.
case configurationChan <- message: case configurationChan <- message:
case <-ctx.Done(): case <-ctx.Done():
} }
} }
} }

View file

@ -250,7 +250,6 @@ func createProvider(t *testing.T, test ProvideTestCase, watch bool) (*Provider,
} }
if len(test.filePath) > 0 { if len(test.filePath) > 0 {
var file *os.File var file *os.File
if watch { if watch {
var err error var err error

View file

@ -225,7 +225,6 @@ func (p *Provider) loadConfigurationFromCRD(ctx context.Context, client Client)
PassTLSClientCert: middleware.Spec.PassTLSClientCert, PassTLSClientCert: middleware.Spec.PassTLSClientCert,
Retry: middleware.Spec.Retry, Retry: middleware.Spec.Retry,
} }
} }
return conf return conf

View file

@ -121,9 +121,7 @@ func (p *Provider) loadIngressRouteTCPConfiguration(ctx context.Context, client
} }
conf.Routers[serviceName].TLS.Options = tlsOptionsName conf.Routers[serviceName].TLS.Options = tlsOptionsName
} }
} }
} }

View file

@ -221,7 +221,6 @@ func loadService(client Client, namespace string, backend v1beta1.IngressBackend
var port int32 var port int32
for _, subset := range endpoints.Subsets { for _, subset := range endpoints.Subsets {
for _, p := range subset.Ports { for _, p := range subset.Ports {
if portName == p.Name { if portName == p.Name {
port = p.Port port = p.Port
@ -352,7 +351,6 @@ func (p *Provider) loadConfigurationFromIngresses(ctx context.Context, client Cl
Service: serviceName, Service: serviceName,
TLS: &dynamic.RouterTLSConfig{}, TLS: &dynamic.RouterTLSConfig{},
} }
} }
conf.HTTP.Services[serviceName] = service conf.HTTP.Services[serviceName] = service
} }

View file

@ -111,7 +111,6 @@ func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.
logger := log.FromContext(ctx) logger := log.FromContext(ctx)
operation := func() error { operation := func() error {
confg := marathon.NewDefaultConfig() confg := marathon.NewDefaultConfig()
confg.URL = p.Endpoint confg.URL = p.Endpoint
confg.EventsTransport = marathon.EventsTransportSSE confg.EventsTransport = marathon.EventsTransportSSE

View file

@ -92,7 +92,6 @@ func (p *Provider) buildTCPServiceConfiguration(ctx context.Context, service ran
} }
func (p *Provider) buildServiceConfiguration(ctx context.Context, service rancherData, configuration *dynamic.HTTPConfiguration) error { func (p *Provider) buildServiceConfiguration(ctx context.Context, service rancherData, configuration *dynamic.HTTPConfiguration) error {
serviceName := service.Name serviceName := service.Name
if len(configuration.Services) == 0 { if len(configuration.Services) == 0 {
@ -181,7 +180,6 @@ func (p *Provider) addServerTCP(ctx context.Context, service rancherData, loadBa
loadBalancer.Servers = servers loadBalancer.Servers = servers
return nil return nil
} }
func (p *Provider) addServers(ctx context.Context, service rancherData, loadBalancer *dynamic.ServersLoadBalancer) error { func (p *Provider) addServers(ctx context.Context, service rancherData, loadBalancer *dynamic.ServersLoadBalancer) error {

View file

@ -46,7 +46,6 @@ func (p *Provider) Append(systemRouter *mux.Router) {
Methods(http.MethodPut). Methods(http.MethodPut).
Path("/api/providers/{provider}"). Path("/api/providers/{provider}").
HandlerFunc(func(response http.ResponseWriter, request *http.Request) { HandlerFunc(func(response http.ResponseWriter, request *http.Request) {
vars := mux.Vars(request) vars := mux.Vars(request)
if vars["provider"] != "rest" { if vars["provider"] != "rest" {
response.WriteHeader(http.StatusBadRequest) response.WriteHeader(http.StatusBadRequest)

View file

@ -399,7 +399,6 @@ func TestAccessLog(t *testing.T) {
for _, test := range testCases { for _, test := range testCases {
t.Run(test.desc, func(t *testing.T) { t.Run(test.desc, func(t *testing.T) {
rtConf := runtime.NewConfig(dynamic.Configuration{ rtConf := runtime.NewConfig(dynamic.Configuration{
HTTP: &dynamic.HTTPConfiguration{ HTTP: &dynamic.HTTPConfiguration{
Services: test.serviceConfig, Services: test.serviceConfig,
@ -407,6 +406,7 @@ func TestAccessLog(t *testing.T) {
Middlewares: test.middlewaresConfig, Middlewares: test.middlewaresConfig,
}, },
}) })
serviceManager := service.NewManager(rtConf.Services, http.DefaultTransport, nil, nil, nil, nil) serviceManager := service.NewManager(rtConf.Services, http.DefaultTransport, nil, nil, nil, nil)
middlewaresBuilder := middleware.NewBuilder(rtConf.Middlewares, serviceManager) middlewaresBuilder := middleware.NewBuilder(rtConf.Middlewares, serviceManager)
responseModifierFactory := responsemodifiers.NewBuilder(rtConf.Middlewares) responseModifierFactory := responsemodifiers.NewBuilder(rtConf.Middlewares)
@ -722,7 +722,6 @@ func TestRuntimeConfiguration(t *testing.T) {
assert.Equal(t, test.expectedError, allErrors) assert.Equal(t, test.expectedError, allErrors)
}) })
} }
} }
func TestProviderOnMiddlewares(t *testing.T) { func TestProviderOnMiddlewares(t *testing.T) {
@ -833,7 +832,6 @@ func BenchmarkRouterServe(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
reqHost.ServeHTTP(w, req, handlers["web"].ServeHTTP) reqHost.ServeHTTP(w, req, handlers["web"].ServeHTTP)
} }
} }
func BenchmarkService(b *testing.B) { func BenchmarkService(b *testing.B) {
@ -868,5 +866,4 @@ func BenchmarkService(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
handler.ServeHTTP(w, req) handler.ServeHTTP(w, req)
} }
} }

View file

@ -77,8 +77,8 @@ func TestShutdownHTTPHijacked(t *testing.T) {
resp := http.Response{StatusCode: http.StatusOK} resp := http.Response{StatusCode: http.StatusOK}
err = resp.Write(conn) err = resp.Write(conn)
require.NoError(t, err) require.NoError(t, err)
})) }))
entryPoint.switchRouter(router) entryPoint.switchRouter(router)
conn, err := net.Dial("tcp", entryPoint.listener.Addr().String()) conn, err := net.Dial("tcp", entryPoint.listener.Addr().String())

View file

@ -19,7 +19,6 @@ type responseRecorder struct {
func (r *responseRecorder) WriteHeader(statusCode int) { func (r *responseRecorder) WriteHeader(statusCode int) {
r.save[r.Header().Get("server")]++ r.save[r.Header().Get("server")]++
r.ResponseRecorder.WriteHeader(statusCode) r.ResponseRecorder.WriteHeader(statusCode)
} }
func TestBalancer(t *testing.T) { func TestBalancer(t *testing.T) {

View file

@ -139,7 +139,6 @@ func TestWebSocketEcho(t *testing.T) {
err = conn.Close() err = conn.Close()
require.NoError(t, err) require.NoError(t, err)
})) }))
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
@ -169,7 +168,6 @@ func TestWebSocketEcho(t *testing.T) {
err = conn.Close() err = conn.Close()
require.NoError(t, err) require.NoError(t, err)
} }
func TestWebSocketPassHost(t *testing.T) { func TestWebSocketPassHost(t *testing.T) {
@ -215,7 +213,6 @@ func TestWebSocketPassHost(t *testing.T) {
err = conn.Close() err = conn.Close()
require.NoError(t, err) require.NoError(t, err)
})) }))
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
@ -246,7 +243,6 @@ func TestWebSocketPassHost(t *testing.T) {
err = conn.Close() err = conn.Close()
require.NoError(t, err) require.NoError(t, err)
}) })
} }
} }

View file

@ -258,7 +258,6 @@ func TestGetLoadBalancerServiceHandler(t *testing.T) {
for _, test := range testCases { for _, test := range testCases {
test := test test := test
t.Run(test.desc, func(t *testing.T) { t.Run(test.desc, func(t *testing.T) {
handler, err := sm.getLoadBalancerServiceHandler(context.Background(), test.serviceName, test.service, test.responseModifier) handler, err := sm.getLoadBalancerServiceHandler(context.Background(), test.serviceName, test.service, test.responseModifier)
assert.NoError(t, err) assert.NoError(t, err)

View file

@ -85,5 +85,4 @@ func (m *Manager) BuildTCP(rootCtx context.Context, serviceName string) (tcp.Han
conf.AddError(err, true) conf.AddError(err, true)
return nil, err return nil, err
} }
} }

View file

@ -140,7 +140,6 @@ func (c *Certificates) isEmpty() bool {
// AppendCertificate appends a Certificate to a certificates map keyed by entrypoint. // AppendCertificate appends a Certificate to a certificates map keyed by entrypoint.
func (c *Certificate) AppendCertificate(certs map[string]map[string]*tls.Certificate, ep string) error { func (c *Certificate) AppendCertificate(certs map[string]map[string]*tls.Certificate, ep string) error {
certContent, err := c.CertFile.Read() certContent, err := c.CertFile.Read()
if err != nil { if err != nil {
return fmt.Errorf("unable to read CertFile : %v", err) return fmt.Errorf("unable to read CertFile : %v", err)
@ -168,7 +167,6 @@ func (c *Certificate) AppendCertificate(certs map[string]map[string]*tls.Certifi
SANs = append(SANs, strings.ToLower(dnsName)) SANs = append(SANs, strings.ToLower(dnsName))
} }
} }
} }
if parsedCert.IPAddresses != nil { if parsedCert.IPAddresses != nil {
for _, ip := range parsedCert.IPAddresses { for _, ip := range parsedCert.IPAddresses {
@ -176,7 +174,6 @@ func (c *Certificate) AppendCertificate(certs map[string]map[string]*tls.Certifi
SANs = append(SANs, strings.ToLower(ip.String())) SANs = append(SANs, strings.ToLower(ip.String()))
} }
} }
} }
certKey := strings.Join(SANs, ",") certKey := strings.Join(SANs, ",")

View file

@ -56,7 +56,6 @@ func (c CertificateStore) getDefaultCertificateDomains() []string {
// GetAllDomains return a slice with all the certificate domain // GetAllDomains return a slice with all the certificate domain
func (c CertificateStore) GetAllDomains() []string { func (c CertificateStore) GetAllDomains() []string {
allCerts := c.getDefaultCertificateDomains() allCerts := c.getDefaultCertificateDomains()
// Get dynamic certificates // Get dynamic certificates

View file

@ -64,7 +64,7 @@ type FieldHeaders struct {
// AccessLogFields holds configuration for access log fields // AccessLogFields holds configuration for access log fields
type AccessLogFields struct { type AccessLogFields struct {
DefaultMode string `description:"Default mode for fields: keep | drop" json:"defaultMode,omitempty" toml:"defaultMode,omitempty" yaml:"defaultMode,omitempty" export:"true"` DefaultMode string `description:"Default mode for fields: keep | drop" json:"defaultMode,omitempty" toml:"defaultMode,omitempty" yaml:"defaultMode,omitempty" export:"true"`
Names map[string]string `json:"names,omitempty" description:"Override mode for fields" json:"names,omitempty" toml:"names,omitempty" yaml:"names,omitempty" export:"true"` Names map[string]string `description:"Override mode for fields" json:"names,omitempty" toml:"names,omitempty" yaml:"names,omitempty" export:"true"`
Headers *FieldHeaders `description:"Headers to keep, drop or redact" json:"headers,omitempty" toml:"headers,omitempty" yaml:"headers,omitempty" export:"true"` Headers *FieldHeaders `description:"Headers to keep, drop or redact" json:"headers,omitempty" toml:"headers,omitempty" yaml:"headers,omitempty" export:"true"`
} }