Skip to content

Commit de8cad7

Browse files
authored
Merge pull request #11 from sttts/sttts-gci
🌱 Add gci for import sorting
2 parents 42599a8 + 0200608 commit de8cad7

File tree

9 files changed

+43
-31
lines changed

9 files changed

+43
-31
lines changed

.golangci.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ linters:
2525
- errchkjson
2626
- errorlint
2727
- exhaustive
28+
- gci
2829
- ginkgolinter
2930
- goconst
3031
- gocritic
@@ -53,6 +54,18 @@ linters:
5354
- whitespace
5455

5556
linters-settings:
57+
gci:
58+
custom-order: true
59+
sections:
60+
- standard
61+
- default
62+
- prefix(k8s.io,sigs.k8s.io)
63+
- prefix(github.com/kcp-dev)
64+
- prefix(github.com/multicluster-runtime)
65+
- prefix(github.com/kcp-dev/multicluster-provider)
66+
- blank
67+
- dot
68+
skip-generated: true
5669
govet:
5770
enable-all: true
5871
disable:

Makefile

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,6 @@ $(GOLANGCI_LINT):
3737
golangci-lint \
3838
${GOLANGCI_LINT_VERSION}
3939

40-
GIMPS = _tools/gimps
41-
GIMPS_VERSION = 0.6.0
42-
43-
.PHONY: $(GIMPS)
44-
$(GIMPS):
45-
@hack/download-tool.sh \
46-
https://github.com/xrstf/gimps/releases/download/v${GIMPS_VERSION}/gimps_${GIMPS_VERSION}_${GOOS}_${GOARCH}.tar.gz \
47-
gimps \
48-
${GIMPS_VERSION}
49-
5040
WWHRD = _tools/wwhrd
5141
WWHRD_VERSION = 0.4.0
5242

@@ -100,8 +90,15 @@ lint: $(GOLANGCI_LINT)
10090
./...
10191

10292
.PHONY: imports
103-
imports: $(GIMPS)
104-
$(GIMPS) .
93+
imports: WHAT ?=
94+
imports: $(GOLANGCI_LINT)
95+
@if [ -n "$(WHAT)" ]; then \
96+
$(GOLANGCI_LINT) run --enable-only=gci --fix --fast $(WHAT); \
97+
else \
98+
for MOD in . $$(git ls-files '**/go.mod' | sed 's,/go.mod,,'); do \
99+
(cd $$MOD; $(GOLANGCI_LINT) run --enable-only=gci --fix --fast); \
100+
done; \
101+
fi
105102

106103
.PHONY: verify
107104
verify:

virtualworkspace/cache.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ import (
2222
"fmt"
2323
"time"
2424

25-
"github.com/kcp-dev/logicalcluster/v3"
26-
2725
"k8s.io/apimachinery/pkg/runtime/schema"
2826
toolscache "k8s.io/client-go/tools/cache"
2927
"sigs.k8s.io/controller-runtime/pkg/cache"
3028
"sigs.k8s.io/controller-runtime/pkg/client"
29+
30+
"github.com/kcp-dev/logicalcluster/v3"
3131
)
3232

3333
var _ cache.Cache = &scopedCache{}

virtualworkspace/cluster.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ import (
2323
"net/http"
2424
"net/url"
2525

26-
"github.com/kcp-dev/logicalcluster/v3"
27-
2826
"k8s.io/apimachinery/pkg/api/meta"
2927
"k8s.io/apimachinery/pkg/runtime"
3028
"k8s.io/client-go/rest"
@@ -33,6 +31,8 @@ import (
3331
"sigs.k8s.io/controller-runtime/pkg/client"
3432
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
3533
"sigs.k8s.io/controller-runtime/pkg/cluster"
34+
35+
"github.com/kcp-dev/logicalcluster/v3"
3636
)
3737

3838
func newScopedCluster(cfg *rest.Config, clusterName logicalcluster.Name, wildcardCA WildcardCache, scheme *runtime.Scheme) (*scopedCluster, error) {

virtualworkspace/forked_cache_reader.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ import (
2424
"fmt"
2525
"reflect"
2626

27-
kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache"
28-
"github.com/kcp-dev/logicalcluster/v3"
29-
3027
apierrors "k8s.io/apimachinery/pkg/api/errors"
3128
apimeta "k8s.io/apimachinery/pkg/api/meta"
3229
"k8s.io/apimachinery/pkg/fields"
@@ -36,6 +33,9 @@ import (
3633
"k8s.io/apimachinery/pkg/selection"
3734
"k8s.io/client-go/tools/cache"
3835
"sigs.k8s.io/controller-runtime/pkg/client"
36+
37+
kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache"
38+
"github.com/kcp-dev/logicalcluster/v3"
3939
)
4040

4141
// cacheReader is a client.Reader.

virtualworkspace/indexes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ package virtualworkspace
1919
import (
2020
"fmt"
2121

22-
"github.com/kcp-dev/logicalcluster/v3"
23-
2422
"k8s.io/apimachinery/pkg/api/meta"
23+
24+
"github.com/kcp-dev/logicalcluster/v3"
2525
)
2626

2727
// ClusterIndexFunc indexes by cluster name.

virtualworkspace/indexes_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ package virtualworkspace
1919
import (
2020
"testing"
2121

22-
"github.com/kcp-dev/logicalcluster/v3"
2322
"github.com/stretchr/testify/require"
2423

2524
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
25+
26+
"github.com/kcp-dev/logicalcluster/v3"
2627
)
2728

2829
func TestClusterIndexFunc(t *testing.T) {

virtualworkspace/provider.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,8 @@ import (
2323
"time"
2424

2525
"github.com/go-logr/logr"
26-
kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache"
27-
"github.com/kcp-dev/logicalcluster/v3"
2826
"golang.org/x/sync/errgroup"
2927

30-
mcmanager "github.com/multicluster-runtime/multicluster-runtime/pkg/manager"
31-
"github.com/multicluster-runtime/multicluster-runtime/pkg/multicluster"
32-
3328
"k8s.io/apimachinery/pkg/runtime"
3429
"k8s.io/client-go/kubernetes/scheme"
3530
"k8s.io/client-go/rest"
@@ -39,6 +34,12 @@ import (
3934
"sigs.k8s.io/controller-runtime/pkg/client"
4035
"sigs.k8s.io/controller-runtime/pkg/cluster"
4136
"sigs.k8s.io/controller-runtime/pkg/log"
37+
38+
kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache"
39+
"github.com/kcp-dev/logicalcluster/v3"
40+
41+
mcmanager "github.com/multicluster-runtime/multicluster-runtime/pkg/manager"
42+
"github.com/multicluster-runtime/multicluster-runtime/pkg/multicluster"
4243
)
4344

4445
var _ multicluster.Provider = &Provider{}

virtualworkspace/wildcard.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ import (
2323
"sync"
2424
"time"
2525

26-
kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache"
27-
kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers"
28-
"github.com/kcp-dev/logicalcluster/v3"
29-
3026
apimeta "k8s.io/apimachinery/pkg/api/meta"
3127
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3228
"k8s.io/apimachinery/pkg/runtime"
@@ -38,6 +34,10 @@ import (
3834
"sigs.k8s.io/controller-runtime/pkg/cache"
3935
"sigs.k8s.io/controller-runtime/pkg/client"
4036
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
37+
38+
kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache"
39+
kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers"
40+
"github.com/kcp-dev/logicalcluster/v3"
4141
)
4242

4343
// WildcardCache is a cache that operates on a /clusters/* endpoint.

0 commit comments

Comments
 (0)