From 4a27fbf69f34dceeacd27a78a5302a29ee63f116 Mon Sep 17 00:00:00 2001 From: Fish-pro Date: Tue, 31 Jan 2023 23:20:56 +0800 Subject: [PATCH] feat: introduce `gci` to unify the order of package import (#2545) Introduce gci to unify the order of package import Signed-off-by: Fish-pro Co-authored-by: Rita Zhang --- .golangci.yaml | 1 + cmd/gator/expand/expand.go | 5 +---- main.go | 6 ++---- pkg/controller/config/config_controller_suite_test.go | 3 +-- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index e1df7498b3d..993f78331c7 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -30,6 +30,7 @@ linters: - errorlint - exportloopref - forcetypeassert + - gci - gocritic - goconst - godot diff --git a/cmd/gator/expand/expand.go b/cmd/gator/expand/expand.go index 502abe0759e..8287c888879 100644 --- a/cmd/gator/expand/expand.go +++ b/cmd/gator/expand/expand.go @@ -10,10 +10,7 @@ import ( "github.com/open-policy-agent/gatekeeper/pkg/gator/expand" "github.com/open-policy-agent/gatekeeper/pkg/gator/reader" "github.com/spf13/cobra" - - // yaml.v3 inserts a space before '-', which is inconsistent with standard - // kubernetes and kubebuilder format. yaml.v2 does not insert these spaces. - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v2" // yaml.v3 inserts a space before '-', which is inconsistent with standard, kubernetes and kubebuilder format. yaml.v2 does not insert these spaces. "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" ) diff --git a/main.go b/main.go index 289bc8f8c7d..3de4673f8dd 100644 --- a/main.go +++ b/main.go @@ -27,10 +27,6 @@ import ( "path/filepath" "time" - "github.com/open-policy-agent/gatekeeper/pkg/expansion" - // set GOMAXPROCS to the number of container cores, if known. - _ "go.uber.org/automaxprocs" - "github.com/go-logr/zapr" "github.com/open-policy-agent/cert-controller/pkg/rotator" constraintclient "github.com/open-policy-agent/frameworks/constraint/pkg/client" @@ -44,6 +40,7 @@ import ( "github.com/open-policy-agent/gatekeeper/pkg/audit" "github.com/open-policy-agent/gatekeeper/pkg/controller" "github.com/open-policy-agent/gatekeeper/pkg/controller/config/process" + "github.com/open-policy-agent/gatekeeper/pkg/expansion" "github.com/open-policy-agent/gatekeeper/pkg/externaldata" "github.com/open-policy-agent/gatekeeper/pkg/metrics" "github.com/open-policy-agent/gatekeeper/pkg/mutation" @@ -56,6 +53,7 @@ import ( "github.com/open-policy-agent/gatekeeper/pkg/watch" "github.com/open-policy-agent/gatekeeper/pkg/webhook" "github.com/open-policy-agent/gatekeeper/third_party/sigs.k8s.io/controller-runtime/pkg/dynamiccache" + _ "go.uber.org/automaxprocs" // set GOMAXPROCS to the number of container cores, if known. "go.uber.org/zap" "go.uber.org/zap/zapcore" "k8s.io/apimachinery/pkg/api/meta" diff --git a/pkg/controller/config/config_controller_suite_test.go b/pkg/controller/config/config_controller_suite_test.go index 7cc043985cf..82bd38f67b0 100644 --- a/pkg/controller/config/config_controller_suite_test.go +++ b/pkg/controller/config/config_controller_suite_test.go @@ -22,6 +22,7 @@ import ( "path/filepath" "testing" + "github.com/open-policy-agent/gatekeeper/apis" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes/scheme" @@ -30,8 +31,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/envtest" "sigs.k8s.io/controller-runtime/pkg/reconcile" - - "github.com/open-policy-agent/gatekeeper/apis" ) var cfg *rest.Config