Skip to content

Commit

Permalink
lint: improve golanglint (#911)
Browse files Browse the repository at this point in the history
Signed-off-by: hejianpeng <hejianpeng2@huawei.com>

Signed-off-by: hejianpeng <hejianpeng2@huawei.com>
  • Loading branch information
zirain authored and Xunzhuo committed Jan 16, 2023
1 parent 7096c09 commit 88530b3
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 16 deletions.
11 changes: 10 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,22 @@ linters:
- revive
- gosec
- misspell
- scopelint
- exportloopref
- unconvert
- unparam
- goheader
- gocritic

linters-settings:
gci:
sections:
- standard # Captures all standard packages if they do not match another section.
- default # Contains all imports that could not be matched to another section type.
- prefix(github.com/envoyproxy/gateway/) # Groups all imports with the specified Prefix.
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: github.com/envoyproxy/gateway/
gofmt:
simplify: true
unparam:
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/validation/authenticationfilter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ package validation
import (
"testing"

"github.com/stretchr/testify/require"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1"
"github.com/stretchr/testify/require"
)

func TestValidateAuthenticationFilter(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion internal/gatewayapi/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import (
"fmt"
"strings"

"github.com/envoyproxy/gateway/internal/ir"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/gateway-api/apis/v1beta1"

"github.com/envoyproxy/gateway/internal/ir"
)

type FiltersTranslator interface {
Expand Down
2 changes: 1 addition & 1 deletion internal/gatewayapi/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
"fmt"
"strings"

"github.com/envoyproxy/gateway/internal/ir"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/gateway-api/apis/v1alpha2"
"sigs.k8s.io/gateway-api/apis/v1beta1"

egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1"
"github.com/envoyproxy/gateway/internal/ir"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion internal/gatewayapi/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ package gatewayapi
import (
"fmt"

"github.com/envoyproxy/gateway/internal/ir"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/gateway-api/apis/v1beta1"

"github.com/envoyproxy/gateway/internal/ir"
)

var _ ListenersTranslator = (*Translator)(nil)
Expand Down
3 changes: 2 additions & 1 deletion internal/gatewayapi/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import (
"fmt"
"strings"

"github.com/envoyproxy/gateway/internal/ir"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/gateway-api/apis/v1alpha2"
"sigs.k8s.io/gateway-api/apis/v1beta1"

"github.com/envoyproxy/gateway/internal/ir"
)

var _ RoutesTranslator = (*Translator)(nil)
Expand Down
3 changes: 2 additions & 1 deletion internal/status/conditions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ import (
"testing"
"time"

"github.com/envoyproxy/gateway/internal/gatewayapi"
"github.com/stretchr/testify/assert"
appsv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
utilclock "k8s.io/utils/clock"
fakeclock "k8s.io/utils/clock/testing"
gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1"

"github.com/envoyproxy/gateway/internal/gatewayapi"
)

var clock utilclock.Clock = utilclock.RealClock{}
Expand Down
14 changes: 7 additions & 7 deletions internal/xds/server/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ import (
"os"
"strconv"

"google.golang.org/grpc"
"google.golang.org/grpc/credentials"

"github.com/envoyproxy/gateway/internal/envoygateway/config"
"github.com/envoyproxy/gateway/internal/message"
"github.com/envoyproxy/gateway/internal/xds/cache"
xdstypes "github.com/envoyproxy/gateway/internal/xds/types"
controlplane_service_cluster_v3 "github.com/envoyproxy/go-control-plane/envoy/service/cluster/v3"
controlplane_service_discovery_v3 "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3"
controlplane_service_endpoint_v3 "github.com/envoyproxy/go-control-plane/envoy/service/endpoint/v3"
Expand All @@ -30,6 +23,13 @@ import (
controlplane_service_runtime_v3 "github.com/envoyproxy/go-control-plane/envoy/service/runtime/v3"
controlplane_service_secret_v3 "github.com/envoyproxy/go-control-plane/envoy/service/secret/v3"
controlplane_server_v3 "github.com/envoyproxy/go-control-plane/pkg/server/v3"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"

"github.com/envoyproxy/gateway/internal/envoygateway/config"
"github.com/envoyproxy/gateway/internal/message"
"github.com/envoyproxy/gateway/internal/xds/cache"
xdstypes "github.com/envoyproxy/gateway/internal/xds/types"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion internal/xds/translator/runner/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import (
"testing"
"time"

resourcev3 "github.com/envoyproxy/go-control-plane/pkg/resource/v3"
"github.com/stretchr/testify/require"

"github.com/envoyproxy/gateway/internal/envoygateway/config"
"github.com/envoyproxy/gateway/internal/ir"
"github.com/envoyproxy/gateway/internal/message"
resourcev3 "github.com/envoyproxy/go-control-plane/pkg/resource/v3"
)

func TestRunner(t *testing.T) {
Expand Down
20 changes: 19 additions & 1 deletion tools/linter/golangci-lint/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,35 @@ linters:
- revive
- gosec
- misspell
- scopelint
- exportloopref
- unconvert
- unparam
- goheader
- gocritic

linters-settings:
gci:
sections:
- standard # Captures all standard packages if they do not match another section.
- default # Contains all imports that could not be matched to another section type.
- prefix(github.com/envoyproxy/gateway/) # Groups all imports with the specified Prefix.
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: github.com/envoyproxy/gateway/
gofmt:
simplify: true
unparam:
check-exported: false
goheader:
# Note that because the format is different (this needs no comment markers),
# updating this text means also updating /tools/boilerplate.txt so that
# `make generate` will update the generated files correctly.
template: |-
Copyright Envoy Gateway Authors
SPDX-License-Identifier: Apache-2.0
The full text of the Apache license is available in the LICENSE file at
the root of the repo.
issues:
exclude-rules:
Expand Down

0 comments on commit 88530b3

Please sign in to comment.