diff --git a/.golangci.yml b/.golangci.yml index 973f62f91c..2572dcee0b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -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: diff --git a/api/v1alpha1/validation/authenticationfilter_test.go b/api/v1alpha1/validation/authenticationfilter_test.go index ff370af567..c105ed2fb4 100644 --- a/api/v1alpha1/validation/authenticationfilter_test.go +++ b/api/v1alpha1/validation/authenticationfilter_test.go @@ -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) { diff --git a/internal/gatewayapi/filters.go b/internal/gatewayapi/filters.go index 6b46669f09..72b70055f9 100644 --- a/internal/gatewayapi/filters.go +++ b/internal/gatewayapi/filters.go @@ -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 { diff --git a/internal/gatewayapi/helpers.go b/internal/gatewayapi/helpers.go index ebf7913df8..6276ccaf5a 100644 --- a/internal/gatewayapi/helpers.go +++ b/internal/gatewayapi/helpers.go @@ -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 ( diff --git a/internal/gatewayapi/listener.go b/internal/gatewayapi/listener.go index 5d47b6de07..be729d0b89 100644 --- a/internal/gatewayapi/listener.go +++ b/internal/gatewayapi/listener.go @@ -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) diff --git a/internal/gatewayapi/resource.go b/internal/gatewayapi/resource.go index 34aab828b9..6c5762f6a7 100644 --- a/internal/gatewayapi/resource.go +++ b/internal/gatewayapi/resource.go @@ -6,11 +6,12 @@ package gatewayapi import ( - egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" - "github.com/envoyproxy/gateway/internal/ir" v1 "k8s.io/api/core/v1" "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" ) type XdsIRMap map[string]*ir.Xds diff --git a/internal/gatewayapi/route.go b/internal/gatewayapi/route.go index a8fc3267d6..71ba587938 100644 --- a/internal/gatewayapi/route.go +++ b/internal/gatewayapi/route.go @@ -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) diff --git a/internal/provider/kubernetes/helpers_test.go b/internal/provider/kubernetes/helpers_test.go index abd38e2ba3..a4310488ef 100644 --- a/internal/provider/kubernetes/helpers_test.go +++ b/internal/provider/kubernetes/helpers_test.go @@ -9,10 +9,11 @@ import ( "testing" "time" - "github.com/envoyproxy/gateway/api/config/v1alpha1" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" + + "github.com/envoyproxy/gateway/api/config/v1alpha1" ) func TestGatewaysOfClass(t *testing.T) { diff --git a/internal/provider/kubernetes/test/utils.go b/internal/provider/kubernetes/test/utils.go index 739bf42a81..fe72447a87 100644 --- a/internal/provider/kubernetes/test/utils.go +++ b/internal/provider/kubernetes/test/utils.go @@ -6,15 +6,15 @@ package test import ( - egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/gatewayapi" - "k8s.io/apimachinery/pkg/types" ) type ObjectKindNamespacedName struct { diff --git a/internal/status/conditions_test.go b/internal/status/conditions_test.go index 8c2a9b263a..03f97c1b5f 100644 --- a/internal/status/conditions_test.go +++ b/internal/status/conditions_test.go @@ -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{} diff --git a/internal/xds/server/runner/runner.go b/internal/xds/server/runner/runner.go index ac530e5a9e..378490f73c 100644 --- a/internal/xds/server/runner/runner.go +++ b/internal/xds/server/runner/runner.go @@ -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" @@ -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 ( diff --git a/internal/xds/translator/runner/runner_test.go b/internal/xds/translator/runner/runner_test.go index 7c35ff92c9..b6dc54f367 100644 --- a/internal/xds/translator/runner/runner_test.go +++ b/internal/xds/translator/runner/runner_test.go @@ -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) { diff --git a/tools/linter/golangci-lint/.golangci.yml b/tools/linter/golangci-lint/.golangci.yml index e5051c4b23..2572dcee0b 100644 --- a/tools/linter/golangci-lint/.golangci.yml +++ b/tools/linter/golangci-lint/.golangci.yml @@ -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: