diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index 21aa83767..8d2195448 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -7,7 +7,7 @@ on: env: GO_VERSION: 1.17 - GOLANGCI_LINT_VERSION: v1.46.2 + GOLANGCI_LINT_VERSION: v1.47.1 MISSSPELL_VERSION: v0.3.4 IN_DOCKER: "" diff --git a/.golangci.toml b/.golangci.toml index 93777cec0..99dfcab4c 100644 --- a/.golangci.toml +++ b/.golangci.toml @@ -179,7 +179,7 @@ ] [[issues.exclude-rules]] path = "(.+)_test.go" - linters = ["goconst", "funlen", "godot"] + linters = ["goconst", "funlen", "godot", "nosnakecase"] [[issues.exclude-rules]] path = "integration/.+_test.go" text = "Error return value of `cmd\\.Process\\.Kill` is not checked" @@ -222,3 +222,15 @@ [[issues.exclude-rules]] path = "pkg/server/router/tcp/manager.go" text = "Function 'buildEntryPointHandler' is too long (.+)" + [[issues.exclude-rules]] + path = "integration/fake_dns_server.go" + linters = ["nosnakecase"] + [[issues.exclude-rules]] + path = "pkg/plugins/providers.go" + linters = ["nosnakecase"] + [[issues.exclude-rules]] + path = "pkg/tls/cipher.go" + linters = ["nosnakecase"] + [[issues.exclude-rules]] + text = "O_WRONLY|O_RDWR|O_CREATE|O_TRUNC|O_APPEND" + linters = ["nosnakecase"] diff --git a/build.Dockerfile b/build.Dockerfile index 8d3159c8e..24d5e829d 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.46.2 +RUN curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- -b $GOPATH/bin v1.47.1 # 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/docs/content/reference/dynamic-configuration/kubernetes-crd-definition-v1.yml b/docs/content/reference/dynamic-configuration/kubernetes-crd-definition-v1.yml index fb0e5ce37..345e90736 100644 --- a/docs/content/reference/dynamic-configuration/kubernetes-crd-definition-v1.yml +++ b/docs/content/reference/dynamic-configuration/kubernetes-crd-definition-v1.yml @@ -1904,8 +1904,8 @@ spec: schema: openAPIV3Schema: description: 'TraefikService is the CRD implementation of a Traefik Service. - TraefikService object allows to: - Apply weight to Services on load-balancing - - Mirror traffic on services More info: https://doc.traefik.io/traefik/v2.8/routing/providers/kubernetes-crd/#kind-traefikservice' + TraefikService object allows to: - Apply weight to Services on load-balancing + - Mirror traffic on services More info: https://doc.traefik.io/traefik/v2.8/routing/providers/kubernetes-crd/#kind-traefikservice' properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation diff --git a/docs/content/reference/dynamic-configuration/traefik.containo.us_traefikservices.yaml b/docs/content/reference/dynamic-configuration/traefik.containo.us_traefikservices.yaml index 4270ecf21..b9850c069 100644 --- a/docs/content/reference/dynamic-configuration/traefik.containo.us_traefikservices.yaml +++ b/docs/content/reference/dynamic-configuration/traefik.containo.us_traefikservices.yaml @@ -20,8 +20,8 @@ spec: schema: openAPIV3Schema: description: 'TraefikService is the CRD implementation of a Traefik Service. - TraefikService object allows to: - Apply weight to Services on load-balancing - - Mirror traffic on services More info: https://doc.traefik.io/traefik/v2.8/routing/providers/kubernetes-crd/#kind-traefikservice' + TraefikService object allows to: - Apply weight to Services on load-balancing + - Mirror traffic on services More info: https://doc.traefik.io/traefik/v2.8/routing/providers/kubernetes-crd/#kind-traefikservice' properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation diff --git a/golangci-lint b/golangci-lint new file mode 100755 index 000000000..ff30cd0dd Binary files /dev/null and b/golangci-lint differ diff --git a/integration/fixtures/k8s/01-traefik-crd.yml b/integration/fixtures/k8s/01-traefik-crd.yml index fb0e5ce37..345e90736 100644 --- a/integration/fixtures/k8s/01-traefik-crd.yml +++ b/integration/fixtures/k8s/01-traefik-crd.yml @@ -1904,8 +1904,8 @@ spec: schema: openAPIV3Schema: description: 'TraefikService is the CRD implementation of a Traefik Service. - TraefikService object allows to: - Apply weight to Services on load-balancing - - Mirror traffic on services More info: https://doc.traefik.io/traefik/v2.8/routing/providers/kubernetes-crd/#kind-traefikservice' + TraefikService object allows to: - Apply weight to Services on load-balancing + - Mirror traffic on services More info: https://doc.traefik.io/traefik/v2.8/routing/providers/kubernetes-crd/#kind-traefikservice' properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation diff --git a/integration/integration_test.go b/integration/integration_test.go index f73d09c46..19b53ad53 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -339,12 +339,12 @@ type tailscaleNotSuite struct{ BaseSuite } // Add this section to your tailscale ACLs to auto-approve the routes for the // containers in the docker subnet: // -// "autoApprovers": { -// // Allow myself to automatically advertize routes for docker networks -// "routes": { -// "172.0.0.0/8": ["your_tailscale_identity"], -// }, -// }, +// "autoApprovers": { +// // Allow myself to automatically advertize routes for docker networks +// "routes": { +// "172.0.0.0/8": ["your_tailscale_identity"], +// }, +// }, // // TODO(mpl): we could maybe even move this setup to the Makefile, to start it // and let it run (forever, or until voluntarily stopped). diff --git a/pkg/metrics/datadog.go b/pkg/metrics/datadog.go index 62cf9020d..6aeafddf6 100644 --- a/pkg/metrics/datadog.go +++ b/pkg/metrics/datadog.go @@ -53,7 +53,7 @@ func RegisterDatadog(ctx context.Context, config *types.Datadog) Registry { } datadogClient = dogstatsd.New(config.Prefix+".", kitlog.LoggerFunc(func(keyvals ...interface{}) error { - log.WithoutContext().WithField(log.MetricsProviderName, "datadog").Info(keyvals) + log.WithoutContext().WithField(log.MetricsProviderName, "datadog").Info(keyvals...) return nil })) diff --git a/pkg/metrics/influxdb.go b/pkg/metrics/influxdb.go index cbb72b997..47a0f2962 100644 --- a/pkg/metrics/influxdb.go +++ b/pkg/metrics/influxdb.go @@ -136,7 +136,7 @@ func initInfluxDBClient(ctx context.Context, config *types.InfluxDB) *influx.Inf RetentionPolicy: config.RetentionPolicy, }, kitlog.LoggerFunc(func(keyvals ...interface{}) error { - log.WithoutContext().WithField(log.MetricsProviderName, "influxdb").Info(keyvals) + log.WithoutContext().WithField(log.MetricsProviderName, "influxdb").Info(keyvals...) return nil })) } diff --git a/pkg/metrics/influxdb2.go b/pkg/metrics/influxdb2.go index 391499c65..9ca2caa94 100644 --- a/pkg/metrics/influxdb2.go +++ b/pkg/metrics/influxdb2.go @@ -38,7 +38,7 @@ func RegisterInfluxDB2(ctx context.Context, config *types.InfluxDB2) Registry { config.AdditionalLabels, influxdb.BatchPointsConfig{}, kitlog.LoggerFunc(func(kv ...interface{}) error { - log.FromContext(ctx).Error(kv) + log.FromContext(ctx).Error(kv...) return nil }), ) diff --git a/pkg/metrics/statsd.go b/pkg/metrics/statsd.go index 7a81dd351..90b356876 100644 --- a/pkg/metrics/statsd.go +++ b/pkg/metrics/statsd.go @@ -50,7 +50,7 @@ func RegisterStatsd(ctx context.Context, config *types.Statsd) Registry { } statsdClient = statsd.New(config.Prefix+".", kitlog.LoggerFunc(func(keyvals ...interface{}) error { - log.WithoutContext().WithField(log.MetricsProviderName, "statsd").Info(keyvals) + log.WithoutContext().WithField(log.MetricsProviderName, "statsd").Info(keyvals...) return nil })) diff --git a/pkg/provider/kubernetes/crd/traefik/v1alpha1/service.go b/pkg/provider/kubernetes/crd/traefik/v1alpha1/service.go index 847c97dae..c7cbe593a 100644 --- a/pkg/provider/kubernetes/crd/traefik/v1alpha1/service.go +++ b/pkg/provider/kubernetes/crd/traefik/v1alpha1/service.go @@ -11,8 +11,8 @@ import ( // TraefikService is the CRD implementation of a Traefik Service. // TraefikService object allows to: -// - Apply weight to Services on load-balancing -// - Mirror traffic on services +// - Apply weight to Services on load-balancing +// - Mirror traffic on services // More info: https://doc.traefik.io/traefik/v2.8/routing/providers/kubernetes-crd/#kind-traefikservice type TraefikService struct { metav1.TypeMeta `json:",inline"` diff --git a/pkg/provider/kubernetes/ingress/client.go b/pkg/provider/kubernetes/ingress/client.go index 7dddb8cda..b9759b1f0 100644 --- a/pkg/provider/kubernetes/ingress/client.go +++ b/pkg/provider/kubernetes/ingress/client.go @@ -570,7 +570,7 @@ func filterIngressClassByName(ingressClassName string, ics []*networkingv1.Ingre return ingressClasses } -// Ingress in networking.k8s.io/v1 is supported starting 1.19. +// Ingress in networking.k8s.io/v1 is supported starting 1.19. // thus, we query it in K8s starting 1.19. func supportsNetworkingV1Ingress(serverVersion *version.Version) bool { ingressNetworkingVersion := version.Must(version.NewVersion("1.19")) diff --git a/pkg/server/router/tcp/router_test.go b/pkg/server/router/tcp/router_test.go index f9e9978cf..1e2180090 100644 --- a/pkg/server/router/tcp/router_test.go +++ b/pkg/server/router/tcp/router_test.go @@ -94,7 +94,6 @@ func (h *httpForwarder) Accept() (net.Conn, error) { // // - TCP-TLS HostSNI(`foobar`) and HTTPS PathPrefix(`/`) // - On v2.6 and v2.7, the TCP-TLS one takes precedence. -// func Test_Routing(t *testing.T) { // This listener simulates the backend service. // It is capable of switching into server first communication mode, diff --git a/pkg/server/service/roundtripper_test.go b/pkg/server/service/roundtripper_test.go index b58a26e33..a057166ab 100644 --- a/pkg/server/service/roundtripper_test.go +++ b/pkg/server/service/roundtripper_test.go @@ -55,13 +55,13 @@ QPZ6VGR7+w1jB5BQXqEZcpHQIPSzeQJBAIy9tZJ/AYNlNbcegxEnsSjy/6VdlLsY rqPRSAtd/h6oZbs= -----END PRIVATE KEY-----`) -// openssl req -newkey rsa:2048 \ -// -new -nodes -x509 \ -// -days 3650 \ -// -out cert.pem \ -// -keyout key.pem \ -// -subj "/CN=example.com" -// -addext "subjectAltName = DNS:example.com" +// openssl req -newkey rsa:2048 \ +// -new -nodes -x509 \ +// -days 3650 \ +// -out cert.pem \ +// -keyout key.pem \ +// -subj "/CN=example.com" +// -addext "subjectAltName = DNS:example.com" var mTLSCert = []byte(`-----BEGIN CERTIFICATE----- MIIDJTCCAg2gAwIBAgIUYKnGcLnmMosOSKqTn4ydAMURE4gwDQYJKoZIhvcNAQEL BQAwFjEUMBIGA1UEAwwLZXhhbXBsZS5jb20wHhcNMjAwODEzMDkyNzIwWhcNMzAw diff --git a/pkg/tcp/chain.go b/pkg/tcp/chain.go index cc192b667..8cc351ba5 100644 --- a/pkg/tcp/chain.go +++ b/pkg/tcp/chain.go @@ -48,10 +48,10 @@ func (c Chain) Then(h Handler) (Handler, error) { // // Append returns a new chain, leaving the original one untouched. // -// stdChain := tcp.NewChain(m1, m2) -// extChain := stdChain.Append(m3, m4) -// // requests in stdChain go m1 -> m2 -// // requests in extChain go m1 -> m2 -> m3 -> m4 +// stdChain := tcp.NewChain(m1, m2) +// extChain := stdChain.Append(m3, m4) +// // requests in stdChain go m1 -> m2 +// // requests in extChain go m1 -> m2 -> m3 -> m4 func (c Chain) Append(constructors ...Constructor) Chain { newCons := make([]Constructor, 0, len(c.constructors)+len(constructors)) newCons = append(newCons, c.constructors...) @@ -65,22 +65,23 @@ func (c Chain) Append(constructors ...Constructor) Chain { // // Extend returns a new chain, leaving the original one untouched. // -// stdChain := tcp.NewChain(m1, m2) -// ext1Chain := tcp.NewChain(m3, m4) -// ext2Chain := stdChain.Extend(ext1Chain) -// // requests in stdChain go m1 -> m2 -// // requests in ext1Chain go m3 -> m4 -// // requests in ext2Chain go m1 -> m2 -> m3 -> m4 +// stdChain := tcp.NewChain(m1, m2) +// ext1Chain := tcp.NewChain(m3, m4) +// ext2Chain := stdChain.Extend(ext1Chain) +// // requests in stdChain go m1 -> m2 +// // requests in ext1Chain go m3 -> m4 +// // requests in ext2Chain go m1 -> m2 -> m3 -> m4 // // Another example: -// aHtmlAfterNosurf := tcp.NewChain(m2) -// aHtml := tcp.NewChain(m1, func(h tcp.Handler) tcp.Handler { -// csrf := nosurf.New(h) -// csrf.SetFailureHandler(aHtmlAfterNosurf.ThenFunc(csrfFail)) -// return csrf -// }).Extend(aHtmlAfterNosurf) -// // requests to aHtml hitting nosurfs success handler go m1 -> nosurf -> m2 -> target-handler -// // requests to aHtml hitting nosurfs failure handler go m1 -> nosurf -> m2 -> csrfFail +// +// aHtmlAfterNosurf := tcp.NewChain(m2) +// aHtml := tcp.NewChain(m1, func(h tcp.Handler) tcp.Handler { +// csrf := nosurf.New(h) +// csrf.SetFailureHandler(aHtmlAfterNosurf.ThenFunc(csrfFail)) +// return csrf +// }).Extend(aHtmlAfterNosurf) +// // requests to aHtml hitting nosurfs success handler go m1 -> nosurf -> m2 -> target-handler +// // requests to aHtml hitting nosurfs failure handler go m1 -> nosurf -> m2 -> csrfFail func (c Chain) Extend(chain Chain) Chain { return c.Append(chain.constructors...) } diff --git a/pkg/tracing/haystack/logger.go b/pkg/tracing/haystack/logger.go index 0912557cb..7635bd821 100644 --- a/pkg/tracing/haystack/logger.go +++ b/pkg/tracing/haystack/logger.go @@ -10,15 +10,15 @@ type haystackLogger struct { // Error prints the error message. func (l haystackLogger) Error(format string, v ...interface{}) { - l.logger.Errorf(format, v) + l.logger.Errorf(format, v...) } // Info prints the info message. func (l haystackLogger) Info(format string, v ...interface{}) { - l.logger.Infof(format, v) + l.logger.Infof(format, v...) } // Debug prints the info message. func (l haystackLogger) Debug(format string, v ...interface{}) { - l.logger.Debug(format, v) + l.logger.Debugf(format, v...) }