Skip to content

Commit 8ca0835

Browse files
[Linter] Update linter rules to force import ordering (#1044)
1 parent a9dee48 commit 8ca0835

File tree

429 files changed

+1100
-1121
lines changed

Some content is hidden

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

429 files changed

+1100
-1121
lines changed

.golangci.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,21 @@ linters:
2424
- unused
2525
- varcheck
2626
- importas
27+
- gci
2728

2829
linters-settings:
2930
importas:
31+
no-unaliased: true
3032
alias:
3133
- pkg: k8s.io/api/core/v1
3234
alias: core
3335
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
3436
alias: meta
37+
- pkg: k8s.io/client-go/kubernetes/typed/core/v1
38+
alias: typedCore
39+
gci:
40+
sections:
41+
- standard
42+
- default
43+
- prefix(github.com/arangodb)
44+
- prefix(github.com/arangodb/kube-arangodb)

Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,9 @@ ifdef VERBOSE
155155
TESTVERBOSEOPTIONS := -v
156156
endif
157157

158-
EXCLUDE_DIRS := vendor .gobuild deps tools
159-
SOURCES_QUERY := find ./ -type f -name '*.go' $(foreach EXCLUDE_DIR,$(EXCLUDE_DIRS), ! -path "*/$(EXCLUDE_DIR)/*")
158+
EXCLUDE_DIRS := vendor .gobuild deps tools pkg/generated
159+
EXCLUDE_FILES := *generated.deepcopy.go
160+
SOURCES_QUERY := find ./ -type f -name '*.go' $(foreach EXCLUDE_DIR,$(EXCLUDE_DIRS), ! -path "*/$(EXCLUDE_DIR)/*") $(foreach EXCLUDE_FILE,$(EXCLUDE_FILES), ! -path "*/$(EXCLUDE_FILE)")
160161
SOURCES := $(shell $(SOURCES_QUERY))
161162
DASHBOARDSOURCES := $(shell find $(DASHBOARDDIR)/src -name '*.js') $(DASHBOARDDIR)/package.json
162163
LINT_EXCLUDES:=
@@ -166,7 +167,6 @@ else
166167
LINT_EXCLUDES+=.*\.enterprise\.go$$
167168
endif
168169

169-
170170
.DEFAULT_GOAL := all
171171
.PHONY: all
172172
all: check-vars verify-generated build
@@ -191,6 +191,7 @@ license-verify:
191191
fmt:
192192
@echo ">> Ensuring style of files"
193193
@$(GOPATH)/bin/goimports -w $(SOURCES)
194+
@$(GOPATH)/bin/gci write -s "standard" -s "default" -s "prefix(github.com/arangodb)" -s "prefix(github.com/arangodb/kube-arangodb)" $(SOURCES)
194195

195196
.PHONY: license
196197
license:
@@ -454,13 +455,15 @@ init: tools update-generated $(BIN) vendor
454455
.PHONY: tools
455456
tools: update-vendor
456457
@echo ">> Fetching golangci-lint linter"
457-
@GOBIN=$(GOPATH)/bin go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.42.1
458+
@GOBIN=$(GOPATH)/bin go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.46.2
458459
@echo ">> Fetching goimports"
459460
@GOBIN=$(GOPATH)/bin go install golang.org/x/tools/cmd/goimports@0bb7e5c47b1a31f85d4f173edc878a8e049764a5
460461
@echo ">> Fetching license check"
461462
@GOBIN=$(GOPATH)/bin go install github.com/google/addlicense@6d92264d717064f28b32464f0f9693a5b4ef0239
462463
@echo ">> Fetching GO Assets Builder"
463464
@GOBIN=$(GOPATH)/bin go install github.com/jessevdk/go-assets-builder@b8483521738fd2198ecfc378067a4e8a6079f8e5
465+
@echo ">> Fetching gci"
466+
@GOBIN=$(GOPATH)/bin go install github.com/daixiang0/gci@v0.3.0
464467

465468
.PHONY: vendor
466469
vendor:

cmd/admin.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@ import (
3333
"strconv"
3434
"syscall"
3535

36-
"github.com/arangodb/kube-arangodb/pkg/util/globals"
37-
3836
"github.com/spf13/cobra"
3937
core "k8s.io/api/core/v1"
4038
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
4139

4240
"github.com/arangodb-helper/go-certificates"
4341
"github.com/arangodb/go-driver/jwt"
4442
"github.com/arangodb/go-driver/v2/connection"
43+
4544
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
4645
"github.com/arangodb/kube-arangodb/pkg/apis/shared"
4746
"github.com/arangodb/kube-arangodb/pkg/util/constants"
4847
"github.com/arangodb/kube-arangodb/pkg/util/errors"
48+
"github.com/arangodb/kube-arangodb/pkg/util/globals"
4949
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
5050
secretv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/secret/v1"
5151
"github.com/arangodb/kube-arangodb/pkg/util/kclient"

cmd/cmd.go

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,43 +31,38 @@ import (
3131
"strings"
3232
"time"
3333

34-
"github.com/arangodb/kube-arangodb/pkg/util/globals"
35-
3634
"github.com/gin-gonic/gin"
37-
38-
operatorHTTP "github.com/arangodb/kube-arangodb/pkg/util/http"
39-
40-
"github.com/arangodb/kube-arangodb/pkg/version"
41-
42-
"github.com/arangodb/kube-arangodb/pkg/operator/scope"
43-
44-
"github.com/arangodb/kube-arangodb/pkg/deployment/features"
35+
"github.com/pkg/errors"
36+
"github.com/rs/zerolog"
37+
"github.com/spf13/cobra"
38+
flag "github.com/spf13/pflag"
39+
appsv1 "k8s.io/api/apps/v1"
40+
core "k8s.io/api/core/v1"
41+
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
42+
"k8s.io/apimachinery/pkg/runtime"
43+
"k8s.io/client-go/kubernetes"
44+
typedCore "k8s.io/client-go/kubernetes/typed/core/v1"
45+
"k8s.io/client-go/tools/record"
46+
"k8s.io/klog"
4547

4648
deploymentApi "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
4749
"github.com/arangodb/kube-arangodb/pkg/crd"
50+
"github.com/arangodb/kube-arangodb/pkg/deployment/features"
4851
"github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/scheme"
4952
"github.com/arangodb/kube-arangodb/pkg/logging"
5053
"github.com/arangodb/kube-arangodb/pkg/operator"
54+
"github.com/arangodb/kube-arangodb/pkg/operator/scope"
5155
"github.com/arangodb/kube-arangodb/pkg/server"
5256
"github.com/arangodb/kube-arangodb/pkg/util"
5357
"github.com/arangodb/kube-arangodb/pkg/util/constants"
5458
utilsError "github.com/arangodb/kube-arangodb/pkg/util/errors"
59+
"github.com/arangodb/kube-arangodb/pkg/util/globals"
60+
operatorHTTP "github.com/arangodb/kube-arangodb/pkg/util/http"
5561
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
5662
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
5763
"github.com/arangodb/kube-arangodb/pkg/util/probe"
5864
"github.com/arangodb/kube-arangodb/pkg/util/retry"
59-
"github.com/pkg/errors"
60-
"github.com/rs/zerolog"
61-
"github.com/spf13/cobra"
62-
flag "github.com/spf13/pflag"
63-
appsv1 "k8s.io/api/apps/v1"
64-
core "k8s.io/api/core/v1"
65-
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
66-
"k8s.io/apimachinery/pkg/runtime"
67-
"k8s.io/client-go/kubernetes"
68-
v1core "k8s.io/client-go/kubernetes/typed/core/v1"
69-
"k8s.io/client-go/tools/record"
70-
"k8s.io/klog"
65+
"github.com/arangodb/kube-arangodb/pkg/version"
7166
)
7267

7368
const (
@@ -477,7 +472,7 @@ func createRecorder(kubecli kubernetes.Interface, name, namespace string) record
477472
eventBroadcaster.StartLogging(func(format string, args ...interface{}) {
478473
eventRecorder.Info(format, args...)
479474
})
480-
eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: v1core.New(kubecli.CoreV1().RESTClient()).Events(namespace)})
475+
eventBroadcaster.StartRecordingToSink(&typedCore.EventSinkImpl{Interface: typedCore.New(kubecli.CoreV1().RESTClient()).Events(namespace)})
481476
combinedScheme := runtime.NewScheme()
482477
scheme.AddToScheme(combinedScheme)
483478
core.AddToScheme(combinedScheme)

cmd/exporter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ import (
2828
"syscall"
2929
"time"
3030

31-
"github.com/arangodb/kube-arangodb/pkg/exporter"
32-
"github.com/arangodb/kube-arangodb/pkg/util"
33-
3431
"github.com/rs/zerolog/log"
3532
"github.com/spf13/cobra"
33+
34+
"github.com/arangodb/kube-arangodb/pkg/exporter"
35+
"github.com/arangodb/kube-arangodb/pkg/util"
3636
)
3737

3838
var (

cmd/lifecycle.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,16 @@ import (
2929
"strconv"
3030
"time"
3131

32-
"github.com/arangodb/kube-arangodb/pkg/handlers/utils"
33-
34-
"github.com/arangodb/kube-arangodb/pkg/util/retry"
35-
36-
"github.com/arangodb/kube-arangodb/pkg/version"
37-
3832
"github.com/spf13/cobra"
3933
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
4034

4135
"github.com/arangodb/kube-arangodb/pkg/apis/shared"
36+
"github.com/arangodb/kube-arangodb/pkg/handlers/utils"
4237
"github.com/arangodb/kube-arangodb/pkg/util/constants"
4338
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
4439
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
40+
"github.com/arangodb/kube-arangodb/pkg/util/retry"
41+
"github.com/arangodb/kube-arangodb/pkg/version"
4542
)
4643

4744
var (

cmd/lifecycle_probes.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ import (
2828
"os"
2929
"path"
3030

31+
"github.com/pkg/errors"
32+
"github.com/rs/zerolog/log"
33+
"github.com/spf13/cobra"
34+
3135
"github.com/arangodb/go-driver/jwt"
36+
3237
"github.com/arangodb/kube-arangodb/pkg/apis/shared"
3338
"github.com/arangodb/kube-arangodb/pkg/deployment/pod"
3439
"github.com/arangodb/kube-arangodb/pkg/util/constants"
35-
"github.com/pkg/errors"
36-
"github.com/rs/zerolog/log"
37-
"github.com/spf13/cobra"
3840
)
3941

4042
var (

cmd/lifecycle_wait.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ import (
2626
"os"
2727
"time"
2828

29+
"github.com/spf13/cobra"
30+
2931
v1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
3032
"github.com/arangodb/kube-arangodb/pkg/util"
3133
"github.com/arangodb/kube-arangodb/pkg/util/constants"
32-
33-
"github.com/spf13/cobra"
3434
)
3535

3636
const (

cmd/reboot.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,21 @@ import (
3131
"strings"
3232
"sync"
3333

34+
"github.com/pkg/errors"
35+
"github.com/spf13/cobra"
36+
core "k8s.io/api/core/v1"
37+
"k8s.io/apimachinery/pkg/api/resource"
38+
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
39+
"k8s.io/apimachinery/pkg/fields"
3440
"k8s.io/apimachinery/pkg/util/intstr"
41+
"k8s.io/client-go/kubernetes"
3542

3643
deplv1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
3744
acli "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned"
3845
"github.com/arangodb/kube-arangodb/pkg/util"
3946
"github.com/arangodb/kube-arangodb/pkg/util/constants"
4047
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
4148
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
42-
"github.com/pkg/errors"
43-
"github.com/spf13/cobra"
44-
core "k8s.io/api/core/v1"
45-
"k8s.io/apimachinery/pkg/api/resource"
46-
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
47-
"k8s.io/apimachinery/pkg/fields"
48-
"k8s.io/client-go/kubernetes"
4949
)
5050

5151
var (

cmd/storage.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ import (
2626
"os"
2727
"strconv"
2828

29-
"github.com/arangodb/kube-arangodb/pkg/version"
30-
3129
"github.com/spf13/cobra"
3230

3331
"github.com/arangodb/kube-arangodb/pkg/storage/provisioner"
3432
"github.com/arangodb/kube-arangodb/pkg/storage/provisioner/service"
3533
"github.com/arangodb/kube-arangodb/pkg/util/constants"
34+
"github.com/arangodb/kube-arangodb/pkg/version"
3635
)
3736

3837
var (

0 commit comments

Comments
 (0)