Skip to content

Commit e168b0a

Browse files
authored
*: Add the -local goimports flag to the fmt Makefile target (#10486)
Signed-off-by: timflannagan <[email protected]>
1 parent 1d9e219 commit e168b0a

File tree

290 files changed

+992
-663
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

290 files changed

+992
-663
lines changed

Makefile

+1-7
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,9 @@ include Makefile.ci
134134
init:
135135
git config core.hooksPath .githooks
136136

137-
# Runs [`goimports`](https://pkg.go.dev/golang.org/x/tools/cmd/goimports) which updates imports and formats code
138-
# TODO: deprecate in favor of using fmt-v2
137+
# Formats code and imports
139138
.PHONY: fmt
140139
fmt:
141-
go run golang.org/x/tools/cmd/goimports -w $(shell ls -d */ | grep -v vendor)
142-
143-
# Formats code and imports
144-
.PHONY: fmt-v2
145-
fmt-v2:
146140
go run golang.org/x/tools/cmd/goimports -local "github.com/kgateway-dev/kgateway/" -w $(shell ls -d */ | grep -v vendor)
147141

148142
.PHONY: fmt-changed

docs/cmd/generate_docs.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ import (
1919

2020
"github.com/Masterminds/semver/v3"
2121
"github.com/google/go-github/v32/github"
22-
. "github.com/kgateway-dev/kgateway/docs/cmd/securityscanutils"
2322
"github.com/rotisserie/eris"
2423
changelogdocutils "github.com/solo-io/go-utils/changeloggenutils"
2524
"github.com/solo-io/go-utils/githubutils"
2625
"github.com/solo-io/go-utils/versionutils"
2726
"github.com/spf13/cobra"
27+
28+
. "github.com/kgateway-dev/kgateway/docs/cmd/securityscanutils"
2829
)
2930

3031
func main() {

docs/cmd/test/securityscanutils/generate_securityscan_doc_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package securityscanutils_test
22

33
import (
4-
. "github.com/kgateway-dev/kgateway/docs/cmd/securityscanutils"
54
. "github.com/onsi/ginkgo/v2"
65
. "github.com/onsi/gomega"
6+
7+
. "github.com/kgateway-dev/kgateway/docs/cmd/securityscanutils"
78
)
89

910
var _ = Describe("generate security scan docgen", func() {

docs/content/crds/generate.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ import (
88
"strings"
99

1010
"github.com/hashicorp/go-multierror"
11-
"github.com/kgateway-dev/kgateway/pkg/utils/cmdutils"
12-
"github.com/kgateway-dev/kgateway/projects/gateway2/api/v1alpha1"
1311
"github.com/rotisserie/eris"
1412
"github.com/stoewer/go-strcase"
1513
"k8s.io/apimachinery/pkg/runtime/schema"
14+
15+
"github.com/kgateway-dev/kgateway/pkg/utils/cmdutils"
16+
"github.com/kgateway-dev/kgateway/projects/gateway2/api/v1alpha1"
1617
)
1718

1819
func main() {

docs/content/guides/dev/example-proxy-controller.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ import (
1212
"os"
1313
"time"
1414

15-
v1 "github.com/kgateway-dev/kgateway/projects/gloo/pkg/api/v1"
16-
matchers "github.com/kgateway-dev/kgateway/projects/gloo/pkg/api/v1/core/matchers"
1715
"github.com/solo-io/k8s-utils/kubeutils"
1816
"github.com/solo-io/solo-kit/pkg/api/v1/clients"
1917
"github.com/solo-io/solo-kit/pkg/api/v1/clients/factory"
2018
"github.com/solo-io/solo-kit/pkg/api/v1/clients/kube"
2119
core "github.com/solo-io/solo-kit/pkg/api/v1/resources/core"
2220

21+
v1 "github.com/kgateway-dev/kgateway/projects/gloo/pkg/api/v1"
22+
matchers "github.com/kgateway-dev/kgateway/projects/gloo/pkg/api/v1/core/matchers"
23+
2324
// import for GKE
2425
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
2526
)

docs/content/guides/dev/plugin.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ import (
1111
"time"
1212

1313
cluster_v3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
14+
"github.com/solo-io/solo-kit/pkg/api/v1/clients"
15+
"github.com/solo-io/solo-kit/pkg/api/v1/resources/core"
16+
1417
v1 "github.com/kgateway-dev/kgateway/projects/gloo/pkg/api/v1"
1518
"github.com/kgateway-dev/kgateway/projects/gloo/pkg/discovery"
1619
"github.com/kgateway-dev/kgateway/projects/gloo/pkg/plugins"
17-
"github.com/solo-io/solo-kit/pkg/api/v1/clients"
18-
"github.com/solo-io/solo-kit/pkg/api/v1/resources/core"
1920

2021
// add these imports to use Envoy's API
2122
envoycore "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"

install/test/5-gateway-validation-webhook-configuration_test.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import (
1010
"strings"
1111

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

17-
gloostringutils "github.com/kgateway-dev/kgateway/pkg/utils/stringutils"
16+
glootestutils "github.com/kgateway-dev/kgateway/test/testutils"
17+
1818
. "github.com/onsi/ginkgo/v2"
1919
. "github.com/onsi/gomega"
2020
"github.com/solo-io/go-utils/stringutils"
@@ -23,6 +23,8 @@ import (
2323
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
2424
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2525
"sigs.k8s.io/yaml"
26+
27+
gloostringutils "github.com/kgateway-dev/kgateway/pkg/utils/stringutils"
2628
)
2729

2830
const (

install/test/grpc_json_transcoder_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ import (
88
"os"
99
"strconv"
1010

11-
"github.com/kgateway-dev/kgateway/projects/gateway/pkg/defaults"
12-
glootestutils "github.com/kgateway-dev/kgateway/test/testutils"
1311
. "github.com/onsi/ginkgo/v2"
1412
. "github.com/onsi/gomega"
1513
"github.com/onsi/gomega/types"
1614
. "github.com/solo-io/k8s-utils/manifesttestutils"
1715
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
16+
17+
"github.com/kgateway-dev/kgateway/projects/gateway/pkg/defaults"
18+
glootestutils "github.com/kgateway-dev/kgateway/test/testutils"
1819
)
1920

2021
var _ = Describe("GrpcJsonTranscoder helm test", func() {

install/test/helm_suite_test.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ import (
1111
"text/template"
1212

1313
"github.com/ghodss/yaml"
14-
"github.com/kgateway-dev/kgateway/pkg/cliutil/helm"
15-
"github.com/kgateway-dev/kgateway/projects/gloo/cli/pkg/cmd/install"
16-
"github.com/kgateway-dev/kgateway/projects/gloo/pkg/defaults"
17-
"github.com/kgateway-dev/kgateway/test/makefile"
18-
glootestutils "github.com/kgateway-dev/kgateway/test/testutils"
1914
. "github.com/onsi/ginkgo/v2"
2015
. "github.com/onsi/gomega"
2116
"github.com/pkg/errors"
@@ -30,6 +25,12 @@ import (
3025
rbacv1 "k8s.io/api/rbac/v1"
3126
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
3227
"k8s.io/apimachinery/pkg/runtime"
28+
29+
"github.com/kgateway-dev/kgateway/pkg/cliutil/helm"
30+
"github.com/kgateway-dev/kgateway/projects/gloo/cli/pkg/cmd/install"
31+
"github.com/kgateway-dev/kgateway/projects/gloo/pkg/defaults"
32+
"github.com/kgateway-dev/kgateway/test/makefile"
33+
glootestutils "github.com/kgateway-dev/kgateway/test/testutils"
3334
)
3435

3536
const (

install/test/helm_test.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ import (
1414

1515
"github.com/ghodss/yaml"
1616
"github.com/golang/protobuf/proto"
17-
values "github.com/kgateway-dev/kgateway/install/helm/gloo/generate"
18-
"github.com/kgateway-dev/kgateway/install/test/securitycontext"
19-
"github.com/kgateway-dev/kgateway/pkg/utils/kubeutils"
20-
"github.com/kgateway-dev/kgateway/projects/gateway/pkg/defaults"
21-
"github.com/kgateway-dev/kgateway/test/gomega/matchers"
22-
glootestutils "github.com/kgateway-dev/kgateway/test/testutils"
2317
. "github.com/onsi/ginkgo/v2"
2418
. "github.com/onsi/gomega"
2519
"github.com/onsi/gomega/format"
@@ -38,6 +32,13 @@ import (
3832
"k8s.io/apimachinery/pkg/util/intstr"
3933
"k8s.io/apimachinery/pkg/util/sets"
4034
"k8s.io/utils/pointer"
35+
36+
values "github.com/kgateway-dev/kgateway/install/helm/gloo/generate"
37+
"github.com/kgateway-dev/kgateway/install/test/securitycontext"
38+
"github.com/kgateway-dev/kgateway/pkg/utils/kubeutils"
39+
"github.com/kgateway-dev/kgateway/projects/gateway/pkg/defaults"
40+
"github.com/kgateway-dev/kgateway/test/gomega/matchers"
41+
glootestutils "github.com/kgateway-dev/kgateway/test/testutils"
4142
)
4243

4344
func GetPodNamespaceStats() corev1.EnvVar {

install/test/k8sgateway_test.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@ package test
55
import (
66
"fmt"
77

8-
"github.com/kgateway-dev/kgateway/install/utils/kuberesource"
9-
"github.com/kgateway-dev/kgateway/pkg/utils/kubeutils"
10-
"github.com/kgateway-dev/kgateway/projects/gateway2/api/v1alpha1"
11-
"github.com/kgateway-dev/kgateway/projects/gateway2/wellknown"
12-
"github.com/kgateway-dev/kgateway/test/gomega/matchers"
13-
glootestutils "github.com/kgateway-dev/kgateway/test/testutils"
148
. "github.com/onsi/ginkgo/v2"
159
. "github.com/onsi/gomega"
1610
. "github.com/solo-io/k8s-utils/manifesttestutils"
1711
corev1 "k8s.io/api/core/v1"
1812
"k8s.io/apimachinery/pkg/api/resource"
1913
"k8s.io/apimachinery/pkg/util/intstr"
2014
"k8s.io/utils/pointer"
15+
16+
"github.com/kgateway-dev/kgateway/install/utils/kuberesource"
17+
"github.com/kgateway-dev/kgateway/pkg/utils/kubeutils"
18+
"github.com/kgateway-dev/kgateway/projects/gateway2/api/v1alpha1"
19+
"github.com/kgateway-dev/kgateway/projects/gateway2/wellknown"
20+
"github.com/kgateway-dev/kgateway/test/gomega/matchers"
21+
glootestutils "github.com/kgateway-dev/kgateway/test/testutils"
2122
)
2223

2324
var _ = Describe("Kubernetes Gateway API integration", func() {

install/test/rbac_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ package test
55
import (
66
"fmt"
77

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

10+
glootestutils "github.com/kgateway-dev/kgateway/test/testutils"
11+
1112
. "github.com/onsi/ginkgo/v2"
1213
. "github.com/onsi/gomega"
1314
"github.com/onsi/gomega/format"

install/test/svc_accnt_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
package test
44

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

8+
glootestutils "github.com/kgateway-dev/kgateway/test/testutils"
9+
910
. "github.com/onsi/gomega"
1011
. "github.com/solo-io/k8s-utils/manifesttestutils"
1112
)

pkg/bootstrap/leaderelector/identity_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package leaderelector_test
22

33
import (
4-
"github.com/kgateway-dev/kgateway/pkg/bootstrap/leaderelector"
54
. "github.com/onsi/ginkgo/v2"
65
. "github.com/onsi/gomega"
6+
7+
"github.com/kgateway-dev/kgateway/pkg/bootstrap/leaderelector"
78
)
89

910
var _ = Describe("Identity", func() {

pkg/bootstrap/leaderelector/kube/factory.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import (
66
"sync/atomic"
77
"time"
88

9-
"github.com/kgateway-dev/kgateway/pkg/bootstrap/leaderelector"
10-
"github.com/kgateway-dev/kgateway/pkg/utils/envutils"
119
"github.com/solo-io/go-utils/contextutils"
1210
"k8s.io/client-go/rest"
1311
k8sleaderelection "k8s.io/client-go/tools/leaderelection"
1412
"sigs.k8s.io/controller-runtime/pkg/leaderelection"
13+
14+
"github.com/kgateway-dev/kgateway/pkg/bootstrap/leaderelector"
15+
"github.com/kgateway-dev/kgateway/pkg/utils/envutils"
1516
)
1617

1718
var _ leaderelector.ElectionFactory = new(kubeElectionFactory)

pkg/bootstrap/leaderelector/leader_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import (
44
"context"
55
"sync/atomic"
66

7-
"github.com/kgateway-dev/kgateway/pkg/bootstrap/leaderelector"
87
. "github.com/onsi/ginkgo/v2"
98
. "github.com/onsi/gomega"
9+
10+
"github.com/kgateway-dev/kgateway/pkg/bootstrap/leaderelector"
1011
)
1112

1213
var _ = Describe("Leader Startup Action", func() {

pkg/bootstrap/leaderelector/singlereplica/factory.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package singlereplica
33
import (
44
"context"
55

6-
"github.com/kgateway-dev/kgateway/pkg/bootstrap/leaderelector"
76
"github.com/solo-io/go-utils/contextutils"
7+
8+
"github.com/kgateway-dev/kgateway/pkg/bootstrap/leaderelector"
89
)
910

1011
var _ leaderelector.ElectionFactory = new(singleReplicaElectionFactory)

pkg/cliutil/input_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package cliutil_test
22

33
import (
4-
. "github.com/kgateway-dev/kgateway/pkg/cliutil"
5-
"github.com/kgateway-dev/kgateway/pkg/cliutil/testutil"
64
. "github.com/onsi/ginkgo/v2"
75
. "github.com/onsi/gomega"
6+
7+
. "github.com/kgateway-dev/kgateway/pkg/cliutil"
8+
"github.com/kgateway-dev/kgateway/pkg/cliutil/testutil"
89
)
910

1011
var _ = Describe("GetBoolInput", func() {

pkg/cliutil/testutil/testutil.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ import (
77

88
expect "github.com/Netflix/go-expect"
99
"github.com/hinshun/vt10x"
10-
"github.com/kgateway-dev/kgateway/pkg/cliutil"
1110
. "github.com/onsi/ginkgo/v2"
1211
. "github.com/onsi/gomega"
1312
"gopkg.in/AlecAivazis/survey.v1/terminal"
13+
14+
"github.com/kgateway-dev/kgateway/pkg/cliutil"
1415
)
1516

1617
func Stdio(c *expect.Console) terminal.Stdio {

pkg/cliutil/uri.go

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/kgateway-dev/kgateway/pkg/utils/kubeutils"
1818

1919
"github.com/avast/retry-go/v4"
20+
2021
"github.com/kgateway-dev/kgateway/pkg/utils/kubeutils/portforward"
2122

2223
"github.com/hashicorp/go-multierror"

pkg/github-action-utils/version.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import (
55
"math"
66
"os"
77

8-
"github.com/kgateway-dev/kgateway/pkg/version"
98
"github.com/pkg/errors"
109
"github.com/solo-io/go-utils/changelogutils"
1110
"github.com/solo-io/go-utils/versionutils"
1211
"github.com/solo-io/go-utils/vfsutils"
12+
13+
"github.com/kgateway-dev/kgateway/pkg/version"
1314
)
1415

1516
// GetLatestEnterpriseVersion computes the latest Gloo Enterprise version.

pkg/schemes/extended_scheme.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ package schemes
33
import (
44
"fmt"
55

6-
"github.com/kgateway-dev/kgateway/projects/gateway2/wellknown"
76
"k8s.io/apimachinery/pkg/api/errors"
87
"k8s.io/apimachinery/pkg/api/meta"
98
"k8s.io/apimachinery/pkg/runtime"
109
"k8s.io/client-go/discovery"
1110
"k8s.io/client-go/rest"
1211

12+
"github.com/kgateway-dev/kgateway/projects/gateway2/wellknown"
13+
1314
gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
1415
)
1516

pkg/utils/envoyutils/admincli/client.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ import (
1010
adminv3 "github.com/envoyproxy/go-control-plane/envoy/admin/v3"
1111
clusterv3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
1212
listenerv3 "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3"
13+
"github.com/solo-io/go-utils/threadsafe"
14+
1315
"github.com/kgateway-dev/kgateway/pkg/utils/cmdutils"
1416
"github.com/kgateway-dev/kgateway/pkg/utils/protoutils"
1517
"github.com/kgateway-dev/kgateway/pkg/utils/requestutils/curl"
16-
"github.com/solo-io/go-utils/threadsafe"
1718

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

pkg/utils/envoyutils/admincli/client_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package admincli_test
33
import (
44
"context"
55

6-
"github.com/kgateway-dev/kgateway/pkg/utils/envoyutils/admincli"
7-
"github.com/kgateway-dev/kgateway/pkg/utils/requestutils/curl"
86
. "github.com/onsi/ginkgo/v2"
97
. "github.com/onsi/gomega"
108
"github.com/solo-io/go-utils/threadsafe"
9+
10+
"github.com/kgateway-dev/kgateway/pkg/utils/envoyutils/admincli"
11+
"github.com/kgateway-dev/kgateway/pkg/utils/requestutils/curl"
1112
)
1213

1314
var _ = Describe("Client", func() {

pkg/utils/envoyutils/bootstrap/bootstrap.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ import (
1313
envoy_extensions_filters_network_http_connection_manager_v3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3"
1414
envoycache "github.com/envoyproxy/go-control-plane/pkg/cache/v3"
1515
"github.com/envoyproxy/go-control-plane/pkg/wellknown"
16-
"github.com/kgateway-dev/kgateway/projects/gateway2/utils"
1716
"github.com/rotisserie/eris"
1817
"google.golang.org/protobuf/encoding/protojson"
1918
"google.golang.org/protobuf/proto"
2019
"google.golang.org/protobuf/types/known/anypb"
20+
21+
"github.com/kgateway-dev/kgateway/projects/gateway2/utils"
2122
)
2223

2324
var (

0 commit comments

Comments
 (0)