Skip to content

Commit

Permalink
*: Add the -local goimports flag to the fmt Makefile target (#10486)
Browse files Browse the repository at this point in the history
Signed-off-by: timflannagan <[email protected]>
  • Loading branch information
timflannagan authored Jan 31, 2025
1 parent 1d9e219 commit e168b0a
Show file tree
Hide file tree
Showing 290 changed files with 992 additions and 663 deletions.
8 changes: 1 addition & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,9 @@ include Makefile.ci
init:
git config core.hooksPath .githooks

# Runs [`goimports`](https://pkg.go.dev/golang.org/x/tools/cmd/goimports) which updates imports and formats code
# TODO: deprecate in favor of using fmt-v2
# Formats code and imports
.PHONY: fmt
fmt:
go run golang.org/x/tools/cmd/goimports -w $(shell ls -d */ | grep -v vendor)

# Formats code and imports
.PHONY: fmt-v2
fmt-v2:
go run golang.org/x/tools/cmd/goimports -local "github.com/kgateway-dev/kgateway/" -w $(shell ls -d */ | grep -v vendor)

.PHONY: fmt-changed
Expand Down
3 changes: 2 additions & 1 deletion docs/cmd/generate_docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ import (

"github.com/Masterminds/semver/v3"
"github.com/google/go-github/v32/github"
. "github.com/kgateway-dev/kgateway/docs/cmd/securityscanutils"
"github.com/rotisserie/eris"
changelogdocutils "github.com/solo-io/go-utils/changeloggenutils"
"github.com/solo-io/go-utils/githubutils"
"github.com/solo-io/go-utils/versionutils"
"github.com/spf13/cobra"

. "github.com/kgateway-dev/kgateway/docs/cmd/securityscanutils"
)

func main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package securityscanutils_test

import (
. "github.com/kgateway-dev/kgateway/docs/cmd/securityscanutils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

. "github.com/kgateway-dev/kgateway/docs/cmd/securityscanutils"
)

var _ = Describe("generate security scan docgen", func() {
Expand Down
5 changes: 3 additions & 2 deletions docs/content/crds/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import (
"strings"

"github.com/hashicorp/go-multierror"
"github.com/kgateway-dev/kgateway/pkg/utils/cmdutils"
"github.com/kgateway-dev/kgateway/projects/gateway2/api/v1alpha1"
"github.com/rotisserie/eris"
"github.com/stoewer/go-strcase"
"k8s.io/apimachinery/pkg/runtime/schema"

"github.com/kgateway-dev/kgateway/pkg/utils/cmdutils"
"github.com/kgateway-dev/kgateway/projects/gateway2/api/v1alpha1"
)

func main() {
Expand Down
5 changes: 3 additions & 2 deletions docs/content/guides/dev/example-proxy-controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ import (
"os"
"time"

v1 "github.com/kgateway-dev/kgateway/projects/gloo/pkg/api/v1"
matchers "github.com/kgateway-dev/kgateway/projects/gloo/pkg/api/v1/core/matchers"
"github.com/solo-io/k8s-utils/kubeutils"
"github.com/solo-io/solo-kit/pkg/api/v1/clients"
"github.com/solo-io/solo-kit/pkg/api/v1/clients/factory"
"github.com/solo-io/solo-kit/pkg/api/v1/clients/kube"
core "github.com/solo-io/solo-kit/pkg/api/v1/resources/core"

v1 "github.com/kgateway-dev/kgateway/projects/gloo/pkg/api/v1"
matchers "github.com/kgateway-dev/kgateway/projects/gloo/pkg/api/v1/core/matchers"

// import for GKE
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
)
Expand Down
5 changes: 3 additions & 2 deletions docs/content/guides/dev/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import (
"time"

cluster_v3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
"github.com/solo-io/solo-kit/pkg/api/v1/clients"
"github.com/solo-io/solo-kit/pkg/api/v1/resources/core"

v1 "github.com/kgateway-dev/kgateway/projects/gloo/pkg/api/v1"
"github.com/kgateway-dev/kgateway/projects/gloo/pkg/discovery"
"github.com/kgateway-dev/kgateway/projects/gloo/pkg/plugins"
"github.com/solo-io/solo-kit/pkg/api/v1/clients"
"github.com/solo-io/solo-kit/pkg/api/v1/resources/core"

// add these imports to use Envoy's API
envoycore "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
"strings"

"github.com/golang/protobuf/ptypes/wrappers"
glootestutils "github.com/kgateway-dev/kgateway/test/testutils"
"github.com/onsi/gomega/types"
v1 "k8s.io/api/admissionregistration/v1"

gloostringutils "github.com/kgateway-dev/kgateway/pkg/utils/stringutils"
glootestutils "github.com/kgateway-dev/kgateway/test/testutils"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/solo-io/go-utils/stringutils"
Expand All @@ -23,6 +23,8 @@ import (
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"sigs.k8s.io/yaml"

gloostringutils "github.com/kgateway-dev/kgateway/pkg/utils/stringutils"
)

const (
Expand Down
5 changes: 3 additions & 2 deletions install/test/grpc_json_transcoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import (
"os"
"strconv"

"github.com/kgateway-dev/kgateway/projects/gateway/pkg/defaults"
glootestutils "github.com/kgateway-dev/kgateway/test/testutils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/types"
. "github.com/solo-io/k8s-utils/manifesttestutils"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"

"github.com/kgateway-dev/kgateway/projects/gateway/pkg/defaults"
glootestutils "github.com/kgateway-dev/kgateway/test/testutils"
)

var _ = Describe("GrpcJsonTranscoder helm test", func() {
Expand Down
11 changes: 6 additions & 5 deletions install/test/helm_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ import (
"text/template"

"github.com/ghodss/yaml"
"github.com/kgateway-dev/kgateway/pkg/cliutil/helm"
"github.com/kgateway-dev/kgateway/projects/gloo/cli/pkg/cmd/install"
"github.com/kgateway-dev/kgateway/projects/gloo/pkg/defaults"
"github.com/kgateway-dev/kgateway/test/makefile"
glootestutils "github.com/kgateway-dev/kgateway/test/testutils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/pkg/errors"
Expand All @@ -30,6 +25,12 @@ import (
rbacv1 "k8s.io/api/rbac/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"

"github.com/kgateway-dev/kgateway/pkg/cliutil/helm"
"github.com/kgateway-dev/kgateway/projects/gloo/cli/pkg/cmd/install"
"github.com/kgateway-dev/kgateway/projects/gloo/pkg/defaults"
"github.com/kgateway-dev/kgateway/test/makefile"
glootestutils "github.com/kgateway-dev/kgateway/test/testutils"
)

const (
Expand Down
13 changes: 7 additions & 6 deletions install/test/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ import (

"github.com/ghodss/yaml"
"github.com/golang/protobuf/proto"
values "github.com/kgateway-dev/kgateway/install/helm/gloo/generate"
"github.com/kgateway-dev/kgateway/install/test/securitycontext"
"github.com/kgateway-dev/kgateway/pkg/utils/kubeutils"
"github.com/kgateway-dev/kgateway/projects/gateway/pkg/defaults"
"github.com/kgateway-dev/kgateway/test/gomega/matchers"
glootestutils "github.com/kgateway-dev/kgateway/test/testutils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/format"
Expand All @@ -38,6 +32,13 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/utils/pointer"

values "github.com/kgateway-dev/kgateway/install/helm/gloo/generate"
"github.com/kgateway-dev/kgateway/install/test/securitycontext"
"github.com/kgateway-dev/kgateway/pkg/utils/kubeutils"
"github.com/kgateway-dev/kgateway/projects/gateway/pkg/defaults"
"github.com/kgateway-dev/kgateway/test/gomega/matchers"
glootestutils "github.com/kgateway-dev/kgateway/test/testutils"
)

func GetPodNamespaceStats() corev1.EnvVar {
Expand Down
13 changes: 7 additions & 6 deletions install/test/k8sgateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@ package test
import (
"fmt"

"github.com/kgateway-dev/kgateway/install/utils/kuberesource"
"github.com/kgateway-dev/kgateway/pkg/utils/kubeutils"
"github.com/kgateway-dev/kgateway/projects/gateway2/api/v1alpha1"
"github.com/kgateway-dev/kgateway/projects/gateway2/wellknown"
"github.com/kgateway-dev/kgateway/test/gomega/matchers"
glootestutils "github.com/kgateway-dev/kgateway/test/testutils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/solo-io/k8s-utils/manifesttestutils"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/pointer"

"github.com/kgateway-dev/kgateway/install/utils/kuberesource"
"github.com/kgateway-dev/kgateway/pkg/utils/kubeutils"
"github.com/kgateway-dev/kgateway/projects/gateway2/api/v1alpha1"
"github.com/kgateway-dev/kgateway/projects/gateway2/wellknown"
"github.com/kgateway-dev/kgateway/test/gomega/matchers"
glootestutils "github.com/kgateway-dev/kgateway/test/testutils"
)

var _ = Describe("Kubernetes Gateway API integration", func() {
Expand Down
3 changes: 2 additions & 1 deletion install/test/rbac_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ package test
import (
"fmt"

glootestutils "github.com/kgateway-dev/kgateway/test/testutils"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

glootestutils "github.com/kgateway-dev/kgateway/test/testutils"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/format"
Expand Down
3 changes: 2 additions & 1 deletion install/test/svc_accnt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
package test

import (
glootestutils "github.com/kgateway-dev/kgateway/test/testutils"
. "github.com/onsi/ginkgo/v2"

glootestutils "github.com/kgateway-dev/kgateway/test/testutils"

. "github.com/onsi/gomega"
. "github.com/solo-io/k8s-utils/manifesttestutils"
)
Expand Down
3 changes: 2 additions & 1 deletion pkg/bootstrap/leaderelector/identity_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package leaderelector_test

import (
"github.com/kgateway-dev/kgateway/pkg/bootstrap/leaderelector"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/kgateway-dev/kgateway/pkg/bootstrap/leaderelector"
)

var _ = Describe("Identity", func() {
Expand Down
5 changes: 3 additions & 2 deletions pkg/bootstrap/leaderelector/kube/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import (
"sync/atomic"
"time"

"github.com/kgateway-dev/kgateway/pkg/bootstrap/leaderelector"
"github.com/kgateway-dev/kgateway/pkg/utils/envutils"
"github.com/solo-io/go-utils/contextutils"
"k8s.io/client-go/rest"
k8sleaderelection "k8s.io/client-go/tools/leaderelection"
"sigs.k8s.io/controller-runtime/pkg/leaderelection"

"github.com/kgateway-dev/kgateway/pkg/bootstrap/leaderelector"
"github.com/kgateway-dev/kgateway/pkg/utils/envutils"
)

var _ leaderelector.ElectionFactory = new(kubeElectionFactory)
Expand Down
3 changes: 2 additions & 1 deletion pkg/bootstrap/leaderelector/leader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"context"
"sync/atomic"

"github.com/kgateway-dev/kgateway/pkg/bootstrap/leaderelector"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/kgateway-dev/kgateway/pkg/bootstrap/leaderelector"
)

var _ = Describe("Leader Startup Action", func() {
Expand Down
3 changes: 2 additions & 1 deletion pkg/bootstrap/leaderelector/singlereplica/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package singlereplica
import (
"context"

"github.com/kgateway-dev/kgateway/pkg/bootstrap/leaderelector"
"github.com/solo-io/go-utils/contextutils"

"github.com/kgateway-dev/kgateway/pkg/bootstrap/leaderelector"
)

var _ leaderelector.ElectionFactory = new(singleReplicaElectionFactory)
Expand Down
5 changes: 3 additions & 2 deletions pkg/cliutil/input_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package cliutil_test

import (
. "github.com/kgateway-dev/kgateway/pkg/cliutil"
"github.com/kgateway-dev/kgateway/pkg/cliutil/testutil"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

. "github.com/kgateway-dev/kgateway/pkg/cliutil"
"github.com/kgateway-dev/kgateway/pkg/cliutil/testutil"
)

var _ = Describe("GetBoolInput", func() {
Expand Down
3 changes: 2 additions & 1 deletion pkg/cliutil/testutil/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import (

expect "github.com/Netflix/go-expect"
"github.com/hinshun/vt10x"
"github.com/kgateway-dev/kgateway/pkg/cliutil"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"gopkg.in/AlecAivazis/survey.v1/terminal"

"github.com/kgateway-dev/kgateway/pkg/cliutil"
)

func Stdio(c *expect.Console) terminal.Stdio {
Expand Down
1 change: 1 addition & 0 deletions pkg/cliutil/uri.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/kgateway-dev/kgateway/pkg/utils/kubeutils"

"github.com/avast/retry-go/v4"

"github.com/kgateway-dev/kgateway/pkg/utils/kubeutils/portforward"

"github.com/hashicorp/go-multierror"
Expand Down
3 changes: 2 additions & 1 deletion pkg/github-action-utils/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import (
"math"
"os"

"github.com/kgateway-dev/kgateway/pkg/version"
"github.com/pkg/errors"
"github.com/solo-io/go-utils/changelogutils"
"github.com/solo-io/go-utils/versionutils"
"github.com/solo-io/go-utils/vfsutils"

"github.com/kgateway-dev/kgateway/pkg/version"
)

// GetLatestEnterpriseVersion computes the latest Gloo Enterprise version.
Expand Down
3 changes: 2 additions & 1 deletion pkg/schemes/extended_scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package schemes
import (
"fmt"

"github.com/kgateway-dev/kgateway/projects/gateway2/wellknown"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/discovery"
"k8s.io/client-go/rest"

"github.com/kgateway-dev/kgateway/projects/gateway2/wellknown"

gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
)

Expand Down
3 changes: 2 additions & 1 deletion pkg/utils/envoyutils/admincli/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import (
adminv3 "github.com/envoyproxy/go-control-plane/envoy/admin/v3"
clusterv3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
listenerv3 "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3"
"github.com/solo-io/go-utils/threadsafe"

"github.com/kgateway-dev/kgateway/pkg/utils/cmdutils"
"github.com/kgateway-dev/kgateway/pkg/utils/protoutils"
"github.com/kgateway-dev/kgateway/pkg/utils/requestutils/curl"
"github.com/solo-io/go-utils/threadsafe"

"github.com/kgateway-dev/kgateway/pkg/utils/kubeutils/kubectl"
"github.com/kgateway-dev/kgateway/pkg/utils/kubeutils/portforward"
Expand Down
5 changes: 3 additions & 2 deletions pkg/utils/envoyutils/admincli/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package admincli_test
import (
"context"

"github.com/kgateway-dev/kgateway/pkg/utils/envoyutils/admincli"
"github.com/kgateway-dev/kgateway/pkg/utils/requestutils/curl"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/solo-io/go-utils/threadsafe"

"github.com/kgateway-dev/kgateway/pkg/utils/envoyutils/admincli"
"github.com/kgateway-dev/kgateway/pkg/utils/requestutils/curl"
)

var _ = Describe("Client", func() {
Expand Down
3 changes: 2 additions & 1 deletion pkg/utils/envoyutils/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ import (
envoy_extensions_filters_network_http_connection_manager_v3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3"
envoycache "github.com/envoyproxy/go-control-plane/pkg/cache/v3"
"github.com/envoyproxy/go-control-plane/pkg/wellknown"
"github.com/kgateway-dev/kgateway/projects/gateway2/utils"
"github.com/rotisserie/eris"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"

"github.com/kgateway-dev/kgateway/projects/gateway2/utils"
)

var (
Expand Down
Loading

0 comments on commit e168b0a

Please sign in to comment.