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.
"noctx", # Too strict
"exhaustive", # Too strict
"nlreturn", # Too strict
]
[issues]

View file

@ -19,7 +19,7 @@ RUN mkdir -p /usr/local/bin \
&& chmod +x /usr/local/bin/go-bindata
# 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
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 (
// CITimeoutMultiplier is the multiplier for all timeout in the CI
// CITimeoutMultiplier is the multiplier for all timeout in the CI.
CITimeoutMultiplier = 3
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/ping"
"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/file"
"github.com/containous/traefik/v2/pkg/provider/kubernetes/crd"
@ -96,11 +95,11 @@ func TestDo_globalConfiguration(t *testing.T) {
CAServer: "CAServer",
Storage: "Storage",
KeyType: "MyKeyType",
DNSChallenge: &acmeprovider.DNSChallenge{Provider: "DNSProvider"},
HTTPChallenge: &acmeprovider.HTTPChallenge{
DNSChallenge: &acme.DNSChallenge{Provider: "DNSProvider"},
HTTPChallenge: &acme.HTTPChallenge{
EntryPoint: "MyEntryPoint",
},
TLSChallenge: &acmeprovider.TLSChallenge{},
TLSChallenge: &acme.TLSChallenge{},
},
},
}

View file

@ -38,7 +38,7 @@ import (
)
const (
// DefaultInternalEntryPointName the name of the default internal entry point
// DefaultInternalEntryPointName the name of the default internal entry point.
DefaultInternalEntryPointName = "traefik"
// DefaultGraceTimeout controls how long Traefik serves pending requests
@ -48,7 +48,7 @@ const (
// DefaultIdleTimeout before closing an idle connection.
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"
)

View file

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

View file

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

View file

@ -19,7 +19,7 @@ const (
ServiceName = "ServiceName"
// ServiceURL is the map key used for the URL of the Traefik backend.
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"
// ClientAddr is the map key used for the remote address in its original form (usually IP:port).
@ -46,9 +46,9 @@ const (
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 = "RequestContentSize"
// RequestRefererHeader is the Referer header in the request
// RequestRefererHeader is the Referer header in the request.
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"
// OriginDuration is the map key used for the time taken by the origin server ('upstream') to return its response.
OriginDuration = "OriginDuration"

View file

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

View file

@ -33,7 +33,7 @@ import (
)
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"
// SwarmAPIVersion is a constant holding the version of the Provider API traefik will use.

View file

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

View file

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

View file

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

View file

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

View file

@ -20,7 +20,6 @@ import (
"github.com/mitchellh/hashstructure"
ptypes "github.com/traefik/paerser/types"
corev1 "k8s.io/api/core/v1"
"k8s.io/api/networking/v1beta1"
networkingv1beta1 "k8s.io/api/networking/v1beta1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/intstr"
@ -291,7 +290,7 @@ func (p *Provider) loadConfigurationFromIngresses(ctx context.Context, client Cl
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.
if p.IngressEndpoint == nil {
return nil
@ -348,7 +347,7 @@ func buildHostRule(host string) string {
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 {
if t.SecretName == "" {
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
}
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)
if err != nil {
return nil, err
@ -539,7 +538,7 @@ func getProtocol(portSpec corev1.ServicePort, portName string, svcConfig *Servic
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
if len(rule.Host) > 0 {
rules = []string{buildHostRule(rule.Host)}
@ -548,11 +547,11 @@ func loadRouter(rule v1beta1.IngressRule, pa v1beta1.HTTPIngressPath, rtConfig *
if len(pa.Path) > 0 {
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 != "" {
matcher = rtConfig.Router.PathMatcher
}
} else if *pa.PathType == v1beta1.PathTypeExact {
} else if *pa.PathType == networkingv1beta1.PathTypeExact {
matcher = "Path"
}

View file

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