chore: update linter.

This commit is contained in:
Ludovic Fernandez 2020-08-21 11:12:04 +02:00 committed by GitHub
parent e424cc7608
commit b67a7215f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 38 additions and 44 deletions

View file

@ -54,6 +54,7 @@
"nestif", # Too many false-positive. "nestif", # Too many false-positive.
"noctx", # Too strict "noctx", # Too strict
"exhaustive", # Too strict "exhaustive", # Too strict
"nlreturn", # Too strict
] ]
[issues] [issues]

View file

@ -19,7 +19,7 @@ RUN mkdir -p /usr/local/bin \
&& chmod +x /usr/local/bin/go-bindata && chmod +x /usr/local/bin/go-bindata
# Download golangci-lint binary to bin folder in $GOPATH # Download golangci-lint binary to bin folder in $GOPATH
RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.28.0 RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.30.0
# Download misspell binary to bin folder in $GOPATH # 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 RUN curl -sfL https://raw.githubusercontent.com/client9/misspell/master/install-misspell.sh | bash -s -- -b $GOPATH/bin v0.3.4

View file

@ -11,7 +11,7 @@ import (
) )
const ( const (
// CITimeoutMultiplier is the multiplier for all timeout in the CI // CITimeoutMultiplier is the multiplier for all timeout in the CI.
CITimeoutMultiplier = 3 CITimeoutMultiplier = 3
maxInterval = 5 * time.Second maxInterval = 5 * time.Second
) )

View file

@ -8,7 +8,6 @@ import (
"github.com/containous/traefik/v2/pkg/config/static" "github.com/containous/traefik/v2/pkg/config/static"
"github.com/containous/traefik/v2/pkg/ping" "github.com/containous/traefik/v2/pkg/ping"
"github.com/containous/traefik/v2/pkg/provider/acme" "github.com/containous/traefik/v2/pkg/provider/acme"
acmeprovider "github.com/containous/traefik/v2/pkg/provider/acme"
"github.com/containous/traefik/v2/pkg/provider/docker" "github.com/containous/traefik/v2/pkg/provider/docker"
"github.com/containous/traefik/v2/pkg/provider/file" "github.com/containous/traefik/v2/pkg/provider/file"
"github.com/containous/traefik/v2/pkg/provider/kubernetes/crd" "github.com/containous/traefik/v2/pkg/provider/kubernetes/crd"
@ -96,11 +95,11 @@ func TestDo_globalConfiguration(t *testing.T) {
CAServer: "CAServer", CAServer: "CAServer",
Storage: "Storage", Storage: "Storage",
KeyType: "MyKeyType", KeyType: "MyKeyType",
DNSChallenge: &acmeprovider.DNSChallenge{Provider: "DNSProvider"}, DNSChallenge: &acme.DNSChallenge{Provider: "DNSProvider"},
HTTPChallenge: &acmeprovider.HTTPChallenge{ HTTPChallenge: &acme.HTTPChallenge{
EntryPoint: "MyEntryPoint", EntryPoint: "MyEntryPoint",
}, },
TLSChallenge: &acmeprovider.TLSChallenge{}, TLSChallenge: &acme.TLSChallenge{},
}, },
}, },
} }

View file

@ -38,7 +38,7 @@ import (
) )
const ( const (
// DefaultInternalEntryPointName the name of the default internal entry point // DefaultInternalEntryPointName the name of the default internal entry point.
DefaultInternalEntryPointName = "traefik" DefaultInternalEntryPointName = "traefik"
// DefaultGraceTimeout controls how long Traefik serves pending requests // DefaultGraceTimeout controls how long Traefik serves pending requests
@ -48,7 +48,7 @@ const (
// DefaultIdleTimeout before closing an idle connection. // DefaultIdleTimeout before closing an idle connection.
DefaultIdleTimeout = 180 * time.Second DefaultIdleTimeout = 180 * time.Second
// DefaultAcmeCAServer is the default ACME API endpoint // DefaultAcmeCAServer is the default ACME API endpoint.
DefaultAcmeCAServer = "https://acme-v02.api.letsencrypt.org/directory" DefaultAcmeCAServer = "https://acme-v02.api.letsencrypt.org/directory"
) )

View file

@ -10,21 +10,21 @@ import (
) )
const ( const (
// server meta information // server meta information.
pilotConfigPrefix = "config" pilotConfigPrefix = "config"
pilotConfigReloadsTotalName = pilotConfigPrefix + "ReloadsTotal" pilotConfigReloadsTotalName = pilotConfigPrefix + "ReloadsTotal"
pilotConfigReloadsFailuresTotalName = pilotConfigPrefix + "ReloadsFailureTotal" pilotConfigReloadsFailuresTotalName = pilotConfigPrefix + "ReloadsFailureTotal"
pilotConfigLastReloadSuccessName = pilotConfigPrefix + "LastReloadSuccess" pilotConfigLastReloadSuccessName = pilotConfigPrefix + "LastReloadSuccess"
pilotConfigLastReloadFailureName = pilotConfigPrefix + "LastReloadFailure" pilotConfigLastReloadFailureName = pilotConfigPrefix + "LastReloadFailure"
// entry point // entry point.
pilotEntryPointPrefix = "entrypoint" pilotEntryPointPrefix = "entrypoint"
pilotEntryPointReqsTotalName = pilotEntryPointPrefix + "RequestsTotal" pilotEntryPointReqsTotalName = pilotEntryPointPrefix + "RequestsTotal"
pilotEntryPointReqsTLSTotalName = pilotEntryPointPrefix + "RequestsTLSTotal" pilotEntryPointReqsTLSTotalName = pilotEntryPointPrefix + "RequestsTLSTotal"
pilotEntryPointReqDurationName = pilotEntryPointPrefix + "RequestDurationSeconds" pilotEntryPointReqDurationName = pilotEntryPointPrefix + "RequestDurationSeconds"
pilotEntryPointOpenConnsName = pilotEntryPointPrefix + "OpenConnections" pilotEntryPointOpenConnsName = pilotEntryPointPrefix + "OpenConnections"
// service level // service level.
pilotServicePrefix = "service" pilotServicePrefix = "service"
pilotServiceReqsTotalName = pilotServicePrefix + "RequestsTotal" pilotServiceReqsTotalName = pilotServicePrefix + "RequestsTotal"
pilotServiceReqsTLSTotalName = pilotServicePrefix + "RequestsTLSTotal" pilotServiceReqsTLSTotalName = pilotServicePrefix + "RequestsTLSTotal"

View file

@ -18,17 +18,17 @@ import (
) )
const ( const (
// MetricNamePrefix prefix of all metric names // MetricNamePrefix prefix of all metric names.
MetricNamePrefix = "traefik_" MetricNamePrefix = "traefik_"
// server meta information // server meta information.
metricConfigPrefix = MetricNamePrefix + "config_" metricConfigPrefix = MetricNamePrefix + "config_"
configReloadsTotalName = metricConfigPrefix + "reloads_total" configReloadsTotalName = metricConfigPrefix + "reloads_total"
configReloadsFailuresTotalName = metricConfigPrefix + "reloads_failure_total" configReloadsFailuresTotalName = metricConfigPrefix + "reloads_failure_total"
configLastReloadSuccessName = metricConfigPrefix + "last_reload_success" configLastReloadSuccessName = metricConfigPrefix + "last_reload_success"
configLastReloadFailureName = metricConfigPrefix + "last_reload_failure" configLastReloadFailureName = metricConfigPrefix + "last_reload_failure"
// entry point // entry point.
metricEntryPointPrefix = MetricNamePrefix + "entrypoint_" metricEntryPointPrefix = MetricNamePrefix + "entrypoint_"
entryPointReqsTotalName = metricEntryPointPrefix + "requests_total" entryPointReqsTotalName = metricEntryPointPrefix + "requests_total"
entryPointReqsTLSTotalName = metricEntryPointPrefix + "requests_tls_total" entryPointReqsTLSTotalName = metricEntryPointPrefix + "requests_tls_total"
@ -37,7 +37,7 @@ const (
// service level. // service level.
// MetricServicePrefix prefix of all service metric names // MetricServicePrefix prefix of all service metric names.
MetricServicePrefix = MetricNamePrefix + "service_" MetricServicePrefix = MetricNamePrefix + "service_"
serviceReqsTotalName = MetricServicePrefix + "requests_total" serviceReqsTotalName = MetricServicePrefix + "requests_total"
serviceReqsTLSTotalName = MetricServicePrefix + "requests_tls_total" serviceReqsTLSTotalName = MetricServicePrefix + "requests_tls_total"

View file

@ -19,7 +19,7 @@ const (
ServiceName = "ServiceName" ServiceName = "ServiceName"
// ServiceURL is the map key used for the URL of the Traefik backend. // ServiceURL is the map key used for the URL of the Traefik backend.
ServiceURL = "ServiceURL" ServiceURL = "ServiceURL"
// ServiceAddr is the map key used for the IP:port of the Traefik backend (extracted from BackendURL) // ServiceAddr is the map key used for the IP:port of the Traefik backend (extracted from BackendURL).
ServiceAddr = "ServiceAddr" ServiceAddr = "ServiceAddr"
// ClientAddr is the map key used for the remote address in its original form (usually IP:port). // ClientAddr is the map key used for the remote address in its original form (usually IP:port).
@ -46,9 +46,9 @@ const (
RequestScheme = "RequestScheme" RequestScheme = "RequestScheme"
// RequestContentSize is the map key used for the number of bytes in the request entity (a.k.a. body) sent by the client. // RequestContentSize is the map key used for the number of bytes in the request entity (a.k.a. body) sent by the client.
RequestContentSize = "RequestContentSize" RequestContentSize = "RequestContentSize"
// RequestRefererHeader is the Referer header in the request // RequestRefererHeader is the Referer header in the request.
RequestRefererHeader = "request_Referer" RequestRefererHeader = "request_Referer"
// RequestUserAgentHeader is the User-Agent header in the request // RequestUserAgentHeader is the User-Agent header in the request.
RequestUserAgentHeader = "request_User-Agent" RequestUserAgentHeader = "request_User-Agent"
// OriginDuration is the map key used for the time taken by the origin server ('upstream') to return its response. // OriginDuration is the map key used for the time taken by the origin server ('upstream') to return its response.
OriginDuration = "OriginDuration" OriginDuration = "OriginDuration"

View file

@ -4,9 +4,8 @@ import (
"net/http" "net/http"
"testing" "testing"
"github.com/containous/traefik/v2/pkg/types"
"github.com/containous/traefik/v2/pkg/testhelpers" "github.com/containous/traefik/v2/pkg/testhelpers"
"github.com/containous/traefik/v2/pkg/types"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )

View file

@ -33,7 +33,7 @@ import (
) )
const ( const (
// DockerAPIVersion is a constant holding the version of the Provider API traefik will use // DockerAPIVersion is a constant holding the version of the Provider API traefik will use.
DockerAPIVersion = "1.24" DockerAPIVersion = "1.24"
// SwarmAPIVersion is a constant holding the version of the Provider API traefik will use. // SwarmAPIVersion is a constant holding the version of the Provider API traefik will use.

View file

@ -7,7 +7,6 @@ import (
"time" "time"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
docker "github.com/docker/docker/api/types"
dockertypes "github.com/docker/docker/api/types" dockertypes "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
dockerclient "github.com/docker/docker/client" dockerclient "github.com/docker/docker/client"
@ -36,7 +35,7 @@ func TestListTasks(t *testing.T) {
tasks []swarm.Task tasks []swarm.Task
isGlobalSVC bool isGlobalSVC bool
expectedTasks []string expectedTasks []string
networks map[string]*docker.NetworkResource networks map[string]*dockertypes.NetworkResource
}{ }{
{ {
service: swarmService(serviceName("container")), service: swarmService(serviceName("container")),
@ -71,7 +70,7 @@ func TestListTasks(t *testing.T) {
"container.1", "container.1",
"container.4", "container.4",
}, },
networks: map[string]*docker.NetworkResource{ networks: map[string]*dockertypes.NetworkResource{
"1": { "1": {
Name: "foo", Name: "foo",
}, },
@ -300,7 +299,7 @@ func TestSwarmTaskParsing(t *testing.T) {
tasks []swarm.Task tasks []swarm.Task
isGlobalSVC bool isGlobalSVC bool
expected map[string]dockerData expected map[string]dockerData
networks map[string]*docker.NetworkResource networks map[string]*dockertypes.NetworkResource
}{ }{
{ {
service: swarmService(serviceName("container")), service: swarmService(serviceName("container")),
@ -321,7 +320,7 @@ func TestSwarmTaskParsing(t *testing.T) {
Name: "container.3", Name: "container.3",
}, },
}, },
networks: map[string]*docker.NetworkResource{ networks: map[string]*dockertypes.NetworkResource{
"1": { "1": {
Name: "foo", Name: "foo",
}, },
@ -346,7 +345,7 @@ func TestSwarmTaskParsing(t *testing.T) {
Name: "container.id3", Name: "container.id3",
}, },
}, },
networks: map[string]*docker.NetworkResource{ networks: map[string]*dockertypes.NetworkResource{
"1": { "1": {
Name: "foo", Name: "foo",
}, },
@ -384,7 +383,7 @@ func TestSwarmTaskParsing(t *testing.T) {
}, },
}, },
}, },
networks: map[string]*docker.NetworkResource{ networks: map[string]*dockertypes.NetworkResource{
"1": { "1": {
Name: "vlan", Name: "vlan",
}, },

View file

@ -9,7 +9,6 @@ import (
"strings" "strings"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/containous/traefik/v2/pkg/config/dynamic" "github.com/containous/traefik/v2/pkg/config/dynamic"
"github.com/containous/traefik/v2/pkg/config/label" "github.com/containous/traefik/v2/pkg/config/label"
"github.com/containous/traefik/v2/pkg/log" "github.com/containous/traefik/v2/pkg/log"

View file

@ -4,12 +4,11 @@ import (
"context" "context"
"testing" "testing"
corev1 "k8s.io/api/core/v1"
"github.com/containous/traefik/v2/pkg/config/dynamic" "github.com/containous/traefik/v2/pkg/config/dynamic"
"github.com/containous/traefik/v2/pkg/provider" "github.com/containous/traefik/v2/pkg/provider"
"github.com/containous/traefik/v2/pkg/tls" "github.com/containous/traefik/v2/pkg/tls"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
) )
var _ provider.Provider = (*Provider)(nil) var _ provider.Provider = (*Provider)(nil)

View file

@ -8,14 +8,13 @@ import (
"github.com/hashicorp/go-version" "github.com/hashicorp/go-version"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
extensionsv1beta1 "k8s.io/api/extensions/v1beta1" extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
"k8s.io/api/networking/v1beta1"
networkingv1beta1 "k8s.io/api/networking/v1beta1" networkingv1beta1 "k8s.io/api/networking/v1beta1"
) )
var _ Client = (*clientMock)(nil) var _ Client = (*clientMock)(nil)
type clientMock struct { type clientMock struct {
ingresses []*v1beta1.Ingress ingresses []*networkingv1beta1.Ingress
services []*corev1.Service services []*corev1.Service
secrets []*corev1.Secret secrets []*corev1.Secret
endpoints []*corev1.Endpoints endpoints []*corev1.Endpoints
@ -51,7 +50,7 @@ func newClientMock(serverVersion string, paths ...string) clientMock {
c.secrets = append(c.secrets, o) c.secrets = append(c.secrets, o)
case *corev1.Endpoints: case *corev1.Endpoints:
c.endpoints = append(c.endpoints, o) c.endpoints = append(c.endpoints, o)
case *v1beta1.Ingress: case *networkingv1beta1.Ingress:
c.ingresses = append(c.ingresses, o) c.ingresses = append(c.ingresses, o)
case *extensionsv1beta1.Ingress: case *extensionsv1beta1.Ingress:
ing, err := extensionsToNetworking(o) ing, err := extensionsToNetworking(o)
@ -70,7 +69,7 @@ func newClientMock(serverVersion string, paths ...string) clientMock {
return c return c
} }
func (c clientMock) GetIngresses() []*v1beta1.Ingress { func (c clientMock) GetIngresses() []*networkingv1beta1.Ingress {
return c.ingresses return c.ingresses
} }
@ -126,6 +125,6 @@ func (c clientMock) WatchAll(namespaces []string, stopCh <-chan struct{}) (<-cha
return c.watchChan, nil return c.watchChan, nil
} }
func (c clientMock) UpdateIngressStatus(_ *v1beta1.Ingress, _, _ string) error { func (c clientMock) UpdateIngressStatus(_ *networkingv1beta1.Ingress, _, _ string) error {
return c.apiIngressStatusError return c.apiIngressStatusError
} }

View file

@ -20,7 +20,6 @@ import (
"github.com/mitchellh/hashstructure" "github.com/mitchellh/hashstructure"
ptypes "github.com/traefik/paerser/types" ptypes "github.com/traefik/paerser/types"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
"k8s.io/api/networking/v1beta1"
networkingv1beta1 "k8s.io/api/networking/v1beta1" networkingv1beta1 "k8s.io/api/networking/v1beta1"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/intstr"
@ -291,7 +290,7 @@ func (p *Provider) loadConfigurationFromIngresses(ctx context.Context, client Cl
return conf return conf
} }
func (p *Provider) updateIngressStatus(ing *v1beta1.Ingress, k8sClient Client) error { func (p *Provider) updateIngressStatus(ing *networkingv1beta1.Ingress, k8sClient Client) error {
// Only process if an EndpointIngress has been configured. // Only process if an EndpointIngress has been configured.
if p.IngressEndpoint == nil { if p.IngressEndpoint == nil {
return nil return nil
@ -348,7 +347,7 @@ func buildHostRule(host string) string {
return "Host(`" + host + "`)" return "Host(`" + host + "`)"
} }
func getCertificates(ctx context.Context, ingress *v1beta1.Ingress, k8sClient Client, tlsConfigs map[string]*tls.CertAndStores) error { func getCertificates(ctx context.Context, ingress *networkingv1beta1.Ingress, k8sClient Client, tlsConfigs map[string]*tls.CertAndStores) error {
for _, t := range ingress.Spec.TLS { for _, t := range ingress.Spec.TLS {
if t.SecretName == "" { if t.SecretName == "" {
log.FromContext(ctx).Debugf("Skipping TLS sub-section: No secret name provided") log.FromContext(ctx).Debugf("Skipping TLS sub-section: No secret name provided")
@ -433,7 +432,7 @@ func getTLSConfig(tlsConfigs map[string]*tls.CertAndStores) []*tls.CertAndStores
return configs return configs
} }
func loadService(client Client, namespace string, backend v1beta1.IngressBackend) (*dynamic.Service, error) { func loadService(client Client, namespace string, backend networkingv1beta1.IngressBackend) (*dynamic.Service, error) {
service, exists, err := client.GetService(namespace, backend.ServiceName) service, exists, err := client.GetService(namespace, backend.ServiceName)
if err != nil { if err != nil {
return nil, err return nil, err
@ -539,7 +538,7 @@ func getProtocol(portSpec corev1.ServicePort, portName string, svcConfig *Servic
return protocol return protocol
} }
func loadRouter(rule v1beta1.IngressRule, pa v1beta1.HTTPIngressPath, rtConfig *RouterConfig, serviceName string) *dynamic.Router { func loadRouter(rule networkingv1beta1.IngressRule, pa networkingv1beta1.HTTPIngressPath, rtConfig *RouterConfig, serviceName string) *dynamic.Router {
var rules []string var rules []string
if len(rule.Host) > 0 { if len(rule.Host) > 0 {
rules = []string{buildHostRule(rule.Host)} rules = []string{buildHostRule(rule.Host)}
@ -548,11 +547,11 @@ func loadRouter(rule v1beta1.IngressRule, pa v1beta1.HTTPIngressPath, rtConfig *
if len(pa.Path) > 0 { if len(pa.Path) > 0 {
matcher := defaultPathMatcher matcher := defaultPathMatcher
if pa.PathType == nil || *pa.PathType == "" || *pa.PathType == v1beta1.PathTypeImplementationSpecific { if pa.PathType == nil || *pa.PathType == "" || *pa.PathType == networkingv1beta1.PathTypeImplementationSpecific {
if rtConfig != nil && rtConfig.Router != nil && rtConfig.Router.PathMatcher != "" { if rtConfig != nil && rtConfig.Router != nil && rtConfig.Router.PathMatcher != "" {
matcher = rtConfig.Router.PathMatcher matcher = rtConfig.Router.PathMatcher
} }
} else if *pa.PathType == v1beta1.PathTypeExact { } else if *pa.PathType == networkingv1beta1.PathTypeExact {
matcher = "Path" matcher = "Path"
} }

View file

@ -41,7 +41,7 @@ func (v Handler) Append(router *mux.Router) {
Version string Version string
Codename string Codename string
StartDate time.Time `json:"startDate"` StartDate time.Time `json:"startDate"`
UUID string `json:"uuid"` UUID string `json:"uuid,omitempty"`
}{ }{
Version: Version, Version: Version,
Codename: Codename, Codename: Codename,