Skip to content

Commit f48ee3c

Browse files
committed
Enable the golangci-lint "import" preset
Most of our files are close to this convention already. The errors reported by "gci" have improved enough to be useful and it can fix typos automatically.
1 parent 46ee186 commit f48ee3c

File tree

17 files changed

+20
-40
lines changed

17 files changed

+20
-40
lines changed

.golangci.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,17 @@
33
linters:
44
disable:
55
- contextcheck
6-
- gci
76
- gofumpt
87
enable:
9-
- depguard
108
- goheader
11-
- gomodguard
129
- gosimple
1310
- importas
1411
- misspell
1512
- unconvert
1613
presets:
1714
- bugs
1815
- format
16+
- import
1917
- unused
2018

2119
linters-settings:
@@ -61,6 +59,12 @@ linters-settings:
6159
exhaustive:
6260
default-signifies-exhaustive: true
6361

62+
gci:
63+
sections:
64+
- standard
65+
- default
66+
- localmodule
67+
6468
goheader:
6569
template: |-
6670
Copyright {{ DATES }} Crunchy Data Solutions, Inc.
@@ -70,9 +74,6 @@ linters-settings:
7074
regexp:
7175
DATES: '((201[7-9]|202[0-4]) - 2025|2025)'
7276

73-
goimports:
74-
local-prefixes: github.com/crunchydata/postgres-operator
75-
7677
gomodguard:
7778
blocked:
7879
modules:

internal/bridge/crunchybridgecluster/mock_bridge_api.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313

1414
"github.com/crunchydata/postgres-operator/internal/bridge"
1515
"github.com/crunchydata/postgres-operator/internal/initialize"
16-
1716
"github.com/crunchydata/postgres-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
1817
)
1918

internal/bridge/crunchybridgecluster/postgres.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/pkg/errors"
1212
corev1 "k8s.io/api/core/v1"
1313
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
14-
1514
ctrl "sigs.k8s.io/controller-runtime"
1615
"sigs.k8s.io/controller-runtime/pkg/client"
1716

internal/bridge/crunchybridgecluster/postgres_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ import (
88
"context"
99
"testing"
1010

11-
"sigs.k8s.io/controller-runtime/pkg/client"
12-
1311
"gotest.tools/v3/assert"
1412
corev1 "k8s.io/api/core/v1"
1513
apierrors "k8s.io/apimachinery/pkg/api/errors"
1614
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
15+
"sigs.k8s.io/controller-runtime/pkg/client"
1716

1817
"github.com/crunchydata/postgres-operator/internal/bridge"
1918
"github.com/crunchydata/postgres-operator/internal/testing/require"

internal/controller/postgrescluster/controller_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
. "github.com/onsi/gomega"
1515
. "github.com/onsi/gomega/gstruct"
1616
"github.com/pkg/errors" //nolint:depguard // This legacy test covers so much code, it logs the origin of unexpected errors.
17-
1817
"gotest.tools/v3/assert"
1918
appsv1 "k8s.io/api/apps/v1"
2019
corev1 "k8s.io/api/core/v1"

internal/controller/postgrescluster/snapshots.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ import (
1010
"strings"
1111
"time"
1212

13+
volumesnapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
1314
"github.com/pkg/errors"
1415
batchv1 "k8s.io/api/batch/v1"
1516
corev1 "k8s.io/api/core/v1"
1617
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1718
"k8s.io/apimachinery/pkg/labels"
1819
"sigs.k8s.io/controller-runtime/pkg/client"
1920

20-
volumesnapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
21-
2221
"github.com/crunchydata/postgres-operator/internal/config"
2322
"github.com/crunchydata/postgres-operator/internal/feature"
2423
"github.com/crunchydata/postgres-operator/internal/initialize"

internal/controller/postgrescluster/snapshots_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"testing"
1010
"time"
1111

12+
volumesnapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
1213
"gotest.tools/v3/assert"
1314
appsv1 "k8s.io/api/apps/v1"
1415
batchv1 "k8s.io/api/batch/v1"
@@ -27,8 +28,6 @@ import (
2728
"github.com/crunchydata/postgres-operator/internal/testing/events"
2829
"github.com/crunchydata/postgres-operator/internal/testing/require"
2930
"github.com/crunchydata/postgres-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
30-
31-
volumesnapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
3231
)
3332

3433
func TestReconcileVolumeSnapshots(t *testing.T) {

internal/controller/postgrescluster/suite_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ import (
1414
. "github.com/onsi/gomega"
1515
"k8s.io/apimachinery/pkg/util/version"
1616
"k8s.io/client-go/discovery"
17-
18-
// Google Kubernetes Engine / Google Cloud Platform authentication provider
19-
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
2017
"k8s.io/client-go/rest"
2118
"sigs.k8s.io/controller-runtime/pkg/client"
2219
"sigs.k8s.io/controller-runtime/pkg/log"

internal/controller/runtime/runtime.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package runtime
66

77
import (
8+
volumesnapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
89
"k8s.io/apimachinery/pkg/runtime"
910
"k8s.io/client-go/kubernetes/scheme"
1011
"k8s.io/client-go/rest"
@@ -15,8 +16,6 @@ import (
1516

1617
"github.com/crunchydata/postgres-operator/internal/logging"
1718
"github.com/crunchydata/postgres-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
18-
19-
volumesnapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
2019
)
2120

2221
type (

internal/controller/standalone_pgadmin/configmap.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ import (
1414
"strconv"
1515
"strings"
1616

17-
corev1 "k8s.io/api/core/v1"
18-
1917
"github.com/pkg/errors"
18+
corev1 "k8s.io/api/core/v1"
2019

2120
"github.com/crunchydata/postgres-operator/internal/collector"
2221
"github.com/crunchydata/postgres-operator/internal/initialize"

0 commit comments

Comments
 (0)