mirror of
https://github.com/traefik/traefik.git
synced 2025-05-07 08:23:03 +00:00
chore: update linter
This commit is contained in:
parent
db515195f0
commit
c5f23493ab
2
.github/workflows/validate.yaml
vendored
2
.github/workflows/validate.yaml
vendored
@ -7,7 +7,7 @@ on:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
GO_VERSION: '1.20'
|
GO_VERSION: '1.20'
|
||||||
GOLANGCI_LINT_VERSION: v1.52.2
|
GOLANGCI_LINT_VERSION: v1.53.1
|
||||||
MISSSPELL_VERSION: v0.4.0
|
MISSSPELL_VERSION: v0.4.0
|
||||||
IN_DOCKER: ""
|
IN_DOCKER: ""
|
||||||
|
|
||||||
|
@ -26,10 +26,13 @@ linters-settings:
|
|||||||
- ^spew\.Print(f|ln)?$
|
- ^spew\.Print(f|ln)?$
|
||||||
- ^spew\.Dump$
|
- ^spew\.Dump$
|
||||||
depguard:
|
depguard:
|
||||||
list-type: denylist
|
rules:
|
||||||
include-go-root: false
|
main:
|
||||||
packages:
|
deny:
|
||||||
- github.com/pkg/errors
|
- pkg: "github.com/instana/testify"
|
||||||
|
desc: not allowed
|
||||||
|
- pkg: "github.com/pkg/errors"
|
||||||
|
desc: Should be replaced by standard lib errors package
|
||||||
godox:
|
godox:
|
||||||
keywords:
|
keywords:
|
||||||
- FIXME
|
- FIXME
|
||||||
@ -199,6 +202,7 @@ linters:
|
|||||||
- containedctx # too many false-positive
|
- containedctx # too many false-positive
|
||||||
- maintidx # kind of duplicate of gocyclo
|
- maintidx # kind of duplicate of gocyclo
|
||||||
- nonamedreturns # Too strict
|
- nonamedreturns # Too strict
|
||||||
|
- gosmopolitan # not relevant
|
||||||
|
|
||||||
issues:
|
issues:
|
||||||
exclude-use-default: false
|
exclude-use-default: false
|
||||||
|
@ -61,7 +61,7 @@ func (s *HealthCheckSuite) TestSimpleConfiguration(c *check.C) {
|
|||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
whoamiHosts := []string{s.whoami1IP, s.whoami2IP}
|
whoamiHosts := []string{s.whoami1IP, s.whoami2IP}
|
||||||
for _, whoami := range whoamiHosts {
|
for _, whoami := range whoamiHosts {
|
||||||
statusInternalServerErrorReq, err := http.NewRequest(http.MethodPost, "http://"+whoami+"/health", bytes.NewBuffer([]byte("500")))
|
statusInternalServerErrorReq, err := http.NewRequest(http.MethodPost, "http://"+whoami+"/health", bytes.NewBufferString("500"))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
_, err = client.Do(statusInternalServerErrorReq)
|
_, err = client.Do(statusInternalServerErrorReq)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
@ -72,7 +72,7 @@ func (s *HealthCheckSuite) TestSimpleConfiguration(c *check.C) {
|
|||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
// Change one whoami health to 200
|
// Change one whoami health to 200
|
||||||
statusOKReq1, err := http.NewRequest(http.MethodPost, "http://"+s.whoami1IP+"/health", bytes.NewBuffer([]byte("200")))
|
statusOKReq1, err := http.NewRequest(http.MethodPost, "http://"+s.whoami1IP+"/health", bytes.NewBufferString("200"))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
_, err = client.Do(statusOKReq1)
|
_, err = client.Do(statusOKReq1)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
@ -138,7 +138,7 @@ func (s *HealthCheckSuite) TestMultipleEntrypoints(c *check.C) {
|
|||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
whoamiHosts := []string{s.whoami1IP, s.whoami2IP}
|
whoamiHosts := []string{s.whoami1IP, s.whoami2IP}
|
||||||
for _, whoami := range whoamiHosts {
|
for _, whoami := range whoamiHosts {
|
||||||
statusInternalServerErrorReq, err := http.NewRequest(http.MethodPost, "http://"+whoami+"/health", bytes.NewBuffer([]byte("500")))
|
statusInternalServerErrorReq, err := http.NewRequest(http.MethodPost, "http://"+whoami+"/health", bytes.NewBufferString("500"))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
_, err = client.Do(statusInternalServerErrorReq)
|
_, err = client.Do(statusInternalServerErrorReq)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
@ -149,7 +149,7 @@ func (s *HealthCheckSuite) TestMultipleEntrypoints(c *check.C) {
|
|||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
// reactivate the whoami2
|
// reactivate the whoami2
|
||||||
statusInternalServerOkReq, err := http.NewRequest(http.MethodPost, "http://"+s.whoami2IP+"/health", bytes.NewBuffer([]byte("200")))
|
statusInternalServerOkReq, err := http.NewRequest(http.MethodPost, "http://"+s.whoami2IP+"/health", bytes.NewBufferString("200"))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
_, err = client.Do(statusInternalServerOkReq)
|
_, err = client.Do(statusInternalServerOkReq)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
@ -174,7 +174,7 @@ 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.NewBufferString("200"))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
_, err = client.Do(statusInternalServerErrorReq)
|
_, err = client.Do(statusInternalServerErrorReq)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
@ -203,7 +203,7 @@ func (s *HealthCheckSuite) TestPortOverload(c *check.C) {
|
|||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
// Set one whoami health to 500
|
// Set one whoami health to 500
|
||||||
statusInternalServerErrorReq, err = http.NewRequest(http.MethodPost, "http://"+s.whoami1IP+"/health", bytes.NewBuffer([]byte("500")))
|
statusInternalServerErrorReq, err = http.NewRequest(http.MethodPost, "http://"+s.whoami1IP+"/health", bytes.NewBufferString("500"))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
_, err = client.Do(statusInternalServerErrorReq)
|
_, err = client.Do(statusInternalServerErrorReq)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
@ -232,7 +232,7 @@ func (s *HealthCheckSuite) TestMultipleRoutersOnSameService(c *check.C) {
|
|||||||
|
|
||||||
// Set whoami health to 200 to be sure to start with the wanted status
|
// Set whoami health to 200 to be sure to start with the wanted status
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
statusOkReq, err := http.NewRequest(http.MethodPost, "http://"+s.whoami1IP+"/health", bytes.NewBuffer([]byte("200")))
|
statusOkReq, err := http.NewRequest(http.MethodPost, "http://"+s.whoami1IP+"/health", bytes.NewBufferString("200"))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
_, err = client.Do(statusOkReq)
|
_, err = client.Do(statusOkReq)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
@ -253,7 +253,7 @@ func (s *HealthCheckSuite) TestMultipleRoutersOnSameService(c *check.C) {
|
|||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
// Set whoami health to 500
|
// Set whoami health to 500
|
||||||
statusInternalServerErrorReq, err := http.NewRequest(http.MethodPost, "http://"+s.whoami1IP+"/health", bytes.NewBuffer([]byte("500")))
|
statusInternalServerErrorReq, err := http.NewRequest(http.MethodPost, "http://"+s.whoami1IP+"/health", bytes.NewBufferString("500"))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
_, err = client.Do(statusInternalServerErrorReq)
|
_, err = client.Do(statusInternalServerErrorReq)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
@ -266,7 +266,7 @@ func (s *HealthCheckSuite) TestMultipleRoutersOnSameService(c *check.C) {
|
|||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
// Change one whoami health to 200
|
// Change one whoami health to 200
|
||||||
statusOKReq1, err := http.NewRequest(http.MethodPost, "http://"+s.whoami1IP+"/health", bytes.NewBuffer([]byte("200")))
|
statusOKReq1, err := http.NewRequest(http.MethodPost, "http://"+s.whoami1IP+"/health", bytes.NewBufferString("200"))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
_, err = client.Do(statusOKReq1)
|
_, err = client.Do(statusOKReq1)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
@ -312,7 +312,7 @@ func (s *HealthCheckSuite) TestPropagate(c *check.C) {
|
|||||||
|
|
||||||
whoamiHosts := []string{s.whoami1IP, s.whoami3IP}
|
whoamiHosts := []string{s.whoami1IP, s.whoami3IP}
|
||||||
for _, whoami := range whoamiHosts {
|
for _, whoami := range whoamiHosts {
|
||||||
statusInternalServerErrorReq, err := http.NewRequest(http.MethodPost, "http://"+whoami+"/health", bytes.NewBuffer([]byte("500")))
|
statusInternalServerErrorReq, err := http.NewRequest(http.MethodPost, "http://"+whoami+"/health", bytes.NewBufferString("500"))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
_, err = client.Do(statusInternalServerErrorReq)
|
_, err = client.Do(statusInternalServerErrorReq)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
@ -394,7 +394,7 @@ func (s *HealthCheckSuite) TestPropagate(c *check.C) {
|
|||||||
// Bring whoami2 and whoami4 down
|
// Bring whoami2 and whoami4 down
|
||||||
whoamiHosts = []string{s.whoami2IP, s.whoami4IP}
|
whoamiHosts = []string{s.whoami2IP, s.whoami4IP}
|
||||||
for _, whoami := range whoamiHosts {
|
for _, whoami := range whoamiHosts {
|
||||||
statusInternalServerErrorReq, err := http.NewRequest(http.MethodPost, "http://"+whoami+"/health", bytes.NewBuffer([]byte("500")))
|
statusInternalServerErrorReq, err := http.NewRequest(http.MethodPost, "http://"+whoami+"/health", bytes.NewBufferString("500"))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
_, err = client.Do(statusInternalServerErrorReq)
|
_, err = client.Do(statusInternalServerErrorReq)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
@ -420,7 +420,7 @@ func (s *HealthCheckSuite) TestPropagate(c *check.C) {
|
|||||||
// Bring everything back up.
|
// Bring everything back up.
|
||||||
whoamiHosts = []string{s.whoami1IP, s.whoami2IP, s.whoami3IP, s.whoami4IP}
|
whoamiHosts = []string{s.whoami1IP, s.whoami2IP, s.whoami3IP, s.whoami4IP}
|
||||||
for _, whoami := range whoamiHosts {
|
for _, whoami := range whoamiHosts {
|
||||||
statusOKReq, err := http.NewRequest(http.MethodPost, "http://"+whoami+"/health", bytes.NewBuffer([]byte("200")))
|
statusOKReq, err := http.NewRequest(http.MethodPost, "http://"+whoami+"/health", bytes.NewBufferString("200"))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
_, err = client.Do(statusOKReq)
|
_, err = client.Do(statusOKReq)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
@ -585,7 +585,7 @@ func (s *HealthCheckSuite) TestPropagateReload(c *check.C) {
|
|||||||
client := http.Client{
|
client := http.Client{
|
||||||
Timeout: 10 * time.Second,
|
Timeout: 10 * time.Second,
|
||||||
}
|
}
|
||||||
statusOKReq, err := http.NewRequest(http.MethodPost, "http://"+s.whoami2IP+"/health", bytes.NewBuffer([]byte("500")))
|
statusOKReq, err := http.NewRequest(http.MethodPost, "http://"+s.whoami2IP+"/health", bytes.NewBufferString("500"))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
_, err = client.Do(statusOKReq)
|
_, err = client.Do(statusOKReq)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -218,7 +218,7 @@ func TestBasicAuthUsersFromFile(t *testing.T) {
|
|||||||
usersFile, err := os.CreateTemp(t.TempDir(), "auth-users")
|
usersFile, err := os.CreateTemp(t.TempDir(), "auth-users")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
_, err = usersFile.Write([]byte(test.userFileContent))
|
_, err = usersFile.WriteString(test.userFileContent)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Creates the configuration for our Authenticator
|
// Creates the configuration for our Authenticator
|
||||||
|
@ -96,7 +96,7 @@ func TestDigestAuthUsersFromFile(t *testing.T) {
|
|||||||
usersFile, err := os.CreateTemp(t.TempDir(), "auth-users")
|
usersFile, err := os.CreateTemp(t.TempDir(), "auth-users")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
_, err = usersFile.Write([]byte(test.userFileContent))
|
_, err = usersFile.WriteString(test.userFileContent)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Creates the configuration for our Authenticator
|
// Creates the configuration for our Authenticator
|
||||||
|
@ -177,7 +177,7 @@ func generateBytes(length int) []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRequestReader(t *testing.T) {
|
func TestRequestReader(t *testing.T) {
|
||||||
buff := bytes.NewBuffer([]byte("foo"))
|
buff := bytes.NewBufferString("foo")
|
||||||
rr := readCounter{source: io.NopCloser(buff)}
|
rr := readCounter{source: io.NopCloser(buff)}
|
||||||
assert.Equal(t, int64(0), rr.size)
|
assert.Equal(t, int64(0), rr.size)
|
||||||
|
|
||||||
|
@ -333,7 +333,7 @@ func TestRedirectSchemeHandler(t *testing.T) {
|
|||||||
schemeRegex := `^(https?):\/\/(\[[\w:.]+\]|[\w\._-]+)?(:\d+)?(.*)$`
|
schemeRegex := `^(https?):\/\/(\[[\w:.]+\]|[\w\._-]+)?(:\d+)?(.*)$`
|
||||||
re, _ := regexp.Compile(schemeRegex)
|
re, _ := regexp.Compile(schemeRegex)
|
||||||
|
|
||||||
if re.Match([]byte(test.url)) {
|
if re.MatchString(test.url) {
|
||||||
match := re.FindStringSubmatch(test.url)
|
match := re.FindStringSubmatch(test.url)
|
||||||
req.RequestURI = match[4]
|
req.RequestURI = match[4]
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ func TestTLSCertificateContent(t *testing.T) {
|
|||||||
keyFile = "` + fileTLSKey.Name() + `"
|
keyFile = "` + fileTLSKey.Name() + `"
|
||||||
`
|
`
|
||||||
|
|
||||||
_, err = fileConfig.Write([]byte(content))
|
_, err = fileConfig.WriteString(content)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
provider := &Provider{}
|
provider := &Provider{}
|
||||||
|
@ -840,7 +840,7 @@ func checkTCPTLS(addr string, timeout time.Duration, tlsVersion uint16) (err err
|
|||||||
|
|
||||||
err = conn.SetReadDeadline(time.Now().Add(timeout))
|
err = conn.SetReadDeadline(time.Now().Add(timeout))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user